Documentation
¶
Index ¶
- Constants
- func F[T any](value T) param.Field[T]
- func String(value string) param.Field[string]
- type BetaCompletionService
- type BetaService
- type ChatCompletion
- type ChatCompletionAccumulator
- type ChatCompletionAssistantMessageParam
- type ChatCompletionAssistantMessageParamRole
- type ChatCompletionChoice
- type ChatCompletionChoicesFinishReason
- type ChatCompletionChoicesLogprobs
- type ChatCompletionChunk
- type ChatCompletionChunkChoice
- type ChatCompletionChunkChoicesDelta
- type ChatCompletionChunkChoicesDeltaRole
- type ChatCompletionChunkChoicesDeltaToolCall
- type ChatCompletionChunkChoicesDeltaToolCallsFunction
- type ChatCompletionChunkChoicesDeltaToolCallsType
- type ChatCompletionChunkChoicesFinishReason
- type ChatCompletionChunkChoicesLogprobs
- type ChatCompletionChunkObject
- type ChatCompletionMessage
- type ChatCompletionMessageParamUnion
- type ChatCompletionMessageRole
- type ChatCompletionMessageService
- type ChatCompletionMessageToolCall
- type ChatCompletionMessageToolCallFunction
- type ChatCompletionMessageToolCallFunctionParam
- type ChatCompletionMessageToolCallParam
- type ChatCompletionMessageToolCallType
- type ChatCompletionNewParams
- type ChatCompletionNewParamsResponseFormatUnion
- type ChatCompletionNewParamsStopArray
- type ChatCompletionNewParamsStopUnion
- type ChatCompletionObject
- type ChatCompletionService
- type ChatCompletionTokenLogprob
- type ChatCompletionTokenLogprobTopLogprob
- type ChatCompletionToolMessageParam
- type ChatCompletionToolMessageParamRole
- type ChatCompletionToolParam
- type ChatCompletionToolType
- type ChatCompletionUserMessageParam
- type ChatCompletionUserMessageParamRole
- type ChatModel
- type ChatService
- type Client
- type CompletionUsage
- type CompletionUsageCompletionTokensDetails
- type FinishedChatCompletionToolCall
- type FunctionDefinitionParam
- type FunctionParameters
- type ResponseFormatJSONObjectParam
- type ResponseFormatJSONObjectType
- type ResponseFormatJSONSchemaJSONSchemaParam
- type ResponseFormatJSONSchemaParam
- type ResponseFormatJSONSchemaType
- type ResponseFormatTextParam
- type ResponseFormatTextType
Constants ¶
const ResponseFormatJSONObjectTypeJSONObject = shared.ResponseFormatJSONObjectTypeJSONObject
This is an alias to an internal value.
const ResponseFormatJSONSchemaTypeJSONSchema = shared.ResponseFormatJSONSchemaTypeJSONSchema
This is an alias to an internal value.
const ResponseFormatTextTypeText = shared.ResponseFormatTextTypeText
This is an alias to an internal value.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BetaCompletionService ¶
type BetaCompletionService struct {
Options []option.RequestOption
}
type BetaService ¶
type BetaService struct {
Options []option.RequestOption
Completions *BetaCompletionService
}
func NewBetaService ¶
func NewBetaService(opts ...option.RequestOption) (r *BetaService)
type ChatCompletion ¶
type ChatCompletion struct {
ID string `json:"id,required"`
Choices []ChatCompletionChoice `json:"choices,required"`
Created int64 `json:"created,required"`
Model string `json:"model,required"`
SystemFingerprint string `json:"system_fingerprint"`
Object ChatCompletionObject `json:"object,required"`
Usage CompletionUsage `json:"usage"`
JSON chatCompletionJSON `json:"-"`
}
type ChatCompletionAccumulator ¶
type ChatCompletionAccumulator struct {
// The up-to-date accumulation of model's responses
ChatCompletion
// contains filtered or unexported fields
}
func (*ChatCompletionAccumulator) AddChunk ¶
func (acc *ChatCompletionAccumulator) AddChunk(chunk ChatCompletionChunk) bool
func (*ChatCompletionAccumulator) JustFinishedContent ¶
func (acc *ChatCompletionAccumulator) JustFinishedContent() (content string, ok bool)
func (*ChatCompletionAccumulator) JustFinishedToolCall ¶
func (acc *ChatCompletionAccumulator) JustFinishedToolCall() (toolcall FinishedChatCompletionToolCall, ok bool)
type ChatCompletionAssistantMessageParam ¶
type ChatCompletionAssistantMessageParam struct {
Role param.Field[ChatCompletionAssistantMessageParamRole] `json:"role,required"`
Content param.Field[string] `json:"content"`
ReasoningContent param.Field[string] `json:"reasoning_content"`
Name param.Field[string] `json:"name"`
Prefix param.Field[bool] `json:"prefix"`
// The tool calls generated by the model, such as function calls.
ToolCalls param.Field[[]ChatCompletionMessageToolCallParam] `json:"tool_calls"`
}
func AssistantMessage ¶
func AssistantMessage(content string, prefix bool) ChatCompletionAssistantMessageParam
func (ChatCompletionAssistantMessageParam) MarshalJSON ¶
func (r ChatCompletionAssistantMessageParam) MarshalJSON() (data []byte, err error)
type ChatCompletionAssistantMessageParamRole ¶
type ChatCompletionAssistantMessageParamRole string
The role of the messages author, in this case `assistant`.
const (
ChatCompletionAssistantMessageParamRoleAssistant ChatCompletionAssistantMessageParamRole = "assistant"
)
type ChatCompletionChoice ¶
type ChatCompletionChoice struct {
FinishReason ChatCompletionChoicesFinishReason `json:"finish_reason,required"`
// The index of the choice in the list of choices.
Index int64 `json:"index,required"`
// Log probability information for the choice.
Logprobs ChatCompletionChoicesLogprobs `json:"logprobs,required,nullable"`
// A chat completion message generated by the model.
Message ChatCompletionMessage `json:"message,required"`
JSON chatCompletionChoiceJSON `json:"-"`
}
type ChatCompletionChoicesFinishReason ¶
type ChatCompletionChoicesFinishReason string
const ( ChatCompletionChoicesFinishReasonStop ChatCompletionChoicesFinishReason = "stop" ChatCompletionChoicesFinishReasonLength ChatCompletionChoicesFinishReason = "length" ChatCompletionChoicesFinishReasonToolCalls ChatCompletionChoicesFinishReason = "tool_calls" ChatCompletionChoicesFinishReasonContentFilter ChatCompletionChoicesFinishReason = "content_filter" ChatCompletionChoicesFinishReasonFunctionCall ChatCompletionChoicesFinishReason = "function_call" ChatCompletionChoicesFinishReasonInsufficientSystemResource ChatCompletionChoicesFinishReason = "insufficient_system_resource" )
type ChatCompletionChoicesLogprobs ¶
type ChatCompletionChoicesLogprobs struct {
// A list of message content tokens with log probability information.
Content []ChatCompletionTokenLogprob `json:"content,required,nullable"`
JSON chatCompletionChoicesLogprobsJSON `json:"-"`
}
Log probability information for the choice.
type ChatCompletionChunk ¶
type ChatCompletionChunk struct {
// A unique identifier for the chat completion. Each chunk has the same ID.
ID string `json:"id,required"`
// A list of chat completion choices. Can contain more than one elements if `n` is
// greater than 1. Can also be empty for the last chunk if you set
// `stream_options: {"include_usage": true}`.
Choices []ChatCompletionChunkChoice `json:"choices,required"`
// The Unix timestamp (in seconds) of when the chat completion was created. Each
// chunk has the same timestamp.
Created int64 `json:"created,required"`
// The model to generate the completion.
Model string `json:"model,required"`
// The object type, which is always `chat.completion.chunk`.
Object ChatCompletionChunkObject `json:"object,required"`
// This fingerprint represents the backend configuration that the model runs with.
// Can be used in conjunction with the `seed` request parameter to understand when
// backend changes have been made that might impact determinism.
SystemFingerprint string `json:"system_fingerprint"`
// An optional field that will only be present when you set
// `stream_options: {"include_usage": true}` in your request. When present, it
// contains a null value except for the last chunk which contains the token usage
// statistics for the entire request.
Usage CompletionUsage `json:"usage,nullable"`
JSON chatCompletionChunkJSON `json:"-"`
}
func (*ChatCompletionChunk) UnmarshalJSON ¶
func (r *ChatCompletionChunk) UnmarshalJSON(data []byte) (err error)
type ChatCompletionChunkChoice ¶
type ChatCompletionChunkChoice struct {
// A chat completion delta generated by streamed model responses.
Delta ChatCompletionChunkChoicesDelta `json:"delta,required"`
// The reason the model stopped generating tokens. This will be `stop` if the model
// hit a natural stop point or a provided stop sequence, `length` if the maximum
// number of tokens specified in the request was reached, `content_filter` if
// content was omitted due to a flag from our content filters, `tool_calls` if the
// model called a tool, or `function_call` (deprecated) if the model called a
// function.
FinishReason ChatCompletionChunkChoicesFinishReason `json:"finish_reason,required,nullable"`
// The index of the choice in the list of choices.
Index int64 `json:"index,required"`
// Log probability information for the choice.
Logprobs ChatCompletionChunkChoicesLogprobs `json:"logprobs,nullable"`
JSON chatCompletionChunkChoiceJSON `json:"-"`
}
func (*ChatCompletionChunkChoice) UnmarshalJSON ¶
func (r *ChatCompletionChunkChoice) UnmarshalJSON(data []byte) (err error)
type ChatCompletionChunkChoicesDelta ¶
type ChatCompletionChunkChoicesDelta struct {
// The contents of the chunk message.
Content string `json:"content,nullable"`
ReasoningContent string `json:"reasoning_content"`
// The role of the author of this message.
Role ChatCompletionChunkChoicesDeltaRole `json:"role"`
ToolCalls []ChatCompletionChunkChoicesDeltaToolCall `json:"tool_calls"`
JSON chatCompletionChunkChoicesDeltaJSON `json:"-"`
}
func (*ChatCompletionChunkChoicesDelta) UnmarshalJSON ¶
func (r *ChatCompletionChunkChoicesDelta) UnmarshalJSON(data []byte) (err error)
type ChatCompletionChunkChoicesDeltaRole ¶
type ChatCompletionChunkChoicesDeltaRole string
const ( ChatCompletionChunkChoicesDeltaRoleDeveloper ChatCompletionChunkChoicesDeltaRole = "developer" ChatCompletionChunkChoicesDeltaRoleSystem ChatCompletionChunkChoicesDeltaRole = "system" ChatCompletionChunkChoicesDeltaRoleUser ChatCompletionChunkChoicesDeltaRole = "user" ChatCompletionChunkChoicesDeltaRoleAssistant ChatCompletionChunkChoicesDeltaRole = "assistant" ChatCompletionChunkChoicesDeltaRoleTool ChatCompletionChunkChoicesDeltaRole = "tool" )
type ChatCompletionChunkChoicesDeltaToolCall ¶
type ChatCompletionChunkChoicesDeltaToolCall struct {
Index int64 `json:"index,required"`
// The ID of the tool call.
ID string `json:"id"`
Function ChatCompletionChunkChoicesDeltaToolCallsFunction `json:"function"`
// The type of the tool. Currently, only `function` is supported.
Type ChatCompletionChunkChoicesDeltaToolCallsType `json:"type"`
JSON chatCompletionChunkChoicesDeltaToolCallJSON `json:"-"`
}
func (*ChatCompletionChunkChoicesDeltaToolCall) UnmarshalJSON ¶
func (r *ChatCompletionChunkChoicesDeltaToolCall) UnmarshalJSON(data []byte) (err error)
type ChatCompletionChunkChoicesDeltaToolCallsFunction ¶
type ChatCompletionChunkChoicesDeltaToolCallsFunction struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
// hallucinate parameters not defined by your function schema. Validate the
// arguments in your code before calling your function.
Arguments string `json:"arguments"`
// The name of the function to call.
Name string `json:"name"`
JSON chatCompletionChunkChoicesDeltaToolCallsFunctionJSON `json:"-"`
}
func (*ChatCompletionChunkChoicesDeltaToolCallsFunction) UnmarshalJSON ¶
func (r *ChatCompletionChunkChoicesDeltaToolCallsFunction) UnmarshalJSON(data []byte) (err error)
type ChatCompletionChunkChoicesDeltaToolCallsType ¶
type ChatCompletionChunkChoicesDeltaToolCallsType string
const (
ChatCompletionChunkChoicesDeltaToolCallsTypeFunction ChatCompletionChunkChoicesDeltaToolCallsType = "function"
)
type ChatCompletionChunkChoicesFinishReason ¶
type ChatCompletionChunkChoicesFinishReason string
const ( ChatCompletionChunkChoicesFinishReasonStop ChatCompletionChunkChoicesFinishReason = "stop" ChatCompletionChunkChoicesFinishReasonLength ChatCompletionChunkChoicesFinishReason = "length" ChatCompletionChunkChoicesFinishReasonToolCalls ChatCompletionChunkChoicesFinishReason = "tool_calls" ChatCompletionChunkChoicesFinishReasonContentFilter ChatCompletionChunkChoicesFinishReason = "content_filter" ChatCompletionChunkChoicesFinishReasonFunctionCall ChatCompletionChunkChoicesFinishReason = "function_call" ChatCompletionChunkChoicesFinishReasonInsufficientSystemResource ChatCompletionChunkChoicesFinishReason = "insufficient_system_resource" )
type ChatCompletionChunkChoicesLogprobs ¶
type ChatCompletionChunkChoicesLogprobs struct {
// A list of message content tokens with log probability information.
Content []ChatCompletionTokenLogprob `json:"content,required,nullable"`
JSON chatCompletionChoicesLogprobsJSON `json:"-"`
}
func (*ChatCompletionChunkChoicesLogprobs) UnmarshalJSON ¶
func (r *ChatCompletionChunkChoicesLogprobs) UnmarshalJSON(data []byte) (err error)
type ChatCompletionChunkObject ¶
type ChatCompletionChunkObject string
The object type, which is always `chat.completion.chunk`.
const (
ChatCompletionChunkObjectChatCompletionChunk ChatCompletionChunkObject = "chat.completion.chunk"
)
type ChatCompletionMessage ¶
type ChatCompletionMessage struct {
// The contents of the message.
Content string `json:"content,required,nullable"`
ReasoningContent string `json:"reasoning_content"`
// The role of the author of this message.
Role ChatCompletionMessageRole `json:"role,required"`
// The tool calls generated by the model, such as function calls.
ToolCalls []ChatCompletionMessageToolCall `json:"tool_calls"`
JSON chatCompletionMessageJSON `json:"-"`
}
A chat completion message generated by the model.
func (ChatCompletionMessage) MarshalJSON ¶
func (r ChatCompletionMessage) MarshalJSON() (data []byte, err error)
func (*ChatCompletionMessage) UnmarshalJSON ¶
func (r *ChatCompletionMessage) UnmarshalJSON(data []byte) (err error)
type ChatCompletionMessageParamUnion ¶
type ChatCompletionMessageParamUnion interface {
// contains filtered or unexported methods
}
type ChatCompletionMessageRole ¶
type ChatCompletionMessageRole string
const (
ChatCompletionMessageRoleAssistant ChatCompletionMessageRole = "assistant"
)
type ChatCompletionMessageService ¶
type ChatCompletionMessageService struct {
Options []option.RequestOption
}
func NewChatCompletionMessageService ¶
func NewChatCompletionMessageService(opts ...option.RequestOption) (r *ChatCompletionMessageService)
type ChatCompletionMessageToolCall ¶
type ChatCompletionMessageToolCall struct {
// The ID of the tool call.
ID string `json:"id,required"`
// The function that the model called.
Function ChatCompletionMessageToolCallFunction `json:"function,required"`
// The type of the tool. Currently, only `function` is supported.
Type ChatCompletionMessageToolCallType `json:"type,required"`
JSON chatCompletionMessageToolCallJSON `json:"-"`
}
func (*ChatCompletionMessageToolCall) UnmarshalJSON ¶
func (r *ChatCompletionMessageToolCall) UnmarshalJSON(data []byte) (err error)
type ChatCompletionMessageToolCallFunction ¶
type ChatCompletionMessageToolCallFunction struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
// hallucinate parameters not defined by your function schema. Validate the
// arguments in your code before calling your function.
Arguments string `json:"arguments,required"`
// The name of the function to call.
Name string `json:"name,required"`
JSON chatCompletionMessageToolCallFunctionJSON `json:"-"`
}
The function that the model called.
type ChatCompletionMessageToolCallFunctionParam ¶
type ChatCompletionMessageToolCallFunctionParam struct {
// The arguments to call the function with, as generated by the model in JSON
// format. Note that the model does not always generate valid JSON, and may
// hallucinate parameters not defined by your function schema. Validate the
// arguments in your code before calling your function.
Arguments param.Field[string] `json:"arguments,required"`
// The name of the function to call.
Name param.Field[string] `json:"name,required"`
}
The function that the model called.
func (ChatCompletionMessageToolCallFunctionParam) MarshalJSON ¶
func (r ChatCompletionMessageToolCallFunctionParam) MarshalJSON() (data []byte, err error)
type ChatCompletionMessageToolCallParam ¶
type ChatCompletionMessageToolCallParam struct {
// The ID of the tool call.
ID param.Field[string] `json:"id,required"`
// The function that the model called.
Function param.Field[ChatCompletionMessageToolCallFunctionParam] `json:"function,required"`
// The type of the tool. Currently, only `function` is supported.
Type param.Field[ChatCompletionMessageToolCallType] `json:"type,required"`
}
func (ChatCompletionMessageToolCallParam) MarshalJSON ¶
func (r ChatCompletionMessageToolCallParam) MarshalJSON() (data []byte, err error)
type ChatCompletionMessageToolCallType ¶
type ChatCompletionMessageToolCallType string
const (
ChatCompletionMessageToolCallTypeFunction ChatCompletionMessageToolCallType = "function"
)
type ChatCompletionNewParams ¶
type ChatCompletionNewParams struct {
Messages param.Field[[]ChatCompletionMessageParamUnion] `json:"messages,required"`
Model param.Field[ChatModel] `json:"model,required"`
Tools param.Field[[]ChatCompletionToolParam] `json:"tools"`
ResponseFormat param.Field[ChatCompletionNewParamsResponseFormatUnion] `json:"response_format"`
Stop param.Field[ChatCompletionNewParamsStopUnion] `json:"stop"`
}
func (ChatCompletionNewParams) MarshalJSON ¶
func (r ChatCompletionNewParams) MarshalJSON() (data []byte, err error)
type ChatCompletionNewParamsResponseFormatUnion ¶
type ChatCompletionNewParamsResponseFormatUnion interface {
ImplementsChatCompletionNewParamsResponseFormatUnion()
}
type ChatCompletionNewParamsStopArray ¶
type ChatCompletionNewParamsStopArray []string
func (ChatCompletionNewParamsStopArray) ImplementsChatCompletionNewParamsStopUnion ¶
func (r ChatCompletionNewParamsStopArray) ImplementsChatCompletionNewParamsStopUnion()
type ChatCompletionNewParamsStopUnion ¶
type ChatCompletionNewParamsStopUnion interface {
ImplementsChatCompletionNewParamsStopUnion()
}
type ChatCompletionObject ¶
type ChatCompletionObject string
const (
ChatCompletionObjectChatCompletion ChatCompletionObject = "chat.completion"
)
type ChatCompletionService ¶
type ChatCompletionService struct {
Options []option.RequestOption
Messages *ChatCompletionMessageService
}
func NewChatCompletionService ¶
func NewChatCompletionService(opts ...option.RequestOption) (r *ChatCompletionService)
func (*ChatCompletionService) New ¶
func (r *ChatCompletionService) New(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (res *ChatCompletion, err error)
func (*ChatCompletionService) NewStreaming ¶
func (r *ChatCompletionService) NewStreaming(ctx context.Context, body ChatCompletionNewParams, opts ...option.RequestOption) (stream *ssestream.Stream[ChatCompletionChunk])
type ChatCompletionTokenLogprob ¶
type ChatCompletionTokenLogprob struct {
// The token.
Token string `json:"token,required"`
// A list of integers representing the UTF-8 bytes representation of the token.
// Useful in instances where characters are represented by multiple tokens and
// their byte representations must be combined to generate the correct text
// representation. Can be `null` if there is no bytes representation for the token.
Bytes []int64 `json:"bytes,required,nullable"`
// The log probability of this token, if it is within the top 20 most likely
// tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
// unlikely.
Logprob float64 `json:"logprob,required"`
// List of the most likely tokens and their log probability, at this token
// position. In rare cases, there may be fewer than the number of requested
// `top_logprobs` returned.
TopLogprobs []ChatCompletionTokenLogprobTopLogprob `json:"top_logprobs,required"`
JSON chatCompletionTokenLogprobJSON `json:"-"`
}
func (*ChatCompletionTokenLogprob) UnmarshalJSON ¶
func (r *ChatCompletionTokenLogprob) UnmarshalJSON(data []byte) (err error)
type ChatCompletionTokenLogprobTopLogprob ¶
type ChatCompletionTokenLogprobTopLogprob struct {
// The token.
Token string `json:"token,required"`
// A list of integers representing the UTF-8 bytes representation of the token.
// Useful in instances where characters are represented by multiple tokens and
// their byte representations must be combined to generate the correct text
// representation. Can be `null` if there is no bytes representation for the token.
Bytes []int64 `json:"bytes,required,nullable"`
// The log probability of this token, if it is within the top 20 most likely
// tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
// unlikely.
Logprob float64 `json:"logprob,required"`
JSON chatCompletionTokenLogprobTopLogprobJSON `json:"-"`
}
func (*ChatCompletionTokenLogprobTopLogprob) UnmarshalJSON ¶
func (r *ChatCompletionTokenLogprobTopLogprob) UnmarshalJSON(data []byte) (err error)
type ChatCompletionToolMessageParam ¶
type ChatCompletionToolMessageParam struct {
// The contents of the tool message.
Content param.Field[string] `json:"content,required"`
// The role of the messages author, in this case `tool`.
Role param.Field[ChatCompletionToolMessageParamRole] `json:"role,required"`
// Tool call that this message is responding to.
ToolCallID param.Field[string] `json:"tool_call_id,required"`
}
func ToolMessage ¶
func ToolMessage(toolCallID, content string) ChatCompletionToolMessageParam
func (ChatCompletionToolMessageParam) MarshalJSON ¶
func (r ChatCompletionToolMessageParam) MarshalJSON() (data []byte, err error)
type ChatCompletionToolMessageParamRole ¶
type ChatCompletionToolMessageParamRole string
const (
ChatCompletionToolMessageParamRoleTool ChatCompletionToolMessageParamRole = "tool"
)
type ChatCompletionToolParam ¶
type ChatCompletionToolParam struct {
Function param.Field[shared.FunctionDefinitionParam] `json:"function,required"`
// The type of the tool. Currently, only `function` is supported.
Type param.Field[ChatCompletionToolType] `json:"type,required"`
}
func (ChatCompletionToolParam) MarshalJSON ¶
func (r ChatCompletionToolParam) MarshalJSON() (data []byte, err error)
type ChatCompletionToolType ¶
type ChatCompletionToolType string
const (
ChatCompletionToolTypeFunction ChatCompletionToolType = "function"
)
type ChatCompletionUserMessageParam ¶
type ChatCompletionUserMessageParam struct {
// The contents of the user message.
Content param.Field[string] `json:"content,required"`
// The role of the messages author, in this case `user`.
Role param.Field[ChatCompletionUserMessageParamRole] `json:"role,required"`
// An optional name for the participant. Provides the model information to
// differentiate between participants of the same role.
Name param.Field[string] `json:"name"`
}
func UserMessage ¶
func UserMessage(content string) ChatCompletionUserMessageParam
type ChatCompletionUserMessageParamRole ¶
type ChatCompletionUserMessageParamRole string
The role of the messages author, in this case `user`.
const (
ChatCompletionUserMessageParamRoleUser ChatCompletionUserMessageParamRole = "user"
)
type ChatService ¶
type ChatService struct {
Options []option.RequestOption
Completions *ChatCompletionService
}
func NewChatService ¶
func NewChatService(opts ...option.RequestOption) (r *ChatService)
type Client ¶
type Client struct {
Options []option.RequestOption
Chat *ChatService
Beta *BetaService
}
func NewClient ¶
func NewClient(opts ...option.RequestOption) (r *Client)
type CompletionUsage ¶
type CompletionUsage struct {
// Number of tokens in the generated completion.
CompletionTokens int64 `json:"completion_tokens,required"`
// Number of tokens in the prompt.
PromptTokens int64 `json:"prompt_tokens,required"`
PromptCacheHitTokens int64 `json:"prompt_cache_hit_tokens"`
// Total number of tokens used in the request (prompt + completion).
TotalTokens int64 `json:"total_tokens,required"`
// Breakdown of tokens used in a completion.
CompletionTokensDetails CompletionUsageCompletionTokensDetails `json:"completion_tokens_details"`
JSON completionUsageJSON `json:"-"`
// contains filtered or unexported fields
}
type CompletionUsageCompletionTokensDetails ¶
type CompletionUsageCompletionTokensDetails struct {
ReasoningTokens int64 `json:"reasoning_tokens"`
JSON completionUsageCompletionTokensDetailsJSON `json:"-"`
}
type FinishedChatCompletionToolCall ¶
type FinishedChatCompletionToolCall struct {
ChatCompletionMessageToolCallFunction
Index int
}
type FunctionDefinitionParam ¶
type FunctionDefinitionParam = shared.FunctionDefinitionParam
type FunctionParameters ¶
type FunctionParameters = shared.FunctionParameters
type ResponseFormatJSONObjectParam ¶
type ResponseFormatJSONObjectParam = shared.ResponseFormatJSONObjectParam
This is an alias to an internal type.
type ResponseFormatJSONObjectType ¶
type ResponseFormatJSONObjectType = shared.ResponseFormatJSONObjectType
The type of response format being defined: `json_object`
This is an alias to an internal type.
type ResponseFormatJSONSchemaJSONSchemaParam ¶
type ResponseFormatJSONSchemaJSONSchemaParam = shared.ResponseFormatJSONSchemaJSONSchemaParam
This is an alias to an internal type.
type ResponseFormatJSONSchemaParam ¶
type ResponseFormatJSONSchemaParam = shared.ResponseFormatJSONSchemaParam
This is an alias to an internal type.
type ResponseFormatJSONSchemaType ¶
type ResponseFormatJSONSchemaType = shared.ResponseFormatJSONSchemaType
The type of response format being defined: `json_schema`
This is an alias to an internal type.
type ResponseFormatTextParam ¶
type ResponseFormatTextParam = shared.ResponseFormatTextParam
This is an alias to an internal type.
type ResponseFormatTextType ¶
type ResponseFormatTextType = shared.ResponseFormatTextType
The type of response format being defined: `text`
This is an alias to an internal type.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
chat-completion
command
|
|
|
chat-completion-accumulating
command
|
|
|
chat-completion-streaming
command
|
|
|
chat-completion-tool-calling
command
|
|
|
chat-multi-round
command
|
|
|
chat-prefix-completion
command
|
|
|
reasoner
command
|
|
|
reasoner-streaming
command
|
|
|
structured-outputs
command
|
|
|
packages
|
|