Documentation
¶
Index ¶
- Constants
- Variables
- type AllowedTool
- type CacheCapabilities
- type CacheControl
- type CacheControlCapabilities
- type CacheControlKind
- type CacheControlTTL
- type Citation
- type CitationConfig
- type CitationKind
- type CompletionDebugger
- type CompletionSpan
- type CompletionSpanEnd
- type CompletionSpanStart
- type ContentItemFile
- type ContentItemImage
- type ContentItemKind
- type ContentItemRefusal
- type ContentItemText
- type Error
- type FetchCompletionOptions
- type FetchCompletionRequest
- type FetchCompletionResponse
- type ImageDetail
- type InputKind
- type InputOutputContent
- type InputOutputContentItemUnion
- type InputUnion
- type JSONSchemaParam
- type MaxOutputTokensParamName
- type Modality
- type ModelCapabilities
- type ModelCapabilityResolver
- type ModelName
- type ModelParam
- type OpenAIChatCompletionsParamDialect
- type OutputCapabilities
- type OutputFormat
- type OutputFormatKind
- type OutputKind
- type OutputParam
- type OutputUnion
- type OutputVerbosity
- type ParamDialect
- type ProviderName
- type ProviderParam
- type ProviderSDKType
- type ReasoningCapabilities
- type ReasoningContent
- type ReasoningLevel
- type ReasoningParam
- type ReasoningSummaryStyle
- type ReasoningTokenBudgetCapabilities
- type ReasoningType
- type ResolveModelCapabilitiesRequest
- type RoleEnum
- type Status
- type StopSequenceCapabilities
- type StreamConfig
- type StreamContentKind
- type StreamEvent
- type StreamHandler
- type StreamTextChunk
- type StreamThinkingChunk
- type ToolCall
- type ToolCapabilities
- type ToolChoice
- type ToolChoiceParamStyle
- type ToolOutput
- type ToolOutputFormatKind
- type ToolOutputItemUnion
- type ToolPolicy
- type ToolPolicyMode
- type ToolType
- type URLCitation
- type Usage
- type Warning
- type WebSearchContextSize
- type WebSearchToolCallFind
- type WebSearchToolCallItemUnion
- type WebSearchToolCallKind
- type WebSearchToolCallOpenPage
- type WebSearchToolCallSearch
- type WebSearchToolCallSearchSource
- type WebSearchToolChoiceItem
- type WebSearchToolChoiceItemUserLocation
- type WebSearchToolOutputError
- type WebSearchToolOutputItemUnion
- type WebSearchToolOutputKind
- type WebSearchToolOutputSearch
Constants ¶
const ( DefaultAuthorizationHeaderKey = "Authorization" DefaultAPITimeout = 300 * time.Second DefaultFileDataMIME = "application/octet-stream" DefaultImageDataMIME = "image/png" DefaultApplicationJSON = "application/json" DefaultContentTypeHeaderKey = "content-type" DefaultAcceptHeaderKey = "accept" DefaultContentTypeHeader = DefaultApplicationJSON DefaultAnthropicOrigin = "https://api.anthropic.com" DefaultAnthropicChatCompletionPrefix = "/v1/messages" DefaultAnthropicAuthorizationHeaderKey = "x-api-key" DefaultOpenAIOrigin = "https://api.openai.com" DefaultOpenAIChatCompletionsPrefix = "/v1/chat/completions" DefaultOpenAIResponsesPrefix = "/v1/responses" DefaultGoogleGenerateContentOrigin = "https://generativelanguage.googleapis.com" DefaultGoogleGenerateContentPrefix = "/" //nolint:gosec // APIKeyHeaderKey is the key string and not the key itself. DefaultGoogleGenerateContentAPIKeyHeaderKey = "x-goog-api-key" )
const DefaultWebSearchToolName string = "webSearchToolChoice"
Variables ¶
var DefaultBaseHeaders = map[string]string{DefaultContentTypeHeaderKey: DefaultContentTypeHeader}
Functions ¶
This section is empty.
Types ¶
type AllowedTool ¶ added in v0.7.0
type AllowedTool struct {
ToolChoiceID string `json:"toolChoiceID"`
ToolChoiceName string `json:"toolChoiceName"`
}
AllowedTool identifies a tool from ToolChoices that the model is allowed/required to call.
Notes: - For ToolPolicyModeTool, AllowedTools is required (must resolve to at least one tool). - For ToolPolicyModeAny, AllowedTools is optional:
- empty => “any of the provided ToolChoices” (recommended default)
- non-empty => restrict to the specified subset.
type CacheCapabilities ¶ added in v0.11.0
type CacheCapabilities struct {
SupportsAutomaticCaching bool `json:"supportsAutomaticCaching"`
TopLevel *CacheControlCapabilities `json:"topLevel,omitempty"`
InputOutputContent *CacheControlCapabilities `json:"inputOutputContent,omitempty"`
ReasoningContent *CacheControlCapabilities `json:"reasoningContent,omitempty"`
ToolChoice *CacheControlCapabilities `json:"toolChoice,omitempty"`
ToolCall *CacheControlCapabilities `json:"toolCall,omitempty"`
ToolOutput *CacheControlCapabilities `json:"toolOutput,omitempty"`
}
type CacheControl ¶
type CacheControl struct {
Kind CacheControlKind `json:"kind"`
// Optional. If empty and CacheControl is explicitly set, provider default may apply.
TTL CacheControlTTL `json:"ttl,omitempty"`
// Optional request-level cache key. Relevant for OpenAI-style root caching.
// Irrelevant on unsupported providers/scopes and should be ignored, not errored.
Key string `json:"key,omitempty"`
}
type CacheControlCapabilities ¶ added in v0.11.0
type CacheControlCapabilities struct {
// Top-level gate: whether request-side TTL/retention is supported at all.
SupportsTTL bool `json:"supportsTTL"`
SupportedKinds []CacheControlKind `json:"supportedKinds,omitempty"`
SupportedTTLs []CacheControlTTL `json:"supportedTTLs,omitempty"`
SupportsKey bool `json:"supportsKey"`
}
type CacheControlKind ¶
type CacheControlKind string
const (
CacheControlKindEphemeral CacheControlKind = "ephemeral"
)
type CacheControlTTL ¶ added in v0.11.0
type CacheControlTTL string
const ( CacheControlTTL5m CacheControlTTL = "5m" CacheControlTTL1h CacheControlTTL = "1h" CacheControlTTL24h CacheControlTTL = "24h" CacheControlTTLInMemory CacheControlTTL = "in-memory" )
type Citation ¶
type Citation struct {
Kind CitationKind `json:"kind"`
URLCitation *URLCitation `json:"urlCitation,omitempty"`
}
type CitationConfig ¶
type CitationConfig struct {
Enabled bool `json:"enabled"`
}
type CompletionDebugger ¶
type CompletionDebugger interface {
// HTTPClient is called once when the provider initializes its SDK client.
//
// The debugger can:
// - wrap base (change Transport),
// - ignore base and create a new client,
// - or return nil to say "use provider's default client".
HTTPClient(base *http.Client) *http.Client
// StartSpan is called at the beginning of FetchCompletion.
//
// It can:
// - inspect the request to decide whether to debug,
// - attach per-request state to the context (e.g., via context keys),
// - return a span handle that will be ended when the call finishes.
//
// If span is nil, no debugging will be performed for this call.
StartSpan(
ctx context.Context,
info *CompletionSpanStart,
) (ctxWithSpan context.Context, span CompletionSpan)
}
CompletionDebugger is the long-lived "client" object for a provider.
Provider code (e.g., OpenAIResponsesAPI) owns one CompletionDebugger. Callers don't touch this directly.
type CompletionSpan ¶
type CompletionSpan interface {
// End is called exactly once, just before FetchCompletion returns.
//
// It can:
// - pull any per-request state from the context,
// - inspect raw/normalized responses and errors,
// - return arbitrary data to attach to Response.DebugDetails.
//
// Returning nil means "no debug details for this call".
End(info *CompletionSpanEnd) any
}
CompletionSpan is the per-request handle. Only provider code sees this; external callers never construct it.
type CompletionSpanEnd ¶
type CompletionSpanEnd struct {
// Raw SDK response (e.g. *responses.Response for OpenAI). May be nil.
ProviderResponse any
// Error from the provider/stream if any.
Err error
// Normalized response object that the caller is about to return.
// May be nil. MUST be treated as read-only.
Response *FetchCompletionResponse
}
type CompletionSpanStart ¶
type CompletionSpanStart struct {
Provider ProviderName
Model ModelName
// Original request and options for this completion.
// These may be nil and MUST be treated as read-only.
Request *FetchCompletionRequest
Options *FetchCompletionOptions
}
type ContentItemFile ¶
type ContentItemFile struct {
ID string `json:"id,omitzero"`
FileName string `json:"fileName,omitzero"`
FileMIME string `json:"fileMIME,omitzero"`
FileURL string `json:"fileURL,omitzero"`
FileData string `json:"fileData,omitzero"`
AdditionalContext string `json:"additionalContext,omitzero"`
CitationConfig *CitationConfig `json:"citationConfig"`
}
type ContentItemImage ¶
type ContentItemKind ¶
type ContentItemKind string
const ( ContentItemKindText ContentItemKind = "text" ContentItemKindImage ContentItemKind = "image" ContentItemKindFile ContentItemKind = "file" ContentItemKindRefusal ContentItemKind = "refusal" )
type ContentItemRefusal ¶
type ContentItemRefusal struct {
Refusal string `json:"refusal"`
}
type ContentItemText ¶
type FetchCompletionOptions ¶
type FetchCompletionOptions struct {
// CompletionKey is an opaque, runtime-only key that is passed in runtime operations
// It can be used by the capability resolver to map arbitrary user/model identifiers to capability profiles.
CompletionKey string `json:"-"`
// StreamHandler, if non-nil, is invoked with incremental streaming events
// when ModelParam.Stream is true. Returning a non-nil error will stop
// streaming early and propagate that error back to the caller.
StreamHandler StreamHandler `json:"-"`
StreamConfig *StreamConfig `json:"streamConfig,omitempty"`
// CapabilityResolver, if non-nil, is used to resolve model capabilities for request validation/normalization.
// Else, inbuilt SDK capabilities are enforced.
CapabilityResolver ModelCapabilityResolver `json:"-"`
}
FetchCompletionOptions controls optional behaviors for FetchCompletion. A nil pointer is treated the same as &FetchCompletionOptions{}.
type FetchCompletionRequest ¶
type FetchCompletionRequest struct {
ModelParam ModelParam `json:"modelParam"`
Inputs []InputUnion `json:"inputs"`
// ToolPolicy - optional control on how (or whether) the model may use the provided ToolChoices.
ToolPolicy *ToolPolicy `json:"toolPolicy,omitempty"`
ToolChoices []ToolChoice `json:"toolChoices,omitempty"`
}
type FetchCompletionResponse ¶
type FetchCompletionResponse struct {
Outputs []OutputUnion `json:"outputs,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Error *Error `json:"error,omitempty"`
Warnings []Warning `json:"warnings,omitempty"`
DebugDetails any `json:"debugDetails,omitempty"`
}
type ImageDetail ¶
type ImageDetail string
const ( ImageDetailHigh ImageDetail = "high" ImageDetailLow ImageDetail = "low" ImageDetailAuto ImageDetail = "auto" )
type InputKind ¶
type InputKind string
const ( InputKindInputMessage InputKind = "inputMessage" InputKindOutputMessage InputKind = "outputMessage" InputKindReasoningMessage InputKind = "reasoningMessage" InputKindFunctionToolCall InputKind = "functionToolCall" InputKindFunctionToolOutput InputKind = "functionToolOutput" InputKindCustomToolCall InputKind = "customToolCall" InputKindCustomToolOutput InputKind = "customToolOutput" InputKindWebSearchToolCall InputKind = "webSearchToolCall" InputKindWebSearchToolOutput InputKind = "webSearchToolOutput" )
type InputOutputContent ¶
type InputOutputContent struct {
ID string `json:"id"`
Role RoleEnum `json:"role"`
Status Status `json:"status,omitzero"`
CacheControl *CacheControl `json:"cacheControl,omitempty"`
Contents []InputOutputContentItemUnion `json:"contents,omitempty"`
}
type InputOutputContentItemUnion ¶
type InputOutputContentItemUnion struct {
Kind ContentItemKind `json:"kind"`
TextItem *ContentItemText `json:"textItem,omitempty"`
RefusalItem *ContentItemRefusal `json:"refusalItem,omitempty"`
ImageItem *ContentItemImage `json:"imageItem,omitempty"`
FileItem *ContentItemFile `json:"fileItem,omitempty"`
}
type InputUnion ¶
type InputUnion struct {
Kind InputKind `json:"kind"`
InputMessage *InputOutputContent `json:"inputMessage,omitempty"`
OutputMessage *InputOutputContent `json:"outputMessage,omitempty"`
ReasoningMessage *ReasoningContent `json:"reasoningMessage,omitempty"`
FunctionToolCall *ToolCall `json:"functionToolCall,omitempty"`
FunctionToolOutput *ToolOutput `json:"functionToolOutput,omitempty"`
CustomToolCall *ToolCall `json:"customToolCall,omitempty"`
CustomToolOutput *ToolOutput `json:"customToolOutput,omitempty"`
WebSearchToolCall *ToolCall `json:"webSearchToolCall,omitempty"`
WebSearchToolOutput *ToolOutput `json:"webSearchToolOutput,omitempty"`
}
type JSONSchemaParam ¶ added in v0.7.0
type JSONSchemaParam struct {
// Name - must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64..
Name string `json:"name"`
// Description: Optional description of what the response format is for, used by the model to determine how to
// respond in the format.
Description string `json:"description,omitempty"`
// JSON Schema payload when Type == jsonSchema.
Schema map[string]any `json:"schema,omitempty"`
// Strict requests stricter adherence where supported.
Strict bool `json:"strict,omitempty"`
}
type MaxOutputTokensParamName ¶ added in v0.17.4
type MaxOutputTokensParamName string
const ( MaxOutputTokensParamNameMaxCompletionTokens MaxOutputTokensParamName = "maxCompletionTokens" MaxOutputTokensParamNameMaxTokens MaxOutputTokensParamName = "maxTokens" )
type Modality ¶ added in v0.9.1
type Modality string
const ( ModalityTextIn Modality = "textIn" ModalityTextOut Modality = "textOut" ModalityImageIn Modality = "imageIn" ModalityImageOut Modality = "imageOut" ModalityFileIn Modality = "fileIn" ModalityFileOut Modality = "fileOut" ModalityAudioIn Modality = "audioIn" ModalityAudioOut Modality = "audioOut" ModalityVideoIn Modality = "videoIn" ModalityVideoOut Modality = "videoOut" )
type ModelCapabilities ¶ added in v0.9.1
type ModelCapabilities struct {
ModalitiesIn []Modality `json:"modalitiesIn"`
ModalitiesOut []Modality `json:"modalitiesOut"`
ReasoningCapabilities *ReasoningCapabilities `json:"reasoningCapabilities,omitempty"`
StopSequenceCapabilities *StopSequenceCapabilities `json:"stopSequenceCapabilities,omitempty"`
OutputCapabilities *OutputCapabilities `json:"outputCapabilities,omitempty"`
ToolCapabilities *ToolCapabilities `json:"toolCapabilities,omitempty"`
CacheCapabilities *CacheCapabilities `json:"cacheCapabilities,omitempty"`
ParamDialect *ParamDialect `json:"paramDialect,omitempty"`
}
type ModelCapabilityResolver ¶ added in v0.9.1
type ModelCapabilityResolver interface {
ResolveModelCapabilities(ctx context.Context, req ResolveModelCapabilitiesRequest) (*ModelCapabilities, error)
}
type ModelParam ¶
type ModelParam struct {
Name ModelName `json:"name"`
Stream bool `json:"stream"`
MaxPromptLength int `json:"maxPromptLength"`
MaxOutputLength int `json:"maxOutputLength"`
Temperature *float64 `json:"temperature,omitempty"`
Reasoning *ReasoningParam `json:"reasoning,omitempty"`
SystemPrompt string `json:"systemPrompt"`
Timeout int `json:"timeout"`
CacheControl *CacheControl `json:"cacheControl,omitempty"`
// OutputParam controls the model's output format.
//
// Cross-provider notes:
// - OpenAI Chat Completions: maps to response_format + verbosity.
// - OpenAI Responses: maps to text.
// - Anthropic Messages: supports jsonSchema via output_config.format; verbosity maps to output_config.effort.
OutputParam *OutputParam `json:"outputParam,omitempty"`
// StopSequences requests provider-side stop sequences when supported.
// Cross-provider notes:
// - OpenAI Chat Completions: maps to stop. Up to 4 sequences supported. Not supported by reasoning models
// - OpenAI Responses: Not supported.
// - Anthropic Messages: maps to stop_sequences.
StopSequences []string `json:"stopSequences,omitempty"`
AdditionalParametersRawJSON *string `json:"additionalParametersRawJSON"`
}
type OpenAIChatCompletionsParamDialect ¶ added in v0.17.4
type OpenAIChatCompletionsParamDialect struct{}
type OutputCapabilities ¶ added in v0.9.1
type OutputCapabilities struct {
SupportedOutputFormats []OutputFormatKind `json:"supportedOutputFormats"`
SupportsVerbosity bool `json:"supportsVerbosity"`
}
type OutputFormat ¶ added in v0.7.0
type OutputFormat struct {
// Can be text or JSONSchema. We don't support JSONObject as it is recommended to move to JSONSchema type.
Kind OutputFormatKind `json:"kind"`
JSONSchemaParam *JSONSchemaParam `json:"jsonSchemaParam,omitempty"`
}
type OutputFormatKind ¶ added in v0.7.0
type OutputFormatKind string
const ( OutputFormatKindText OutputFormatKind = "text" OutputFormatKindJSONSchema OutputFormatKind = "jsonSchema" )
type OutputKind ¶
type OutputKind string
const ( OutputKindOutputMessage OutputKind = "outputMessage" OutputKindReasoningMessage OutputKind = "reasoningMessage" OutputKindFunctionToolCall OutputKind = "functionToolCall" OutputKindCustomToolCall OutputKind = "customToolCall" OutputKindWebSearchToolCall OutputKind = "webSearchToolCall" OutputKindWebSearchToolOutput OutputKind = "webSearchToolOutput" )
type OutputParam ¶ added in v0.7.0
type OutputParam struct {
Format *OutputFormat `json:"format,omitempty"`
// Maps to "Verbosity" in OpenAI, "Effort" in Anthropic.
Verbosity *OutputVerbosity `json:"verbosity,omitempty"`
}
type OutputUnion ¶
type OutputUnion struct {
Kind OutputKind `json:"kind"`
OutputMessage *InputOutputContent `json:"outputMessage,omitempty"`
ReasoningMessage *ReasoningContent `json:"reasoningMessage,omitempty"`
FunctionToolCall *ToolCall `json:"functionToolCall,omitempty"`
CustomToolCall *ToolCall `json:"customToolCall,omitempty"`
WebSearchToolCall *ToolCall `json:"webSearchToolCall,omitempty"`
WebSearchToolOutput *ToolOutput `json:"webSearchToolOutput,omitempty"`
}
type OutputVerbosity ¶ added in v0.7.0
type OutputVerbosity string
OutputVerbosity constrains the verbosity of the model's response. Lower values will result in more concise responses, while higher values will result in more verbose responses.
const ( OutputVerbosityLow OutputVerbosity = "low" OutputVerbosityMedium OutputVerbosity = "medium" OutputVerbosityHigh OutputVerbosity = "high" OutputVerbosityXHigh OutputVerbosity = "xhigh" OutputVerbosityMax OutputVerbosity = "max" )
type ParamDialect ¶ added in v0.17.4
type ParamDialect struct {
MaxOutputTokensParamName MaxOutputTokensParamName `json:"maxOutputTokensParamName,omitempty"`
ToolChoiceParamStyle ToolChoiceParamStyle `json:"toolChoiceParamStyle,omitempty"`
}
type ProviderName ¶
type ProviderName string
type ProviderParam ¶
type ProviderParam struct {
Name ProviderName `json:"name"`
SDKType ProviderSDKType `json:"sdkType"`
APIKey string `json:"apiKey"`
Origin string `json:"origin"`
ChatCompletionPathPrefix string `json:"chatCompletionPathPrefix"`
APIKeyHeaderKey string `json:"apiKeyHeaderKey"`
DefaultHeaders map[string]string `json:"defaultHeaders"`
}
ProviderParam represents information about a provider.
type ProviderSDKType ¶
type ProviderSDKType string
const ( ProviderSDKTypeAnthropic ProviderSDKType = "providerSDKTypeAnthropicMessages" ProviderSDKTypeOpenAIChatCompletions ProviderSDKType = "providerSDKTypeOpenAIChatCompletions" ProviderSDKTypeOpenAIResponses ProviderSDKType = "providerSDKTypeOpenAIResponses" ProviderSDKTypeGoogleGenerateContent ProviderSDKType = "providerSDKTypeGoogleGenerateContent" )
type ReasoningCapabilities ¶ added in v0.9.1
type ReasoningCapabilities struct {
// Top-level gate: whether request-side reasoning config is supported at all.
// If false, ModelParam.Reasoning must not be sent.
SupportsReasoningConfig bool `json:"supportsReasoningConfig"`
SupportedReasoningTypes []ReasoningType `json:"supportedReasoningTypes"`
SupportedReasoningLevels []ReasoningLevel `json:"supportedReasoningLevels"`
HybridTokenBudgetCapabilities *ReasoningTokenBudgetCapabilities `json:"hybridTokenBudgetCapabilities,omitempty"`
SupportsSummaryStyle bool `json:"supportsSummaryStyle"`
SupportsEncryptedReasoningInput bool `json:"supportsEncryptedReasoningInput"`
TemperatureDisallowedWhenEnabled bool `json:"temperatureDisallowedWhenEnabled"`
}
type ReasoningContent ¶
type ReasoningContent struct {
ID string `json:"id"`
Role RoleEnum `json:"role"`
Status Status `json:"status,omitzero"`
CacheControl *CacheControl `json:"cacheControl,omitempty"`
Signature string `json:"signature,omitzero"`
Summary []string `json:"summary,omitempty"`
Thinking []string `json:"thinking,omitempty"`
RedactedThinking []string `json:"redactedThinking,omitempty"`
EncryptedContent []string `json:"encryptedContent,omitempty"`
}
type ReasoningLevel ¶
type ReasoningLevel string
const ( ReasoningLevelNone ReasoningLevel = "none" ReasoningLevelMinimal ReasoningLevel = "minimal" ReasoningLevelLow ReasoningLevel = "low" ReasoningLevelMedium ReasoningLevel = "medium" ReasoningLevelHigh ReasoningLevel = "high" ReasoningLevelXHigh ReasoningLevel = "xhigh" ReasoningLevelMax ReasoningLevel = "max" )
type ReasoningParam ¶
type ReasoningParam struct {
Type ReasoningType `json:"type"`
Level ReasoningLevel `json:"level"`
Tokens int `json:"tokens"`
// SummaryStyle - what kind of summary should be emitted for the reasoning performed by the model.
// SummaryStyle is supported by OpenAI responses only.
SummaryStyle *ReasoningSummaryStyle `json:"summaryStyle,omitempty"`
}
type ReasoningSummaryStyle ¶ added in v0.7.0
type ReasoningSummaryStyle string
const ( ReasoningSummaryStyleAuto ReasoningSummaryStyle = "auto" ReasoningSummaryStyleConcise ReasoningSummaryStyle = "concise" ReasoningSummaryStyleDetailed ReasoningSummaryStyle = "detailed" )
type ReasoningTokenBudgetCapabilities ¶ added in v0.14.0
type ReasoningTokenBudgetCapabilities struct {
MinAllowed int `json:"minAllowed,omitempty"`
MaxAllowed int `json:"maxAllowed,omitempty"`
ZeroAllowed bool `json:"zeroAllowed,omitempty"`
MinusOneAllowed bool `json:"minusOneAllowed,omitempty"`
}
ReasoningTokenBudgetCapabilities applies to ReasoningTypeHybridWithTokens. MinAllowed/MaxAllowed apply to positive token budgets only. Special values 0 and -1 are governed separately because some providers/models support them as distinct control values.
type ReasoningType ¶
type ReasoningType string
const ( ReasoningTypeHybridWithTokens ReasoningType = "hybridWithTokens" ReasoningTypeSingleWithLevels ReasoningType = "singleWithLevels" )
type ResolveModelCapabilitiesRequest ¶ added in v0.9.1
type ResolveModelCapabilitiesRequest struct {
ProviderSDKType ProviderSDKType `json:"providerSDKType"`
ModelName ModelName `json:"modelName"`
CompletionKey string `json:"completionKey"`
}
type StopSequenceCapabilities ¶ added in v0.9.1
type StreamConfig ¶
type StreamConfig struct {
// FlushIntervalMillis is the maximum delay between flushes of buffered stream data to the StreamHandler.
FlushIntervalMillis int `json:"flushIntervalMillis,omitempty"`
// FlushChunkSize is the approximate target size (in bytes/characters) for chunks passed to the StreamHandler.
FlushChunkSize int `json:"flushChunkSize,omitempty"`
}
StreamConfig controls low-level behavior of streaming delivery. All fields are optional; zero values mean "use library defaults".
type StreamContentKind ¶
type StreamContentKind string
StreamContentKind enumerates the kinds of streaming events that can be delivered while a completion is in progress.
const ( StreamContentKindText StreamContentKind = "text" StreamContentKindThinking StreamContentKind = "thinking" )
type StreamEvent ¶
type StreamEvent struct {
Kind StreamContentKind `json:"kind"`
// Optional metadata to help consumers correlate events across models/providers.
Provider ProviderName `json:"provider,omitempty"`
Model ModelName `json:"model,omitempty"`
CompletionKey string `json:"completionKey,omitempty"`
// Exactly one of the below will be non-nil depending on Kind.
Text *StreamTextChunk `json:"text,omitempty"`
Thinking *StreamThinkingChunk `json:"thinking,omitempty"`
}
type StreamHandler ¶
type StreamHandler func(event StreamEvent) error
type StreamTextChunk ¶
type StreamTextChunk struct {
Text string `json:"text"`
}
type StreamThinkingChunk ¶
type StreamThinkingChunk struct {
Text string `json:"text"`
}
type ToolCall ¶
type ToolCall struct {
Type ToolType `json:"type"`
ChoiceID string `json:"choiceID"`
ID string `json:"id"`
Role RoleEnum `json:"role"`
Status Status `json:"status,omitzero"`
CacheControl *CacheControl `json:"cacheControl,omitempty"`
CallID string `json:"callID"`
Name string `json:"name"`
Arguments string `json:"arguments,omitempty"`
Signature string `json:"signature,omitzero"`
WebSearchToolCallItems []WebSearchToolCallItemUnion `json:"webSearchToolCallItems,omitempty"`
}
type ToolCapabilities ¶ added in v0.9.1
type ToolCapabilities struct {
SupportedToolTypes []ToolType `json:"supportedToolTypes"`
SupportedToolPolicyModes []ToolPolicyMode `json:"supportedToolPolicyModes"`
SupportsParallelToolCalls bool `json:"supportsParallelToolCalls"`
MaxForcedTools int `json:"maxForcedTools"`
SupportedClientToolOutputFormats []ToolOutputFormatKind `json:"supportedClientToolOutputFormats,omitempty"`
}
type ToolChoice ¶
type ToolChoice struct {
Type ToolType `json:"type"`
ID string `json:"id"`
CacheControl *CacheControl `json:"cacheControl,omitempty"`
Name string `json:"name"`
Description string `json:"description,omitzero"`
Arguments map[string]any `json:"arguments,omitempty"`
WebSearchArguments *WebSearchToolChoiceItem `json:"webSearchArguments,omitempty"`
}
type ToolChoiceParamStyle ¶ added in v0.17.4
type ToolChoiceParamStyle string
const ( ToolChoiceParamStyleAllowedTools ToolChoiceParamStyle = "allowedTools" ToolChoiceParamStyleRequiredNamed ToolChoiceParamStyle = "requiredNamed" )
type ToolOutput ¶
type ToolOutput struct {
Type ToolType `json:"type"`
ChoiceID string `json:"choiceID"`
ID string `json:"id"`
Role RoleEnum `json:"role"`
Status Status `json:"status,omitzero"`
CacheControl *CacheControl `json:"cacheControl,omitempty"`
CallID string `json:"callID"`
Name string `json:"name"`
IsError bool `json:"isError"`
Signature string `json:"signature,omitzero"`
Contents []ToolOutputItemUnion `json:"contents,omitempty"`
WebSearchToolOutputItems []WebSearchToolOutputItemUnion `json:"webSearchToolOutputItems,omitempty"`
}
type ToolOutputFormatKind ¶ added in v0.17.2
type ToolOutputFormatKind string
ToolOutputFormatKind describes how caller-supplied tool outputs (FunctionToolOutput / CustomToolOutput) may be sent back to the model.
const ( ToolOutputFormatKindString ToolOutputFormatKind = "string" ToolOutputFormatKindContentItemList ToolOutputFormatKind = "contentItemList" )
type ToolOutputItemUnion ¶
type ToolOutputItemUnion struct {
Kind ContentItemKind `json:"kind"`
TextItem *ContentItemText `json:"textItem,omitempty"`
ImageItem *ContentItemImage `json:"imageItem,omitempty"`
FileItem *ContentItemFile `json:"fileItem,omitempty"`
}
type ToolPolicy ¶ added in v0.7.0
type ToolPolicy struct {
// Mode selects the tool policy:
// - auto: model may decide.
// - any: model must use *a* tool.
// OpenAI adapters map this to tool_choice="required" and (by default) allow any ToolChoice.
// - tool: Force a specific tool by name/ID.
// Anthropic directly supports. OpenAI supports this as "required" + one tool in allowed tools.
// - none: prohibit tool use.
//
// Web search note:
// - In OpenAI Chat Completions, web search is configured via top-level web_search_options, not as a tool-call.
// ToolPolicy cannot “force web search” there; toolPolicy.mode=none disables it (best-effort).
Mode ToolPolicyMode `json:"mode"`
AllowedTools []AllowedTool `json:"allowedTools,omitempty"`
// DisableParallel requests that the model emit at most one tool call.
DisableParallel bool `json:"disableParallel,omitempty"`
}
ToolPolicy controls tool selection independent of the tool definitions (ToolChoices).
type ToolPolicyMode ¶ added in v0.7.0
type ToolPolicyMode string
const ( ToolPolicyModeAuto ToolPolicyMode = "auto" ToolPolicyModeAny ToolPolicyMode = "any" ToolPolicyModeTool ToolPolicyMode = "tool" ToolPolicyModeNone ToolPolicyMode = "none" )
type URLCitation ¶
type WebSearchContextSize ¶ added in v0.9.1
type WebSearchContextSize string
const ( WebSearchContextSizeLow WebSearchContextSize = "low" WebSearchContextSizeMedium WebSearchContextSize = "medium" WebSearchContextSizeHigh WebSearchContextSize = "high" )
type WebSearchToolCallFind ¶
type WebSearchToolCallItemUnion ¶
type WebSearchToolCallItemUnion struct {
Kind WebSearchToolCallKind `json:"kind"`
SearchItem *WebSearchToolCallSearch `json:"searchItem,omitempty"`
OpenPageItem *WebSearchToolCallOpenPage `json:"openPageItem,omitempty"`
FindItem *WebSearchToolCallFind `json:"findItem,omitempty"`
}
type WebSearchToolCallKind ¶
type WebSearchToolCallKind string
const ( WebSearchToolCallKindSearch WebSearchToolCallKind = "search" WebSearchToolCallKindOpenPage WebSearchToolCallKind = "openPage" WebSearchToolCallKindFind WebSearchToolCallKind = "find" )
type WebSearchToolCallOpenPage ¶
type WebSearchToolCallOpenPage struct {
URL string `json:"url"`
}
type WebSearchToolCallSearch ¶
type WebSearchToolCallSearch struct {
Query string `json:"query"`
Sources []WebSearchToolCallSearchSource `json:"sources,omitempty"`
Input map[string]any `json:"input,omitempty"`
}
type WebSearchToolCallSearchSource ¶
type WebSearchToolCallSearchSource struct {
URL string `json:"url"`
}
type WebSearchToolChoiceItem ¶
type WebSearchToolChoiceItem struct {
MaxUses int64 `json:"maxUses,omitzero"`
SearchContextSize WebSearchContextSize `json:"searchContextSize,omitzero"`
AllowedDomains []string `json:"allowedDomains,omitzero"`
BlockedDomains []string `json:"blockedDomains,omitzero"`
UserLocation *WebSearchToolChoiceItemUserLocation `json:"userLocation,omitempty"`
}
type WebSearchToolOutputError ¶
type WebSearchToolOutputError struct {
Code string `json:"code"`
}
type WebSearchToolOutputItemUnion ¶
type WebSearchToolOutputItemUnion struct {
Kind WebSearchToolOutputKind `json:"kind"`
SearchItem *WebSearchToolOutputSearch `json:"searchItem,omitempty"`
ErrorItem *WebSearchToolOutputError `json:"errorItem,omitempty"`
}
type WebSearchToolOutputKind ¶
type WebSearchToolOutputKind string
const ( WebSearchToolOutputKindSearch WebSearchToolOutputKind = "search" WebSearchToolOutputKindError WebSearchToolOutputKind = "error" )