Skip to content

Chat

ChatCompletions

List available chat completion models
client.Chat.Completions.Models(ctx, query) (*ChatCompletionModelsResponse, error)
GET/v5/chat/completions/models
Generate OpenAI chat completion from messages
client.Chat.Completions.New(ctx, params) (*ChatCompletionNewResponseUnion, error)
POST/v5/chat/completions
ModelsExpand Collapse
type ChatCompletion struct{…}
ID string
Choices []ChatCompletionChoice
FinishReason string
One of the following:
const ChatCompletionChoiceFinishReasonStop ChatCompletionChoiceFinishReason = "stop"
const ChatCompletionChoiceFinishReasonLength ChatCompletionChoiceFinishReason = "length"
const ChatCompletionChoiceFinishReasonToolCalls ChatCompletionChoiceFinishReason = "tool_calls"
const ChatCompletionChoiceFinishReasonContentFilter ChatCompletionChoiceFinishReason = "content_filter"
const ChatCompletionChoiceFinishReasonFunctionCall ChatCompletionChoiceFinishReason = "function_call"
Index int64
Message ChatCompletionChoiceMessage

A chat completion message generated by the model.

Role Assistant
Annotations []ChatCompletionChoiceMessageAnnotationOptional
Type URLCitation
URLCitation ChatCompletionChoiceMessageAnnotationURLCitation

A URL citation when using web search.

EndIndex int64
StartIndex int64
Title string
URL string
Audio ChatCompletionChoiceMessageAudioOptional

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

ID string
Data string
ExpiresAt int64
Transcript string
Content stringOptional
FunctionCall ChatCompletionChoiceMessageFunctionCallOptional

Deprecated and replaced by tool_calls.

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

Arguments string
Name string
Refusal stringOptional
ToolCalls []ChatCompletionChoiceMessageToolCallUnionOptional
One of the following:
type ChatCompletionChoiceMessageToolCallChatCompletionMessageFunctionToolCall struct{…}

A call to a function tool created by the model.

ID string
Function ChatCompletionChoiceMessageToolCallChatCompletionMessageFunctionToolCallFunction

The function that the model called.

Arguments string
Name string
Type Function
type ChatCompletionChoiceMessageToolCallChatCompletionMessageCustomToolCall struct{…}

A call to a custom tool created by the model.

ID string
Custom ChatCompletionChoiceMessageToolCallChatCompletionMessageCustomToolCallCustom

The custom tool that the model called.

Input string
Name string
Type Custom
Logprobs ChoiceLogprobsOptional

Log probability information for the choice.

Content []ChatCompletionTokenLogprobOptional
Token string
Logprob float64
TopLogprobs []ChatCompletionTokenLogprobTopLogprob
Token string
Logprob float64
Bytes []int64Optional
Bytes []int64Optional
Refusal []ChatCompletionTokenLogprobOptional
Token string
Logprob float64
TopLogprobs []ChatCompletionTokenLogprobTopLogprob
Token string
Logprob float64
Bytes []int64Optional
Bytes []int64Optional
Created int64
Model string
Object ChatCompletionObjectOptional
ServiceTier ChatCompletionServiceTierOptional
One of the following:
const ChatCompletionServiceTierAuto ChatCompletionServiceTier = "auto"
const ChatCompletionServiceTierDefault ChatCompletionServiceTier = "default"
const ChatCompletionServiceTierFlex ChatCompletionServiceTier = "flex"
const ChatCompletionServiceTierScale ChatCompletionServiceTier = "scale"
const ChatCompletionServiceTierPriority ChatCompletionServiceTier = "priority"
SystemFingerprint stringOptional
Usage CompletionUsageOptional

Usage statistics for the completion request.

CompletionTokens int64
PromptTokens int64
TotalTokens int64
CompletionTokensDetails CompletionUsageCompletionTokensDetailsOptional

Breakdown of tokens used in a completion.

AcceptedPredictionTokens int64Optional
AudioTokens int64Optional
ReasoningTokens int64Optional
RejectedPredictionTokens int64Optional
PromptTokensDetails CompletionUsagePromptTokensDetailsOptional

Breakdown of tokens used in the prompt.

AudioTokens int64Optional
CachedTokens int64Optional
type ChatCompletionChunk struct{…}
ID string
Choices []ChatCompletionChunkChoice
Delta ChatCompletionChunkChoiceDelta

A chat completion delta generated by streamed model responses.

Content stringOptional
FunctionCall ChatCompletionChunkChoiceDeltaFunctionCallOptional

Deprecated and replaced by tool_calls.

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

Arguments stringOptional
Name stringOptional
Refusal stringOptional
Role stringOptional
One of the following:
const ChatCompletionChunkChoiceDeltaRoleDeveloper ChatCompletionChunkChoiceDeltaRole = "developer"
const ChatCompletionChunkChoiceDeltaRoleSystem ChatCompletionChunkChoiceDeltaRole = "system"
const ChatCompletionChunkChoiceDeltaRoleUser ChatCompletionChunkChoiceDeltaRole = "user"
const ChatCompletionChunkChoiceDeltaRoleAssistant ChatCompletionChunkChoiceDeltaRole = "assistant"
const ChatCompletionChunkChoiceDeltaRoleTool ChatCompletionChunkChoiceDeltaRole = "tool"
ToolCalls []ChatCompletionChunkChoiceDeltaToolCallOptional
Index int64
ID stringOptional
Function ChatCompletionChunkChoiceDeltaToolCallFunctionOptional
Arguments stringOptional
Name stringOptional
Type stringOptional
Index int64
FinishReason stringOptional
One of the following:
const ChatCompletionChunkChoiceFinishReasonStop ChatCompletionChunkChoiceFinishReason = "stop"
const ChatCompletionChunkChoiceFinishReasonLength ChatCompletionChunkChoiceFinishReason = "length"
const ChatCompletionChunkChoiceFinishReasonToolCalls ChatCompletionChunkChoiceFinishReason = "tool_calls"
const ChatCompletionChunkChoiceFinishReasonContentFilter ChatCompletionChunkChoiceFinishReason = "content_filter"
const ChatCompletionChunkChoiceFinishReasonFunctionCall ChatCompletionChunkChoiceFinishReason = "function_call"
Logprobs ChoiceLogprobsOptional

Log probability information for the choice.

Content []ChatCompletionTokenLogprobOptional
Token string
Logprob float64
TopLogprobs []ChatCompletionTokenLogprobTopLogprob
Token string
Logprob float64
Bytes []int64Optional
Bytes []int64Optional
Refusal []ChatCompletionTokenLogprobOptional
Token string
Logprob float64
TopLogprobs []ChatCompletionTokenLogprobTopLogprob
Token string
Logprob float64
Bytes []int64Optional
Bytes []int64Optional
Created int64
Model string
Object ChatCompletionChunkObjectOptional
ServiceTier ChatCompletionChunkServiceTierOptional
One of the following:
const ChatCompletionChunkServiceTierAuto ChatCompletionChunkServiceTier = "auto"
const ChatCompletionChunkServiceTierDefault ChatCompletionChunkServiceTier = "default"
const ChatCompletionChunkServiceTierFlex ChatCompletionChunkServiceTier = "flex"
const ChatCompletionChunkServiceTierScale ChatCompletionChunkServiceTier = "scale"
const ChatCompletionChunkServiceTierPriority ChatCompletionChunkServiceTier = "priority"
SystemFingerprint stringOptional
Usage CompletionUsageOptional

Usage statistics for the completion request.

CompletionTokens int64
PromptTokens int64
TotalTokens int64
CompletionTokensDetails CompletionUsageCompletionTokensDetailsOptional

Breakdown of tokens used in a completion.

AcceptedPredictionTokens int64Optional
AudioTokens int64Optional
ReasoningTokens int64Optional
RejectedPredictionTokens int64Optional
PromptTokensDetails CompletionUsagePromptTokensDetailsOptional

Breakdown of tokens used in the prompt.

AudioTokens int64Optional
CachedTokens int64Optional
type ChatCompletionTokenLogprob struct{…}
Token string
Logprob float64
TopLogprobs []ChatCompletionTokenLogprobTopLogprob
Token string
Logprob float64
Bytes []int64Optional
Bytes []int64Optional
type ChoiceLogprobs struct{…}

Log probability information for the choice.

Content []ChatCompletionTokenLogprobOptional
Token string
Logprob float64
TopLogprobs []ChatCompletionTokenLogprobTopLogprob
Token string
Logprob float64
Bytes []int64Optional
Bytes []int64Optional
Refusal []ChatCompletionTokenLogprobOptional
Token string
Logprob float64
TopLogprobs []ChatCompletionTokenLogprobTopLogprob
Token string
Logprob float64
Bytes []int64Optional
Bytes []int64Optional
type InferenceModelVendor string
One of the following:
const InferenceModelVendorOpenAI InferenceModelVendor = "openai"
const InferenceModelVendorCohere InferenceModelVendor = "cohere"
const InferenceModelVendorVertexAI InferenceModelVendor = "vertex_ai"
const InferenceModelVendorAnthropic InferenceModelVendor = "anthropic"
const InferenceModelVendorAzure InferenceModelVendor = "azure"
const InferenceModelVendorGemini InferenceModelVendor = "gemini"
const InferenceModelVendorLaunch InferenceModelVendor = "launch"
const InferenceModelVendorLlmengine InferenceModelVendor = "llmengine"
const InferenceModelVendorModelZoo InferenceModelVendor = "model_zoo"
const InferenceModelVendorBedrock InferenceModelVendor = "bedrock"
const InferenceModelVendorXai InferenceModelVendor = "xai"
const InferenceModelVendorFireworksAI InferenceModelVendor = "fireworks_ai"
type ModelDefinition struct{…}
ModelName string

model name, for example gpt-4o

model type, for example chat_completion

One of the following:
const InferenceModelTypeGeneric InferenceModelType = "generic"
const InferenceModelTypeCompletion InferenceModelType = "completion"
const InferenceModelTypeChatCompletion InferenceModelType = "chat_completion"

model vendor, for example openai

One of the following:
const InferenceModelVendorOpenAI InferenceModelVendor = "openai"
const InferenceModelVendorCohere InferenceModelVendor = "cohere"
const InferenceModelVendorVertexAI InferenceModelVendor = "vertex_ai"
const InferenceModelVendorAnthropic InferenceModelVendor = "anthropic"
const InferenceModelVendorAzure InferenceModelVendor = "azure"
const InferenceModelVendorGemini InferenceModelVendor = "gemini"
const InferenceModelVendorLaunch InferenceModelVendor = "launch"
const InferenceModelVendorLlmengine InferenceModelVendor = "llmengine"
const InferenceModelVendorModelZoo InferenceModelVendor = "model_zoo"
const InferenceModelVendorBedrock InferenceModelVendor = "bedrock"
const InferenceModelVendorXai InferenceModelVendor = "xai"
const InferenceModelVendorFireworksAI InferenceModelVendor = "fireworks_ai"
ModelAvailability InferenceModelAvailabilityOptional

model availability indicating availability status, for example available

One of the following:
const InferenceModelAvailabilityUnknown InferenceModelAvailability = "unknown"
const InferenceModelAvailabilityAvailable InferenceModelAvailability = "available"
const InferenceModelAvailabilityUnavailable InferenceModelAvailability = "unavailable"
type SortOrder string
One of the following:
const SortOrderAsc SortOrder = "asc"
const SortOrderDesc SortOrder = "desc"