Skip to content

Completions

List available chat completion models
chat.completions.models(CompletionModelsParams**kwargs) -> CompletionModelsResponse
GET/v5/chat/completions/models
Generate OpenAI chat completion from messages
chat.completions.create(CompletionCreateParams**kwargs) -> CompletionCreateResponse
POST/v5/chat/completions
ModelsExpand Collapse
class ChatCompletion: …
id: str
choices: List[Choice]
finish_reason: Literal["stop", "length", "tool_calls", 2 more]
One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
index: int
message: ChoiceMessage

A chat completion message generated by the model.

role: Literal["assistant"]
annotations: Optional[List[ChoiceMessageAnnotation]]
type: Literal["url_citation"]
url_citation: ChoiceMessageAnnotationURLCitation

A URL citation when using web search.

end_index: int
start_index: int
title: str
url: str
audio: Optional[ChoiceMessageAudio]

If the audio output modality is requested, this object contains data about the audio response from the model. Learn more.

id: str
data: str
expires_at: int
transcript: str
content: Optional[str]
function_call: Optional[ChoiceMessageFunctionCall]

Deprecated and replaced by tool_calls.

The name and arguments of a function that should be called, as generated by the model.

arguments: str
name: str
refusal: Optional[str]
tool_calls: Optional[List[ChoiceMessageToolCall]]
One of the following:
class ChoiceMessageToolCallChatCompletionMessageFunctionToolCall: …

A call to a function tool created by the model.

id: str
function: ChoiceMessageToolCallChatCompletionMessageFunctionToolCallFunction

The function that the model called.

arguments: str
name: str
type: Literal["function"]
class ChoiceMessageToolCallChatCompletionMessageCustomToolCall: …

A call to a custom tool created by the model.

id: str
custom: ChoiceMessageToolCallChatCompletionMessageCustomToolCallCustom

The custom tool that the model called.

input: str
name: str
type: Literal["custom"]
logprobs: Optional[ChoiceLogprobs]

Log probability information for the choice.

content: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
refusal: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
created: int
model: str
object: Optional[Literal["chat.completion"]]
service_tier: Optional[Literal["auto", "default", "flex", 2 more]]
One of the following:
"auto"
"default"
"flex"
"scale"
"priority"
system_fingerprint: Optional[str]
usage: Optional[CompletionUsage]

Usage statistics for the completion request.

completion_tokens: int
prompt_tokens: int
total_tokens: int
completion_tokens_details: Optional[CompletionTokensDetails]

Breakdown of tokens used in a completion.

accepted_prediction_tokens: Optional[int]
audio_tokens: Optional[int]
reasoning_tokens: Optional[int]
rejected_prediction_tokens: Optional[int]
prompt_tokens_details: Optional[PromptTokensDetails]

Breakdown of tokens used in the prompt.

audio_tokens: Optional[int]
cached_tokens: Optional[int]
class ChatCompletionChunk: …
id: str
choices: List[Choice]
delta: ChoiceDelta

A chat completion delta generated by streamed model responses.

content: Optional[str]
function_call: Optional[ChoiceDeltaFunctionCall]

Deprecated and replaced by tool_calls.

The name and arguments of a function that should be called, as generated by the model.

arguments: Optional[str]
name: Optional[str]
refusal: Optional[str]
role: Optional[Literal["developer", "system", "user", 2 more]]
One of the following:
"developer"
"system"
"user"
"assistant"
"tool"
tool_calls: Optional[List[ChoiceDeltaToolCall]]
index: int
id: Optional[str]
function: Optional[ChoiceDeltaToolCallFunction]
arguments: Optional[str]
name: Optional[str]
type: Optional[Literal["function"]]
index: int
finish_reason: Optional[Literal["stop", "length", "tool_calls", 2 more]]
One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
logprobs: Optional[ChoiceLogprobs]

Log probability information for the choice.

content: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
refusal: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
created: int
model: str
object: Optional[Literal["chat.completion.chunk"]]
service_tier: Optional[Literal["auto", "default", "flex", 2 more]]
One of the following:
"auto"
"default"
"flex"
"scale"
"priority"
system_fingerprint: Optional[str]
usage: Optional[CompletionUsage]

Usage statistics for the completion request.

completion_tokens: int
prompt_tokens: int
total_tokens: int
completion_tokens_details: Optional[CompletionTokensDetails]

Breakdown of tokens used in a completion.

accepted_prediction_tokens: Optional[int]
audio_tokens: Optional[int]
reasoning_tokens: Optional[int]
rejected_prediction_tokens: Optional[int]
prompt_tokens_details: Optional[PromptTokensDetails]

Breakdown of tokens used in the prompt.

audio_tokens: Optional[int]
cached_tokens: Optional[int]
class ChatCompletionTokenLogprob: …
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
class ChoiceLogprobs: …

Log probability information for the choice.

content: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
refusal: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
Literal["openai", "cohere", "vertex_ai", 9 more]
One of the following:
"openai"
"cohere"
"vertex_ai"
"anthropic"
"azure"
"gemini"
"launch"
"llmengine"
"model_zoo"
"bedrock"
"xai"
"fireworks_ai"
class ModelDefinition: …
model_name: str

model name, for example gpt-4o

model_type: InferenceModelType

model type, for example chat_completion

One of the following:
"generic"
"completion"
"chat_completion"
model_vendor: InferenceModelVendor

model vendor, for example openai

One of the following:
"openai"
"cohere"
"vertex_ai"
"anthropic"
"azure"
"gemini"
"launch"
"llmengine"
"model_zoo"
"bedrock"
"xai"
"fireworks_ai"
model_availability: Optional[InferenceModelAvailability]

model availability indicating availability status, for example available

One of the following:
"unknown"
"available"
"unavailable"
Literal["asc", "desc"]
One of the following:
"asc"
"desc"
class CompletionModelsResponse: …
items: List[ModelDefinition]
model_name: str

model name, for example gpt-4o

model_type: InferenceModelType

model type, for example chat_completion

One of the following:
"generic"
"completion"
"chat_completion"
model_vendor: InferenceModelVendor

model vendor, for example openai

One of the following:
"openai"
"cohere"
"vertex_ai"
"anthropic"
"azure"
"gemini"
"launch"
"llmengine"
"model_zoo"
"bedrock"
"xai"
"fireworks_ai"
model_availability: Optional[InferenceModelAvailability]

model availability indicating availability status, for example available

One of the following:
"unknown"
"available"
"unavailable"
object: Optional[Literal["list"]]
One of the following:
class ChatCompletion: …
id: str
choices: List[Choice]
finish_reason: Literal["stop", "length", "tool_calls", 2 more]
One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
index: int
message: ChoiceMessage

A chat completion message generated by the model.

role: Literal["assistant"]
annotations: Optional[List[ChoiceMessageAnnotation]]
type: Literal["url_citation"]
url_citation: ChoiceMessageAnnotationURLCitation

A URL citation when using web search.

end_index: int
start_index: int
title: str
url: str
audio: Optional[ChoiceMessageAudio]

If the audio output modality is requested, this object contains data about the audio response from the model. Learn more.

id: str
data: str
expires_at: int
transcript: str
content: Optional[str]
function_call: Optional[ChoiceMessageFunctionCall]

Deprecated and replaced by tool_calls.

The name and arguments of a function that should be called, as generated by the model.

arguments: str
name: str
refusal: Optional[str]
tool_calls: Optional[List[ChoiceMessageToolCall]]
One of the following:
class ChoiceMessageToolCallChatCompletionMessageFunctionToolCall: …

A call to a function tool created by the model.

id: str
function: ChoiceMessageToolCallChatCompletionMessageFunctionToolCallFunction

The function that the model called.

arguments: str
name: str
type: Literal["function"]
class ChoiceMessageToolCallChatCompletionMessageCustomToolCall: …

A call to a custom tool created by the model.

id: str
custom: ChoiceMessageToolCallChatCompletionMessageCustomToolCallCustom

The custom tool that the model called.

input: str
name: str
type: Literal["custom"]
logprobs: Optional[ChoiceLogprobs]

Log probability information for the choice.

content: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
refusal: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
created: int
model: str
object: Optional[Literal["chat.completion"]]
service_tier: Optional[Literal["auto", "default", "flex", 2 more]]
One of the following:
"auto"
"default"
"flex"
"scale"
"priority"
system_fingerprint: Optional[str]
usage: Optional[CompletionUsage]

Usage statistics for the completion request.

completion_tokens: int
prompt_tokens: int
total_tokens: int
completion_tokens_details: Optional[CompletionTokensDetails]

Breakdown of tokens used in a completion.

accepted_prediction_tokens: Optional[int]
audio_tokens: Optional[int]
reasoning_tokens: Optional[int]
rejected_prediction_tokens: Optional[int]
prompt_tokens_details: Optional[PromptTokensDetails]

Breakdown of tokens used in the prompt.

audio_tokens: Optional[int]
cached_tokens: Optional[int]
class ChatCompletionChunk: …
id: str
choices: List[Choice]
delta: ChoiceDelta

A chat completion delta generated by streamed model responses.

content: Optional[str]
function_call: Optional[ChoiceDeltaFunctionCall]

Deprecated and replaced by tool_calls.

The name and arguments of a function that should be called, as generated by the model.

arguments: Optional[str]
name: Optional[str]
refusal: Optional[str]
role: Optional[Literal["developer", "system", "user", 2 more]]
One of the following:
"developer"
"system"
"user"
"assistant"
"tool"
tool_calls: Optional[List[ChoiceDeltaToolCall]]
index: int
id: Optional[str]
function: Optional[ChoiceDeltaToolCallFunction]
arguments: Optional[str]
name: Optional[str]
type: Optional[Literal["function"]]
index: int
finish_reason: Optional[Literal["stop", "length", "tool_calls", 2 more]]
One of the following:
"stop"
"length"
"tool_calls"
"content_filter"
"function_call"
logprobs: Optional[ChoiceLogprobs]

Log probability information for the choice.

content: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
refusal: Optional[List[ChatCompletionTokenLogprob]]
token: str
logprob: float
top_logprobs: List[TopLogprob]
token: str
logprob: float
bytes: Optional[List[int]]
bytes: Optional[List[int]]
created: int
model: str
object: Optional[Literal["chat.completion.chunk"]]
service_tier: Optional[Literal["auto", "default", "flex", 2 more]]
One of the following:
"auto"
"default"
"flex"
"scale"
"priority"
system_fingerprint: Optional[str]
usage: Optional[CompletionUsage]

Usage statistics for the completion request.

completion_tokens: int
prompt_tokens: int
total_tokens: int
completion_tokens_details: Optional[CompletionTokensDetails]

Breakdown of tokens used in a completion.

accepted_prediction_tokens: Optional[int]
audio_tokens: Optional[int]
reasoning_tokens: Optional[int]
rejected_prediction_tokens: Optional[int]
prompt_tokens_details: Optional[PromptTokensDetails]

Breakdown of tokens used in the prompt.

audio_tokens: Optional[int]
cached_tokens: Optional[int]