Documentation
¶
Overview ¶
Package models defines shared types for the CLASP proxy.
Package models defines shared types for the CLASP proxy.
Index ¶
- Constants
- type AnthropicContentBlock
- type AnthropicMessage
- type AnthropicRequest
- type AnthropicResponse
- type AnthropicTool
- type AnthropicUsage
- type CacheControl
- type ContentBlock
- type ContentBlockDeltaEvent
- type ContentBlockStartData
- type ContentBlockStartEvent
- type ContentBlockStopEvent
- type DeltaData
- type ImageSource
- type ImageURL
- type MessageDeltaData
- type MessageDeltaEvent
- type MessageDeltaUsage
- type MessageStartEvent
- type MessageStopEvent
- type Metadata
- type OpenAIContentPart
- type OpenAIFunction
- type OpenAIFunctionCall
- type OpenAIMessage
- type OpenAIRequest
- type OpenAIStreamChunk
- type OpenAITool
- type OpenAIToolCall
- type OpenRouterThinkingConfig
- type PingEvent
- type ReasoningContent
- type ResponsesAnnotation
- type ResponsesAudioPart
- type ResponsesContentPart
- type ResponsesDelta
- type ResponsesError
- type ResponsesFunction
- type ResponsesInput
- type ResponsesItem
- type ResponsesMCPServer
- type ResponsesOutputContentPart
- type ResponsesReasoning
- type ResponsesRequest
- type ResponsesResponse
- type ResponsesStreamEvent
- type ResponsesStreamEventExtended
- type ResponsesSummaryItem
- type ResponsesTokenDetails
- type ResponsesTool
- type ResponsesUsage
- type ResponsesUserLocation
- type ResponsesWebSearchTool
- type StreamChoice
- type StreamDelta
- type StreamOptions
- type ThinkingConfig
- type Usage
- type WebSearchAction
Constants ¶
const ( // Response lifecycle events EventResponseCreated = "response.created" EventResponseInProgress = "response.in_progress" EventResponseCompleted = "response.completed" EventResponseFailed = "response.failed" EventResponseCancelled = "response.cancelled" EventResponseIncomplete = "response.incomplete" EventResponseQueued = "response.queued" // Output item events EventOutputItemAdded = "response.output_item.added" EventOutputItemDone = "response.output_item.done" // Content events EventContentPartAdded = "response.content_part.added" EventContentPartDelta = "response.content_part.delta" EventContentPartDone = "response.content_part.done" // Text output events (primary text streaming) EventOutputTextDelta = "response.output_text.delta" EventOutputTextDone = "response.output_text.done" EventOutputTextAnnotationAdd = "response.output_text.annotation.added" // Refusal events EventRefusalDelta = "response.refusal.delta" EventRefusalDone = "response.refusal.done" // Reasoning events EventReasoningTextDelta = "response.reasoning_text.delta" EventReasoningTextDone = "response.reasoning_text.done" EventReasoningSummaryPartAdded = "response.reasoning_summary_part.added" EventReasoningSummaryPartDone = "response.reasoning_summary_part.done" EventReasoningSummaryTextDelta = "response.reasoning_summary_text.delta" EventReasoningSummaryTextDone = "response.reasoning_summary_text.done" // Function call events EventFunctionCallArgs = "response.function_call_arguments.delta" EventFunctionCallDone = "response.function_call_arguments.done" // Rate limit event EventRateLimitsUpdated = "rate_limits.updated" )
Responses API SSE Event Types
const ( ToolTypeComputer = "computer_20241024" ToolTypeTextEditor = "text_editor_20250124" ToolTypeBash = "bash_20241022" )
Computer use tool type constants
const ( EventMessageStart = "message_start" EventContentBlockStart = "content_block_start" EventContentBlockDelta = "content_block_delta" EventContentBlockStop = "content_block_stop" EventMessageDelta = "message_delta" EventMessageStop = "message_stop" EventPing = "ping" )
SSE Event types for Anthropic streaming.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnthropicContentBlock ¶
type AnthropicContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input interface{} `json:"input,omitempty"`
}
AnthropicContentBlock represents a content block in Anthropic response.
type AnthropicMessage ¶
type AnthropicMessage struct {
Role string `json:"role"`
Content interface{} `json:"content"` // Can be string or []ContentBlock
}
AnthropicMessage represents a message in Anthropic format.
type AnthropicRequest ¶
type AnthropicRequest struct {
Model string `json:"model"`
System interface{} `json:"system,omitempty"` // Can be string or []ContentBlock
Messages []AnthropicMessage `json:"messages"`
MaxTokens int `json:"max_tokens,omitempty"`
Stream bool `json:"stream,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
TopK *int `json:"top_k,omitempty"`
Tools []AnthropicTool `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
Metadata *Metadata `json:"metadata,omitempty"`
Thinking *ThinkingConfig `json:"thinking,omitempty"` // Extended thinking configuration
}
AnthropicRequest represents an incoming Anthropic Messages API request.
type AnthropicResponse ¶
type AnthropicResponse struct {
ID string `json:"id"`
Type string `json:"type"`
Role string `json:"role"`
Content []AnthropicContentBlock `json:"content"`
Model string `json:"model"`
StopReason string `json:"stop_reason,omitempty"`
StopSequence string `json:"stop_sequence,omitempty"`
Usage *AnthropicUsage `json:"usage,omitempty"`
}
AnthropicResponse represents a response in Anthropic format.
type AnthropicTool ¶
type AnthropicTool struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema interface{} `json:"input_schema"`
// Type field for computer use tools (e.g., "computer_20241024", "text_editor_20250124", "bash_20241022")
Type string `json:"type,omitempty"`
// Cache control (Anthropic-specific, stripped during translation)
CacheControl *CacheControl `json:"cache_control,omitempty"`
}
AnthropicTool represents a tool definition in Anthropic format.
type AnthropicUsage ¶
type AnthropicUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
}
AnthropicUsage represents usage in Anthropic format.
type CacheControl ¶ added in v0.29.0
type CacheControl struct {
Type string `json:"type"` // "ephemeral"
}
CacheControl represents Anthropic's prompt caching configuration. This is stripped during translation as OpenAI doesn't support prompt caching.
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Source *ImageSource `json:"source,omitempty"`
// Tool use fields
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input interface{} `json:"input,omitempty"`
// Tool result fields
ToolUseID string `json:"tool_use_id,omitempty"`
Content interface{} `json:"content,omitempty"` // Can be string or []ContentBlock for tool results
IsError bool `json:"is_error,omitempty"`
// Cache control (Anthropic-specific, stripped during translation)
CacheControl *CacheControl `json:"cache_control,omitempty"`
}
ContentBlock represents a content block in Anthropic messages.
type ContentBlockDeltaEvent ¶
type ContentBlockDeltaEvent struct {
Type string `json:"type"`
Index int `json:"index"`
Delta DeltaData `json:"delta"`
}
ContentBlockDeltaEvent represents a content_block_delta SSE event.
type ContentBlockStartData ¶
type ContentBlockStartData struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Thinking string `json:"thinking,omitempty"` // For thinking blocks
}
ContentBlockStartData represents the content_block in a start event.
type ContentBlockStartEvent ¶
type ContentBlockStartEvent struct {
Type string `json:"type"`
Index int `json:"index"`
ContentBlock ContentBlockStartData `json:"content_block"`
}
ContentBlockStartEvent represents a content_block_start SSE event.
type ContentBlockStopEvent ¶
ContentBlockStopEvent represents a content_block_stop SSE event.
type DeltaData ¶
type DeltaData struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
PartialJSON string `json:"partial_json,omitempty"`
Thinking string `json:"thinking,omitempty"` // For thinking_delta blocks
}
DeltaData represents the delta in a content_block_delta event.
type ImageSource ¶
type ImageSource struct {
Type string `json:"type"`
MediaType string `json:"media_type"`
Data string `json:"data"`
}
ImageSource represents an image source in Anthropic format.
type ImageURL ¶
type ImageURL struct {
URL string `json:"url"`
}
ImageURL represents an image URL in OpenAI format.
type MessageDeltaData ¶
type MessageDeltaData struct {
StopReason string `json:"stop_reason,omitempty"`
StopSequence string `json:"stop_sequence,omitempty"`
}
MessageDeltaData represents the delta in a message_delta event.
type MessageDeltaEvent ¶
type MessageDeltaEvent struct {
Type string `json:"type"`
Delta MessageDeltaData `json:"delta"`
Usage *MessageDeltaUsage `json:"usage,omitempty"`
}
MessageDeltaEvent represents a message_delta SSE event.
type MessageDeltaUsage ¶
type MessageDeltaUsage struct {
OutputTokens int `json:"output_tokens"`
}
MessageDeltaUsage represents usage in a message_delta event.
type MessageStartEvent ¶
type MessageStartEvent struct {
Type string `json:"type"`
Message AnthropicResponse `json:"message"`
}
MessageStartEvent represents a message_start SSE event.
type MessageStopEvent ¶
type MessageStopEvent struct {
Type string `json:"type"`
}
MessageStopEvent represents a message_stop SSE event.
type Metadata ¶
type Metadata struct {
UserID string `json:"user_id,omitempty"`
}
Metadata represents request metadata.
type OpenAIContentPart ¶
type OpenAIContentPart struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
ImageURL *ImageURL `json:"image_url,omitempty"`
}
OpenAIContentPart represents a content part in OpenAI messages.
type OpenAIFunction ¶
type OpenAIFunction struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters interface{} `json:"parameters"`
Strict bool `json:"strict"` // CRITICAL: Must be false to allow optional parameters
}
OpenAIFunction represents a function definition in OpenAI format.
type OpenAIFunctionCall ¶
OpenAIFunctionCall represents a function call in OpenAI format.
type OpenAIMessage ¶
type OpenAIMessage struct {
Role string `json:"role"`
Content interface{} `json:"content,omitempty"` // string or []OpenAIContentPart
ToolCalls []OpenAIToolCall `json:"tool_calls,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
OpenAIMessage represents a message in OpenAI format.
type OpenAIRequest ¶
type OpenAIRequest struct {
Model string `json:"model"`
Messages []OpenAIMessage `json:"messages"`
MaxTokens int `json:"max_tokens,omitempty"`
MaxCompletionTokens int `json:"max_completion_tokens,omitempty"` // For O1/O3 reasoning models
Stream bool `json:"stream,omitempty"`
Stop []string `json:"stop,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
Tools []OpenAITool `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
StreamOptions *StreamOptions `json:"stream_options,omitempty"`
ReasoningEffort string `json:"reasoning_effort,omitempty"` // O1/O3: "minimal", "low", "medium", "high"
// Provider-specific reasoning parameters (OpenRouter)
ThinkingConfig *OpenRouterThinkingConfig `json:"thinking_config,omitempty"` // Gemini 2.5
ThinkingLevel string `json:"thinking_level,omitempty"` // Gemini 3
EnableThinking *bool `json:"enable_thinking,omitempty"` // Qwen
ThinkingBudget int `json:"thinking_budget,omitempty"` // Qwen
ReasoningSplit *bool `json:"reasoning_split,omitempty"` // MiniMax
}
OpenAIRequest represents an outgoing OpenAI Chat Completions API request.
type OpenAIStreamChunk ¶
type OpenAIStreamChunk struct {
ID string `json:"id"`
Object string `json:"object"`
Created int64 `json:"created"`
Model string `json:"model"`
Choices []StreamChoice `json:"choices"`
Usage *Usage `json:"usage,omitempty"`
}
OpenAIStreamChunk represents a streaming chunk from OpenAI.
type OpenAITool ¶
type OpenAITool struct {
Type string `json:"type"`
Function OpenAIFunction `json:"function"`
}
OpenAITool represents a tool definition in OpenAI format.
type OpenAIToolCall ¶
type OpenAIToolCall struct {
ID string `json:"id"`
Type string `json:"type"`
Function OpenAIFunctionCall `json:"function"`
Index int `json:"index,omitempty"`
}
OpenAIToolCall represents a tool call in OpenAI format.
type OpenRouterThinkingConfig ¶ added in v0.14.0
type OpenRouterThinkingConfig struct {
ThinkingBudget int `json:"thinking_budget"`
}
OpenRouterThinkingConfig for Gemini 2.5 models.
type PingEvent ¶
type PingEvent struct {
Type string `json:"type"`
}
PingEvent represents a ping SSE event.
type ReasoningContent ¶ added in v0.30.0
type ReasoningContent struct {
Content string `json:"content,omitempty"`
}
ReasoningContent represents reasoning/thinking content in streaming. Some providers return this in usage.completion_tokens_details.
type ResponsesAnnotation ¶ added in v0.48.11
type ResponsesAnnotation struct {
Type string `json:"type"` // "url_citation", "file_citation"
StartIndex int `json:"start_index"` // Character position where citation begins
EndIndex int `json:"end_index"` // Character position where citation ends
URL string `json:"url,omitempty"`
Title string `json:"title,omitempty"`
// File citation fields
FileID string `json:"file_id,omitempty"`
Filename string `json:"filename,omitempty"`
}
ResponsesAnnotation represents a citation or annotation in Responses output. Used primarily for web search results to cite sources.
type ResponsesAudioPart ¶ added in v0.23.0
type ResponsesAudioPart struct {
Data string `json:"data"` // Base64-encoded audio
Format string `json:"format"` // "wav", "mp3", etc.
}
ResponsesAudioPart represents audio input in Responses API.
type ResponsesContentPart ¶ added in v0.23.0
type ResponsesContentPart struct {
Type string `json:"type"` // "input_text", "input_image", "output_text", "input_audio", "text", "image_url"
Text string `json:"text,omitempty"`
ImageURL *ImageURL `json:"image_url,omitempty"`
Audio *ResponsesAudioPart `json:"input_audio,omitempty"`
}
ResponsesContentPart represents a content part in Responses input. Note: Responses API uses "input_text" and "input_image" for user/input content types, and "output_text" for assistant/output content types.
type ResponsesDelta ¶ added in v0.23.0
type ResponsesDelta struct {
Type string `json:"type"` // "text_delta", "refusal_delta", "function_call_arguments_delta"
Text string `json:"text,omitempty"`
Refusal string `json:"refusal,omitempty"`
CallID string `json:"call_id,omitempty"`
Delta string `json:"delta,omitempty"` // For function call arguments or generic delta content
}
ResponsesDelta represents incremental content in streaming.
type ResponsesError ¶ added in v0.23.0
ResponsesError represents an error in Responses API.
type ResponsesFunction ¶ added in v0.23.0
type ResponsesFunction struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Parameters interface{} `json:"parameters,omitempty"`
Strict bool `json:"strict,omitempty"`
}
ResponsesFunction represents a function tool in Responses API.
type ResponsesInput ¶ added in v0.23.0
type ResponsesInput struct {
Type string `json:"type"` // "message", "function_call", "function_call_output", "item_reference"
Role string `json:"role,omitempty"`
Content interface{} `json:"content,omitempty"` // string or []ResponsesContentPart
ID string `json:"id,omitempty"` // For item_reference
// Function call fields (type: "function_call")
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
// Function call output fields (type: "function_call_output")
// NOTE: Output uses a pointer to differentiate between unset (nil) and empty string ("").
// OpenAI Responses API REQUIRES the "output" field for function_call_output items,
// even when the output is empty. Using *string ensures empty outputs are serialized.
Output *string `json:"output,omitempty"`
}
ResponsesInput represents an input item in a Responses request. Supports multiple item types: message, function_call, function_call_output, item_reference
type ResponsesItem ¶ added in v0.23.0
type ResponsesItem struct {
Type string `json:"type"` // "reasoning", "message", "function_call", "function_call_output", "web_search_call"
ID string `json:"id,omitempty"`
// Message fields
Role string `json:"role,omitempty"`
Content interface{} `json:"content,omitempty"` // string or []ResponsesOutputContentPart
// Reasoning fields
// Summary is an array of summary items, each with a text field
// Populated when using reasoning.summary: "auto" or "detailed"
Summary []ResponsesSummaryItem `json:"summary,omitempty"`
// Function call fields
CallID string `json:"call_id,omitempty"`
Name string `json:"name,omitempty"`
Arguments string `json:"arguments,omitempty"`
Status string `json:"status,omitempty"` // "in_progress", "completed", "failed"
Output string `json:"output,omitempty"` // For function_call_output
// Web search call fields (type: "web_search_call")
// Action is an object with type "search" and a query field
Action *WebSearchAction `json:"action,omitempty"`
}
ResponsesItem represents an output item in Responses API. Items are polymorphic: reasoning, message, function_call, function_call_output, web_search_call
type ResponsesMCPServer ¶ added in v0.23.0
type ResponsesMCPServer struct {
URL string `json:"url"`
AllowedTools []string `json:"allowed_tools,omitempty"`
Headers map[string]string `json:"headers,omitempty"`
}
ResponsesMCPServer represents an MCP server tool in Responses API.
type ResponsesOutputContentPart ¶ added in v0.23.0
type ResponsesOutputContentPart struct {
Type string `json:"type"` // "output_text", "refusal", "audio"
Text string `json:"text,omitempty"`
Refusal string `json:"refusal,omitempty"`
AudioData string `json:"audio_data,omitempty"`
Transcript string `json:"transcript,omitempty"`
Annotations []ResponsesAnnotation `json:"annotations,omitempty"`
}
ResponsesOutputContentPart represents a content part in Responses output.
type ResponsesReasoning ¶ added in v0.25.18
type ResponsesReasoning struct {
Effort string `json:"effort,omitempty"` // "low", "medium", "high"
}
ResponsesReasoning represents the nested reasoning configuration for Responses API. The Responses API requires reasoning parameters under this nested object.
type ResponsesRequest ¶ added in v0.23.0
type ResponsesRequest struct {
Model string `json:"model"`
Input []ResponsesInput `json:"input"`
PreviousResponseID string `json:"previous_response_id,omitempty"`
Tools []ResponsesTool `json:"tools,omitempty"`
ToolChoice interface{} `json:"tool_choice,omitempty"`
MaxOutputTokens int `json:"max_output_tokens,omitempty"`
Stream bool `json:"stream,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
Background bool `json:"background,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Reasoning *ResponsesReasoning `json:"reasoning,omitempty"`
Instructions string `json:"instructions,omitempty"`
}
ResponsesRequest represents an OpenAI Responses API request.
type ResponsesResponse ¶ added in v0.23.0
type ResponsesResponse struct {
ID string `json:"id"`
Object string `json:"object"` // "response"
CreatedAt int64 `json:"created_at"`
Model string `json:"model"`
Status string `json:"status"` // "completed", "in_progress", "failed", "canceled"
Output []ResponsesItem `json:"output"`
Usage *ResponsesUsage `json:"usage,omitempty"`
Metadata map[string]string `json:"metadata,omitempty"`
Error *ResponsesError `json:"error,omitempty"`
}
ResponsesResponse represents an OpenAI Responses API response.
type ResponsesStreamEvent ¶ added in v0.23.0
type ResponsesStreamEvent struct {
Type string `json:"type"` // "response.created", "response.output_item.added", etc.
Response *ResponsesResponse `json:"response,omitempty"`
Item *ResponsesItem `json:"item,omitempty"`
Delta *ResponsesDelta `json:"delta,omitempty"`
Error *ResponsesError `json:"error,omitempty"`
Index int `json:"index,omitempty"`
// Extended fields for output_text.delta and similar events
ResponseID string `json:"response_id,omitempty"`
ItemID string `json:"item_id,omitempty"`
OutputIndex int `json:"output_index,omitempty"`
ContentIndex int `json:"content_index,omitempty"`
DeltaText string `json:"-"` // Populated from delta field after checking type (not a direct JSON field)
Text string `json:"text,omitempty"` // Complete text for done events
SequenceNumber int `json:"sequence_number,omitempty"`
// Part field for content_part events
Part *ResponsesOutputContentPart `json:"part,omitempty"`
// Annotation field for output_text.annotation.added events
Annotation *ResponsesAnnotation `json:"annotation,omitempty"`
}
ResponsesStreamEvent represents an SSE event from Responses API streaming. This struct accommodates multiple event formats used by the Responses API.
func (*ResponsesStreamEvent) UnmarshalJSON ¶ added in v0.34.1
func (e *ResponsesStreamEvent) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling to handle the polymorphic delta field. OpenAI's Responses API uses "delta" as both an object (for content_part.delta) and a string (for output_text.delta, refusal.delta, etc.).
type ResponsesStreamEventExtended ¶ added in v0.31.0
type ResponsesStreamEventExtended struct {
Type string `json:"type"`
ResponseID string `json:"response_id,omitempty"`
ItemID string `json:"item_id,omitempty"`
OutputIndex int `json:"output_index,omitempty"`
ContentIndex int `json:"content_index,omitempty"`
Delta string `json:"delta,omitempty"` // Direct delta text for output_text.delta
Text string `json:"text,omitempty"` // Complete text for done events
SequenceNumber int `json:"sequence_number,omitempty"`
Response *ResponsesResponse `json:"response,omitempty"`
Item *ResponsesItem `json:"item,omitempty"`
Error *ResponsesError `json:"error,omitempty"`
}
ResponsesStreamEventExtended represents extended stream event fields for newer events. Some events like response.output_text.delta have different structures.
type ResponsesSummaryItem ¶ added in v0.34.5
type ResponsesSummaryItem struct {
Type string `json:"type,omitempty"` // "summary_text"
Text string `json:"text,omitempty"`
}
ResponsesSummaryItem represents a single reasoning summary item.
type ResponsesTokenDetails ¶ added in v0.23.0
type ResponsesTokenDetails struct {
ReasoningTokens int `json:"reasoning_tokens"`
}
ResponsesTokenDetails provides detailed token breakdown.
type ResponsesTool ¶ added in v0.23.0
type ResponsesTool struct {
Type string `json:"type"` // "function", "code_interpreter", "file_search", "mcp", "custom"
// Top-level fields for Responses API flattened format
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
Parameters interface{} `json:"parameters,omitempty"`
// CRITICAL: Strict must be explicitly set to false at top level for Responses API
// When true, OpenAI enforces all "required" parameters must be provided.
// Anthropic tools mark ALL params as required, so strict=true causes validation failures.
Strict *bool `json:"strict,omitempty"`
// Nested function for backwards compatibility with Chat Completions format
Function *ResponsesFunction `json:"function,omitempty"`
MCPServer *ResponsesMCPServer `json:"mcp_server,omitempty"`
}
ResponsesTool represents a tool definition in Responses API. Note: Responses API supports both the Chat Completions format (with nested function) and a flattened format where name/description/parameters are at the top level.
type ResponsesUsage ¶ added in v0.23.0
type ResponsesUsage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
OutputTokensDetails *ResponsesTokenDetails `json:"output_tokens_details,omitempty"`
CacheReadInputTokens int `json:"cache_read_input_tokens,omitempty"`
CacheCreationInputTokens int `json:"cache_creation_input_tokens,omitempty"`
}
ResponsesUsage represents usage statistics in Responses API.
type ResponsesUserLocation ¶ added in v0.48.11
type ResponsesUserLocation struct {
Type string `json:"type"` // "approximate"
Country string `json:"country,omitempty"` // ISO 3166-1 alpha-2 country code
City string `json:"city,omitempty"`
Region string `json:"region,omitempty"`
Timezone string `json:"timezone,omitempty"`
}
ResponsesUserLocation provides location context for web search results.
type ResponsesWebSearchTool ¶ added in v0.48.11
type ResponsesWebSearchTool struct {
Type string `json:"type"` // "web_search_preview"
SearchContextSize string `json:"search_context_size,omitempty"` // "low", "medium", "high"
UserLocation *ResponsesUserLocation `json:"user_location,omitempty"`
}
ResponsesWebSearchTool represents a web_search_preview tool in Responses API. When included in tools, the model can search the web for current information.
type StreamChoice ¶
type StreamChoice struct {
Index int `json:"index"`
Delta StreamDelta `json:"delta"`
FinishReason string `json:"finish_reason,omitempty"`
}
StreamChoice represents a choice in a streaming chunk.
type StreamDelta ¶
type StreamDelta struct {
Role string `json:"role,omitempty"`
Content string `json:"content,omitempty"`
ToolCalls []OpenAIToolCall `json:"tool_calls,omitempty"`
// Reasoning fields for O1/O3 models (returned by some providers)
Reasoning string `json:"reasoning,omitempty"` // Azure OpenAI
}
StreamDelta represents the delta content in a streaming chunk.
type StreamOptions ¶
type StreamOptions struct {
IncludeUsage bool `json:"include_usage"`
}
StreamOptions for OpenAI streaming.
type ThinkingConfig ¶ added in v0.14.0
type ThinkingConfig struct {
Type string `json:"type,omitempty"` // "enabled"
BudgetTokens int `json:"budget_tokens,omitempty"` // Token budget for reasoning
}
ThinkingConfig represents the Anthropic thinking/extended reasoning configuration.
type Usage ¶
type Usage struct {
PromptTokens int `json:"prompt_tokens"`
CompletionTokens int `json:"completion_tokens"`
TotalTokens int `json:"total_tokens"`
}
Usage represents token usage information.
type WebSearchAction ¶ added in v0.48.12
type WebSearchAction struct {
Type string `json:"type"` // "search"
Query string `json:"query"` // The search query used
}
WebSearchAction represents the action details for a web_search_call.