ray.serve.llm.openai_api_models.ChatCompletionStreamResponse#

pydantic model ray.serve.llm.openai_api_models.ChatCompletionStreamResponse[source]#

ChatCompletionStreamResponse is the response body for the chat completion API.

This model is compatible with vLLM’s OpenAI API models.

PublicAPI (alpha): This API is in alpha and may change before becoming stable.

Show JSON schema
{
   "title": "ChatCompletionStreamResponse",
   "description": "ChatCompletionStreamResponse is the response body for the chat completion API.\n\nThis model is compatible with vLLM's OpenAI API models.\n\n**PublicAPI (alpha):** This API is in alpha and may change before becoming stable.",
   "type": "object",
   "properties": {
      "id": {
         "title": "Id",
         "type": "string"
      },
      "object": {
         "const": "chat.completion.chunk",
         "default": "chat.completion.chunk",
         "title": "Object",
         "type": "string"
      },
      "created": {
         "title": "Created",
         "type": "integer"
      },
      "model": {
         "title": "Model",
         "type": "string"
      },
      "choices": {
         "items": {
            "$ref": "#/$defs/ChatCompletionResponseStreamChoice"
         },
         "title": "Choices",
         "type": "array"
      },
      "usage": {
         "anyOf": [
            {
               "$ref": "#/$defs/UsageInfo"
            },
            {
               "type": "null"
            }
         ],
         "default": null
      }
   },
   "$defs": {
      "ChatCompletionLogProb": {
         "properties": {
            "token": {
               "title": "Token",
               "type": "string"
            },
            "logprob": {
               "default": -9999.0,
               "title": "Logprob",
               "type": "number"
            },
            "bytes": {
               "anyOf": [
                  {
                     "items": {
                        "type": "integer"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Bytes"
            }
         },
         "required": [
            "token"
         ],
         "title": "ChatCompletionLogProb",
         "type": "object"
      },
      "ChatCompletionLogProbs": {
         "properties": {
            "content": {
               "anyOf": [
                  {
                     "items": {
                        "$ref": "#/$defs/ChatCompletionLogProbsContent"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Content"
            }
         },
         "title": "ChatCompletionLogProbs",
         "type": "object"
      },
      "ChatCompletionLogProbsContent": {
         "properties": {
            "token": {
               "title": "Token",
               "type": "string"
            },
            "logprob": {
               "default": -9999.0,
               "title": "Logprob",
               "type": "number"
            },
            "bytes": {
               "anyOf": [
                  {
                     "items": {
                        "type": "integer"
                     },
                     "type": "array"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Bytes"
            },
            "top_logprobs": {
               "items": {
                  "$ref": "#/$defs/ChatCompletionLogProb"
               },
               "title": "Top Logprobs",
               "type": "array"
            }
         },
         "required": [
            "token"
         ],
         "title": "ChatCompletionLogProbsContent",
         "type": "object"
      },
      "ChatCompletionResponseStreamChoice": {
         "properties": {
            "index": {
               "title": "Index",
               "type": "integer"
            },
            "delta": {
               "$ref": "#/$defs/DeltaMessage"
            },
            "logprobs": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ChatCompletionLogProbs"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "finish_reason": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Finish Reason"
            },
            "stop_reason": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stop Reason"
            }
         },
         "required": [
            "index",
            "delta"
         ],
         "title": "ChatCompletionResponseStreamChoice",
         "type": "object"
      },
      "DeltaFunctionCall": {
         "properties": {
            "name": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Name"
            },
            "arguments": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Arguments"
            }
         },
         "title": "DeltaFunctionCall",
         "type": "object"
      },
      "DeltaMessage": {
         "properties": {
            "role": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Role"
            },
            "content": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Content"
            },
            "reasoning_content": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Reasoning Content"
            },
            "tool_calls": {
               "items": {
                  "$ref": "#/$defs/DeltaToolCall"
               },
               "title": "Tool Calls",
               "type": "array"
            }
         },
         "title": "DeltaMessage",
         "type": "object"
      },
      "DeltaToolCall": {
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "type": {
               "const": "function",
               "default": "function",
               "title": "Type",
               "type": "string"
            },
            "index": {
               "title": "Index",
               "type": "integer"
            },
            "function": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/DeltaFunctionCall"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            }
         },
         "required": [
            "index"
         ],
         "title": "DeltaToolCall",
         "type": "object"
      },
      "PromptTokenUsageInfo": {
         "properties": {
            "cached_tokens": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cached Tokens"
            }
         },
         "title": "PromptTokenUsageInfo",
         "type": "object"
      },
      "UsageInfo": {
         "properties": {
            "prompt_tokens": {
               "default": 0,
               "title": "Prompt Tokens",
               "type": "integer"
            },
            "total_tokens": {
               "default": 0,
               "title": "Total Tokens",
               "type": "integer"
            },
            "completion_tokens": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": 0,
               "title": "Completion Tokens"
            },
            "prompt_tokens_details": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/PromptTokenUsageInfo"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            }
         },
         "title": "UsageInfo",
         "type": "object"
      }
   },
   "required": [
      "model",
      "choices"
   ]
}

field choices: List[ChatCompletionResponseStreamChoice] [Required]#
field created: int [Optional]#
field id: str [Optional]#
field model: str [Required]#
field object: Literal['chat.completion.chunk'] = 'chat.completion.chunk'#
field usage: UsageInfo | None = None#