ray.serve.llm.openai_api_models.ChatCompletionResponse#

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

ChatCompletionResponse 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": "ChatCompletionResponse",
   "description": "ChatCompletionResponse 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",
         "default": "chat.completion",
         "title": "Object",
         "type": "string"
      },
      "created": {
         "title": "Created",
         "type": "integer"
      },
      "model": {
         "title": "Model",
         "type": "string"
      },
      "choices": {
         "items": {
            "$ref": "#/$defs/ChatCompletionResponseChoice"
         },
         "title": "Choices",
         "type": "array"
      },
      "usage": {
         "$ref": "#/$defs/UsageInfo"
      },
      "prompt_logprobs": {
         "anyOf": [
            {
               "items": {
                  "anyOf": [
                     {
                        "additionalProperties": {
                           "$ref": "#/$defs/Logprob"
                        },
                        "type": "object"
                     },
                     {
                        "type": "null"
                     }
                  ]
               },
               "type": "array"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Prompt Logprobs"
      }
   },
   "$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"
      },
      "ChatCompletionResponseChoice": {
         "properties": {
            "index": {
               "title": "Index",
               "type": "integer"
            },
            "message": {
               "$ref": "#/$defs/ChatMessage"
            },
            "logprobs": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/ChatCompletionLogProbs"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null
            },
            "finish_reason": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": "stop",
               "title": "Finish Reason"
            },
            "stop_reason": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Stop Reason"
            }
         },
         "required": [
            "index",
            "message"
         ],
         "title": "ChatCompletionResponseChoice",
         "type": "object"
      },
      "ChatMessage": {
         "properties": {
            "role": {
               "title": "Role",
               "type": "string"
            },
            "reasoning_content": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Reasoning Content"
            },
            "content": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Content"
            },
            "tool_calls": {
               "items": {
                  "$ref": "#/$defs/ToolCall"
               },
               "title": "Tool Calls",
               "type": "array"
            }
         },
         "required": [
            "role"
         ],
         "title": "ChatMessage",
         "type": "object"
      },
      "FunctionCall": {
         "properties": {
            "name": {
               "title": "Name",
               "type": "string"
            },
            "arguments": {
               "title": "Arguments",
               "type": "string"
            }
         },
         "required": [
            "name",
            "arguments"
         ],
         "title": "FunctionCall",
         "type": "object"
      },
      "Logprob": {
         "description": "Infos for supporting OpenAI compatible logprobs and token ranks.\n\nAttributes:\n    logprob: The logprob of chosen token\n    rank: The vocab rank of chosen token (>=1)\n    decoded_token: The decoded chosen token index",
         "properties": {
            "logprob": {
               "title": "Logprob",
               "type": "number"
            },
            "rank": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Rank"
            },
            "decoded_token": {
               "anyOf": [
                  {
                     "type": "string"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Decoded Token"
            }
         },
         "required": [
            "logprob"
         ],
         "title": "Logprob",
         "type": "object"
      },
      "PromptTokenUsageInfo": {
         "properties": {
            "cached_tokens": {
               "anyOf": [
                  {
                     "type": "integer"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "title": "Cached Tokens"
            }
         },
         "title": "PromptTokenUsageInfo",
         "type": "object"
      },
      "ToolCall": {
         "properties": {
            "id": {
               "title": "Id",
               "type": "string"
            },
            "type": {
               "const": "function",
               "default": "function",
               "title": "Type",
               "type": "string"
            },
            "function": {
               "$ref": "#/$defs/FunctionCall"
            }
         },
         "required": [
            "function"
         ],
         "title": "ToolCall",
         "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",
      "usage"
   ]
}

field choices: List[ChatCompletionResponseChoice] [Required]#
field created: int [Optional]#
field id: str [Optional]#
field model: str [Required]#
field object: Literal['chat.completion'] = 'chat.completion'#
field prompt_logprobs: List[Dict[int, Logprob] | None] | None = None#
field usage: UsageInfo [Required]#