Documentation
¶
Index ¶
- Constants
- func DataURI(mimeType string, data []byte) string
- func DefaultSleep(ctx context.Context, d time.Duration) error
- func ErrorFromHTTPStatus(provider string, statusCode int, message string, raw any, ...) error
- func ExpandTilde(path string) string
- func InferMimeTypeFromPath(path string) string
- func IsAuthenticationError(err error) bool
- func IsLocalPath(s string) bool
- func NewAbortError(message string) error
- func NewInvalidToolCallError(message string) error
- func NewNetworkError(provider, message string) error
- func NewNoObjectGeneratedError(message string, rawText string) error
- func NewRequestTimeoutError(provider string, message string) error
- func NewStreamError(provider, message string) error
- func NewUnsupportedToolChoiceError(provider, mode string) error
- func ParseRetryAfter(v string, now time.Time) *time.Duration
- func ParseSSE(ctx context.Context, r io.Reader, fn func(ev SSEEvent) error) error
- func RegisterEnvAdapterFactory(factory EnvAdapterFactory)
- func Retry[T any](ctx context.Context, policy RetryPolicy, sleep SleepFunc, ...) (T, error)
- func SetDefaultClient(c *Client)
- func ValidateToolName(name string) error
- func WithTimeout(ctx context.Context, d time.Duration) (context.Context, context.CancelFunc)
- func WrapContextError(provider string, err error) error
- type AbortError
- type AccessDeniedError
- type AudioData
- type AuthenticationError
- type ChanStream
- type Client
- func (c *Client) Complete(ctx context.Context, req Request) (Response, error)
- func (c *Client) ProviderNames() []string
- func (c *Client) Register(adapter ProviderAdapter)
- func (c *Client) SetDefaultProvider(name string)
- func (c *Client) Stream(ctx context.Context, req Request) (Stream, error)
- func (c *Client) Use(mw ...Middleware)
- type CompleteFunc
- type ConfigurationError
- type ContentFilterError
- type ContentKind
- type ContentPart
- type ContextLengthError
- type DocumentData
- type EnvAdapterFactory
- type Error
- type FinishReason
- type GenerateObjectOptions
- type GenerateOptions
- type GenerateResult
- type ImageData
- type InvalidRequestError
- type InvalidToolCallError
- type Message
- type Middleware
- type MiddlewareFunc
- type ModelCatalog
- type ModelInfo
- type NetworkError
- type NoObjectGeneratedError
- type NotFoundError
- type ProviderAdapter
- type ProviderExecutionPolicy
- type ProviderToolLifecycle
- type ProviderToolOutputDelta
- type QuotaExceededError
- type RateLimitError
- type RateLimitInfo
- type Request
- type RequestTimeoutError
- type Response
- type ResponseFormat
- type RetryPolicy
- type Role
- type SSEEvent
- type ServerError
- type SleepFunc
- type StepResult
- type Stream
- type StreamAccumulator
- type StreamError
- type StreamEvent
- type StreamEventType
- type StreamFunc
- type StreamResult
- type ThinkingData
- type Tool
- type ToolCallData
- type ToolChoice
- type ToolDefinition
- type ToolResultData
- type UnknownHTTPError
- type UnsupportedToolChoiceError
- type Usage
- type Warning
Constants ¶
const ( FinishReasonStop = "stop" FinishReasonLength = "length" FinishReasonToolCalls = "tool_calls" FinishReasonContentFilter = "content_filter" FinishReasonError = "error" FinishReasonOther = "other" )
Canonical finish reason values per unified spec section 3.8.
Variables ¶
This section is empty.
Functions ¶
func ErrorFromHTTPStatus ¶
func ExpandTilde ¶
func InferMimeTypeFromPath ¶
func IsAuthenticationError ¶
func IsLocalPath ¶
func NewAbortError ¶
func NewInvalidToolCallError ¶
func NewNetworkError ¶
func NewRequestTimeoutError ¶
NewRequestTimeoutError constructs a non-HTTP timeout error (e.g., context deadline exceeded) that matches the unified error hierarchy. These timeouts are not retried by default (spec).
func NewStreamError ¶
func ParseRetryAfter ¶
ParseRetryAfter parses the Retry-After header value. Supported forms: - integer seconds - HTTP-date (RFC 7231)
func ParseSSE ¶
ParseSSE parses Server-Sent Events from r and invokes fn for each complete event. It handles "event:" and "data:" lines and emits an event on blank-line boundaries.
func RegisterEnvAdapterFactory ¶
func RegisterEnvAdapterFactory(factory EnvAdapterFactory)
RegisterEnvAdapterFactory registers a factory that can construct a ProviderAdapter from environment variables. Provider packages should call this from init().
func Retry ¶
func Retry[T any](ctx context.Context, policy RetryPolicy, sleep SleepFunc, randFloat func() float64, fn func() (T, error)) (T, error)
Retry runs fn and retries retryable errors with exponential backoff and jitter.
Semantics: - policy.MaxRetries is the number of retries (not counting the initial attempt). - Jitter is +/- 50% (factor in [0.5, 1.5]) per unified-llm-spec.md. - If err provides RetryAfter:
- if RetryAfter <= policy.MaxDelay (or MaxDelay <= 0), it overrides calculated backoff.
- if RetryAfter > policy.MaxDelay, Retry aborts immediately (no retry) per spec.
func SetDefaultClient ¶
func SetDefaultClient(c *Client)
SetDefaultClient sets the module-level default client and disables lazy env initialization.
func ValidateToolName ¶
Tool names must match the strict common subset across providers: [a-zA-Z][a-zA-Z0-9_]* with a max length of 64.
func WithTimeout ¶
WithTimeout wraps ctx in a context with the given timeout. A zero or negative timeout returns the input context unchanged.
func WrapContextError ¶
WrapContextError converts context cancellation/deadline errors into the SDK error hierarchy (AbortError/RequestTimeoutError). Other errors are returned unchanged.
Types ¶
type AbortError ¶
type AbortError struct {
// contains filtered or unexported fields
}
func (*AbortError) RetryAfter ¶
func (*AbortError) StatusCode ¶
func (e *AbortError) StatusCode() int
type AccessDeniedError ¶
type AccessDeniedError struct {
// contains filtered or unexported fields
}
func (*AccessDeniedError) RetryAfter ¶
func (*AccessDeniedError) StatusCode ¶
func (e *AccessDeniedError) StatusCode() int
type AuthenticationError ¶
type AuthenticationError struct {
// contains filtered or unexported fields
}
func (*AuthenticationError) RetryAfter ¶
func (*AuthenticationError) StatusCode ¶
func (e *AuthenticationError) StatusCode() int
type ChanStream ¶
type ChanStream struct {
// contains filtered or unexported fields
}
func NewChanStream ¶
func NewChanStream(cancel context.CancelFunc) *ChanStream
func (*ChanStream) Close ¶
func (s *ChanStream) Close() error
func (*ChanStream) CloseSend ¶
func (s *ChanStream) CloseSend()
CloseSend closes the event channel and marks the stream as finished. Provider adapters should call this exactly once when the underlying stream finishes.
func (*ChanStream) Events ¶
func (s *ChanStream) Events() <-chan StreamEvent
func (*ChanStream) Send ¶
func (s *ChanStream) Send(ev StreamEvent)
Send publishes a stream event, dropping it if the stream is already closed.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func DefaultClient ¶
DefaultClient returns the module-level default client, lazily constructing it from environment variables on first use.
func NewFromEnv ¶
NewFromEnv constructs a Client by registering any provider adapters that can be constructed from environment variables. The first successfully registered provider becomes the default provider.
Note: providers are discovered via factories registered with RegisterEnvAdapterFactory.
func (*Client) ProviderNames ¶
func (*Client) Register ¶
func (c *Client) Register(adapter ProviderAdapter)
func (*Client) SetDefaultProvider ¶
func (*Client) Use ¶
func (c *Client) Use(mw ...Middleware)
Use appends middleware to the client. Middleware is applied in registration order for the request phase and in reverse order for the response/event phases.
type ConfigurationError ¶
type ConfigurationError struct {
Message string
}
func (*ConfigurationError) Error ¶
func (e *ConfigurationError) Error() string
func (*ConfigurationError) Provider ¶
func (e *ConfigurationError) Provider() string
func (*ConfigurationError) RetryAfter ¶
func (e *ConfigurationError) RetryAfter() *time.Duration
func (*ConfigurationError) Retryable ¶
func (e *ConfigurationError) Retryable() bool
func (*ConfigurationError) StatusCode ¶
func (e *ConfigurationError) StatusCode() int
type ContentFilterError ¶
type ContentFilterError struct {
// contains filtered or unexported fields
}
func (*ContentFilterError) RetryAfter ¶
func (*ContentFilterError) StatusCode ¶
func (e *ContentFilterError) StatusCode() int
type ContentKind ¶
type ContentKind string
const ( ContentText ContentKind = "text" ContentImage ContentKind = "image" ContentAudio ContentKind = "audio" ContentDocument ContentKind = "document" ContentToolCall ContentKind = "tool_call" ContentToolResult ContentKind = "tool_result" ContentThinking ContentKind = "thinking" ContentRedThinking ContentKind = "redacted_thinking" )
type ContentPart ¶
type ContentPart struct {
Kind ContentKind `json:"kind"`
Text string `json:"text,omitempty"`
Image *ImageData `json:"image,omitempty"`
Audio *AudioData `json:"audio,omitempty"`
Document *DocumentData `json:"document,omitempty"`
ToolCall *ToolCallData `json:"tool_call,omitempty"`
ToolResult *ToolResultData `json:"tool_result,omitempty"`
Thinking *ThinkingData `json:"thinking,omitempty"`
// Data carries provider-specific payload for custom content kinds.
Data any `json:"data,omitempty"`
}
type ContextLengthError ¶
type ContextLengthError struct {
// contains filtered or unexported fields
}
func (*ContextLengthError) RetryAfter ¶
func (*ContextLengthError) StatusCode ¶
func (e *ContextLengthError) StatusCode() int
type DocumentData ¶
type EnvAdapterFactory ¶
type EnvAdapterFactory func() (adapter ProviderAdapter, configured bool, err error)
type Error ¶
type Error interface {
error
Provider() string
StatusCode() int
Retryable() bool
RetryAfter() *time.Duration
}
Error is the unified error interface returned by provider adapters and the client.
type FinishReason ¶
func NormalizeFinishReason ¶
func NormalizeFinishReason(provider, raw string) FinishReason
NormalizeFinishReason maps provider-specific finish reason strings to canonical values while preserving the provider raw value.
type GenerateObjectOptions ¶
type GenerateObjectOptions struct {
GenerateOptions
Schema map[string]any
Strict bool
}
type GenerateOptions ¶
type GenerateOptions struct {
Client *Client
Model string
Provider string
Prompt *string
Messages []Message
System *string
Tools []Tool
ToolChoice *ToolChoice
// MaxToolRounds is the maximum number of tool-execution rounds.
// Nil means use the spec default (1).
// A value of 0 disables automatic tool execution (passive tool mode).
MaxToolRounds *int
ResponseFormat *ResponseFormat
Temperature *float64
TopP *float64
MaxTokens *int
StopSequences []string
ReasoningEffort *string
Metadata map[string]string
ProviderOptions map[string]any
// Retry policy for each individual LLM call within generate().
RetryPolicy *RetryPolicy
Sleep SleepFunc
// Optional timeouts for the multi-step operation.
TimeoutTotal time.Duration
TimeoutPerStep time.Duration
}
type GenerateResult ¶
type GenerateResult struct {
Text string
Reasoning string
ToolCalls []ToolCallData
ToolResults []ToolResultData
FinishReason FinishReason
Usage Usage
TotalUsage Usage
Steps []StepResult
Response Response
Output any
}
func Generate ¶
func Generate(ctx context.Context, opts GenerateOptions) (*GenerateResult, error)
func GenerateObject ¶
func GenerateObject(ctx context.Context, opts GenerateObjectOptions) (*GenerateResult, error)
type InvalidRequestError ¶
type InvalidRequestError struct {
// contains filtered or unexported fields
}
func (*InvalidRequestError) RetryAfter ¶
func (*InvalidRequestError) StatusCode ¶
func (e *InvalidRequestError) StatusCode() int
type InvalidToolCallError ¶
type InvalidToolCallError struct {
// contains filtered or unexported fields
}
func (*InvalidToolCallError) RetryAfter ¶
func (*InvalidToolCallError) StatusCode ¶
func (e *InvalidToolCallError) StatusCode() int
type Message ¶
type Message struct {
Role Role `json:"role"`
Content []ContentPart `json:"content"`
Name string `json:"name,omitempty"`
ToolCallID string `json:"tool_call_id,omitempty"`
}
func ToolResultNamed ¶
type Middleware ¶
type Middleware interface {
WrapComplete(next CompleteFunc) CompleteFunc
WrapStream(next StreamFunc) StreamFunc
}
Middleware wraps provider calls for cross-cutting concerns. Middleware is applied in registration order for the request phase and in reverse order for the response/event phase.
type MiddlewareFunc ¶
type MiddlewareFunc struct {
Complete func(ctx context.Context, req Request, next CompleteFunc) (Response, error)
Stream func(ctx context.Context, req Request, next StreamFunc) (Stream, error)
}
func (MiddlewareFunc) WrapComplete ¶
func (m MiddlewareFunc) WrapComplete(next CompleteFunc) CompleteFunc
func (MiddlewareFunc) WrapStream ¶
func (m MiddlewareFunc) WrapStream(next StreamFunc) StreamFunc
type ModelCatalog ¶
type ModelCatalog struct {
Models []ModelInfo
// contains filtered or unexported fields
}
func LoadModelCatalogFromOpenRouterJSON ¶
func LoadModelCatalogFromOpenRouterJSON(path string) (*ModelCatalog, error)
LoadModelCatalogFromOpenRouterJSON loads model metadata from OpenRouter's /api/v1/models payload shape: {"data":[...]}.
func (*ModelCatalog) GetLatestModel ¶
func (c *ModelCatalog) GetLatestModel(provider string, capability string) *ModelInfo
func (*ModelCatalog) GetModelInfo ¶
func (c *ModelCatalog) GetModelInfo(modelID string) *ModelInfo
func (*ModelCatalog) ListModels ¶
func (c *ModelCatalog) ListModels(provider string) []ModelInfo
type ModelInfo ¶
type ModelInfo struct {
ID string `json:"id"`
Provider string `json:"provider"`
DisplayName string `json:"display_name"`
ContextWindow int `json:"context_window"`
MaxOutputTokens *int `json:"max_output_tokens,omitempty"`
SupportsTools bool `json:"supports_tools"`
SupportsVision bool `json:"supports_vision"`
SupportsReasoning bool `json:"supports_reasoning"`
InputCostPerMillion *float64 `json:"input_cost_per_million,omitempty"`
OutputCostPerMillion *float64 `json:"output_cost_per_million,omitempty"`
Aliases []string `json:"aliases,omitempty"`
}
ModelInfo is the normalized model metadata entry, primarily sourced from OpenRouter model info in Kilroy. This is metadata-only and is not used as a provider call path.
type NetworkError ¶
type NetworkError struct {
// contains filtered or unexported fields
}
func (*NetworkError) RetryAfter ¶
func (*NetworkError) StatusCode ¶
func (e *NetworkError) StatusCode() int
type NoObjectGeneratedError ¶
type NoObjectGeneratedError struct {
RawText string
// contains filtered or unexported fields
}
func (*NoObjectGeneratedError) RetryAfter ¶
func (*NoObjectGeneratedError) StatusCode ¶
func (e *NoObjectGeneratedError) StatusCode() int
type NotFoundError ¶
type NotFoundError struct {
// contains filtered or unexported fields
}
func (*NotFoundError) RetryAfter ¶
func (*NotFoundError) StatusCode ¶
func (e *NotFoundError) StatusCode() int
type ProviderAdapter ¶
type ProviderExecutionPolicy ¶
type ProviderExecutionPolicy struct {
ForceStream bool
MinMaxTokens int
MaxMaxTokens int
Reason string
}
func ExecutionPolicy ¶
func ExecutionPolicy(provider, model string) ProviderExecutionPolicy
type ProviderToolLifecycle ¶
type ProviderToolLifecycle struct {
ToolName string
CallID string
ArgumentsJSON string
FullOutput string
Completed bool
IsError bool
}
ProviderToolLifecycle captures provider-native tool lifecycle events that can be surfaced through generic progress telemetry.
func ParseCodexAppServerToolLifecycle ¶
func ParseCodexAppServerToolLifecycle(ev StreamEvent) (ProviderToolLifecycle, bool)
ParseCodexAppServerToolLifecycle maps codex-app-server item lifecycle provider events into a normalized tool lifecycle shape.
type ProviderToolOutputDelta ¶
ProviderToolOutputDelta captures provider-native streamed tool output chunks.
func ParseCodexAppServerToolOutputDelta ¶
func ParseCodexAppServerToolOutputDelta(ev StreamEvent) (ProviderToolOutputDelta, bool)
ParseCodexAppServerToolOutputDelta maps codex-app-server output/progress notifications into normalized tool output deltas.
type QuotaExceededError ¶
type QuotaExceededError struct {
// contains filtered or unexported fields
}
func (*QuotaExceededError) RetryAfter ¶
func (*QuotaExceededError) StatusCode ¶
func (e *QuotaExceededError) StatusCode() int
type RateLimitError ¶
type RateLimitError struct {
// contains filtered or unexported fields
}
func (*RateLimitError) RetryAfter ¶
func (*RateLimitError) StatusCode ¶
func (e *RateLimitError) StatusCode() int
type RateLimitInfo ¶
type RateLimitInfo struct {
RequestsRemaining *int `json:"requests_remaining,omitempty"`
RequestsLimit *int `json:"requests_limit,omitempty"`
TokensRemaining *int `json:"tokens_remaining,omitempty"`
TokensLimit *int `json:"tokens_limit,omitempty"`
ResetAt string `json:"reset_at,omitempty"`
}
func ParseRateLimitInfo ¶
func ParseRateLimitInfo(headers http.Header, now time.Time) *RateLimitInfo
ParseRateLimitInfo extracts informational rate limit metadata from response headers. The result is best-effort and intended for observability, not proactive throttling.
type Request ¶
type Request struct {
Model string `json:"model"`
Provider string `json:"provider,omitempty"`
Messages []Message `json:"messages"`
Tools []ToolDefinition `json:"tools,omitempty"`
ToolChoice *ToolChoice `json:"tool_choice,omitempty"`
ResponseFormat *ResponseFormat `json:"response_format,omitempty"`
Temperature *float64 `json:"temperature,omitempty"`
TopP *float64 `json:"top_p,omitempty"`
MaxTokens *int `json:"max_tokens,omitempty"`
StopSequences []string `json:"stop_sequences,omitempty"`
ReasoningEffort *string `json:"reasoning_effort,omitempty"` // low|medium|high|none
Metadata map[string]string `json:"metadata,omitempty"`
ProviderOptions map[string]any `json:"provider_options,omitempty"`
}
func ApplyExecutionPolicy ¶
func ApplyExecutionPolicy(req Request, policy ProviderExecutionPolicy) Request
type RequestTimeoutError ¶
type RequestTimeoutError struct {
// contains filtered or unexported fields
}
func (*RequestTimeoutError) RetryAfter ¶
func (*RequestTimeoutError) StatusCode ¶
func (e *RequestTimeoutError) StatusCode() int
type Response ¶
type Response struct {
ID string `json:"id"`
Model string `json:"model"`
Provider string `json:"provider"`
Message Message `json:"message"`
Finish FinishReason `json:"finish_reason"`
Usage Usage `json:"usage"`
Raw map[string]any `json:"raw,omitempty"`
Warnings []Warning `json:"warnings,omitempty"`
RateLimit *RateLimitInfo `json:"rate_limit,omitempty"`
}
func (Response) ReasoningText ¶
func (Response) ToolCalls ¶
func (r Response) ToolCalls() []ToolCallData
type ResponseFormat ¶
type RetryPolicy ¶
type RetryPolicy struct {
// MaxRetries is the number of retry attempts (not counting the initial attempt).
MaxRetries int
// BaseDelay is the delay before the first retry attempt.
BaseDelay time.Duration
// MaxDelay caps the delay between retries.
MaxDelay time.Duration
// BackoffMultiplier controls exponential backoff growth (2.0 = double each retry).
BackoffMultiplier float64
// Jitter adds randomness to delays to reduce thundering-herd retries.
Jitter bool
// OnRetry is invoked before sleeping for a retry attempt.
OnRetry func(err error, attempt int, delay time.Duration)
}
func DefaultRetryPolicy ¶
func DefaultRetryPolicy() RetryPolicy
type ServerError ¶
type ServerError struct {
// contains filtered or unexported fields
}
func (*ServerError) RetryAfter ¶
func (*ServerError) StatusCode ¶
func (e *ServerError) StatusCode() int
type StepResult ¶
type StepResult struct {
Text string
Reasoning string
ToolCalls []ToolCallData
ToolResults []ToolResultData
FinishReason FinishReason
Usage Usage
Response Response
Warnings []Warning
}
type Stream ¶
type Stream interface {
Events() <-chan StreamEvent
Close() error
}
Stream is an asynchronous iterator of StreamEvent values. Implementations must be explicitly closed when the consumer is done to avoid leaking connections.
type StreamAccumulator ¶
type StreamAccumulator struct {
// contains filtered or unexported fields
}
StreamAccumulator collects StreamEvent values and produces a complete Response. It primarily exists to bridge streaming mode back to code that expects a Response.
func NewStreamAccumulator ¶
func NewStreamAccumulator() *StreamAccumulator
func (*StreamAccumulator) PartialResponse ¶
func (a *StreamAccumulator) PartialResponse() *Response
PartialResponse returns the best-effort accumulated response so far (may be nil).
func (*StreamAccumulator) Process ¶
func (a *StreamAccumulator) Process(ev StreamEvent)
func (*StreamAccumulator) Response ¶
func (a *StreamAccumulator) Response() *Response
Response returns the final accumulated response after FINISH, or nil if the stream has not completed.
type StreamError ¶
type StreamError struct {
// contains filtered or unexported fields
}
func (*StreamError) RetryAfter ¶
func (*StreamError) StatusCode ¶
func (e *StreamError) StatusCode() int
type StreamEvent ¶
type StreamEvent struct {
Type StreamEventType `json:"type"`
// Stream start metadata
ID string `json:"id,omitempty"`
Model string `json:"model,omitempty"`
Warnings []Warning `json:"warnings,omitempty"`
// Text events
Delta string `json:"delta,omitempty"`
TextID string `json:"text_id,omitempty"`
// Reasoning events
ReasoningDelta string `json:"reasoning_delta,omitempty"`
ReasoningID string `json:"reasoning_id,omitempty"`
Redacted *bool `json:"redacted,omitempty"`
// Tool call events
ToolCall *ToolCallData `json:"tool_call,omitempty"`
// Finish event
FinishReason *FinishReason `json:"finish_reason,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Response *Response `json:"response,omitempty"`
// Error event
Err error `json:"-"`
// Passthrough
EventType string `json:"event_type,omitempty"`
Raw map[string]any `json:"raw,omitempty"`
}
type StreamEventType ¶
type StreamEventType string
const ( StreamEventStreamStart StreamEventType = "STREAM_START" StreamEventTextStart StreamEventType = "TEXT_START" StreamEventTextDelta StreamEventType = "TEXT_DELTA" StreamEventTextEnd StreamEventType = "TEXT_END" StreamEventReasoningStart StreamEventType = "REASONING_START" StreamEventReasoningDelta StreamEventType = "REASONING_DELTA" StreamEventReasoningEnd StreamEventType = "REASONING_END" StreamEventToolCallStart StreamEventType = "TOOL_CALL_START" StreamEventToolCallDelta StreamEventType = "TOOL_CALL_DELTA" StreamEventToolCallEnd StreamEventType = "TOOL_CALL_END" StreamEventStepFinish StreamEventType = "STEP_FINISH" StreamEventFinish StreamEventType = "FINISH" StreamEventError StreamEventType = "ERROR" StreamEventProviderEvent StreamEventType = "PROVIDER_EVENT" )
type StreamResult ¶
type StreamResult struct {
// contains filtered or unexported fields
}
StreamResult is the high-level streaming generation result. It yields StreamEvent values over Events() and exposes the accumulated final response once the stream ends.
func StreamGenerate ¶
func StreamGenerate(ctx context.Context, opts GenerateOptions) (*StreamResult, error)
StreamGenerate is the high-level streaming API (spec stream()). It is equivalent to Generate(), but yields StreamEvent values incrementally and continues across tool-execution steps. Between tool steps it emits a STEP_FINISH event.
func (*StreamResult) Close ¶
func (r *StreamResult) Close() error
func (*StreamResult) Events ¶
func (r *StreamResult) Events() <-chan StreamEvent
func (*StreamResult) PartialResponse ¶
func (r *StreamResult) PartialResponse() *Response
func (*StreamResult) Response ¶
func (r *StreamResult) Response() (*Response, error)
type ThinkingData ¶
type ToolCallData ¶
type ToolCallData struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"` // raw JSON object
Type string `json:"type,omitempty"` // usually "function"
// ThoughtSignature carries provider-specific thought-signature state (e.g., Gemini)
// required to continue tool-calling turns safely.
ThoughtSignature string `json:"thought_signature,omitempty"`
}
type ToolChoice ¶
type ToolDefinition ¶
type ToolResultData ¶
type UnknownHTTPError ¶
type UnknownHTTPError struct {
// contains filtered or unexported fields
}
func (*UnknownHTTPError) RetryAfter ¶
func (*UnknownHTTPError) StatusCode ¶
func (e *UnknownHTTPError) StatusCode() int
type UnsupportedToolChoiceError ¶
type UnsupportedToolChoiceError struct {
// contains filtered or unexported fields
}
func (*UnsupportedToolChoiceError) Provider ¶
func (e *UnsupportedToolChoiceError) Provider() string
func (*UnsupportedToolChoiceError) RetryAfter ¶
func (*UnsupportedToolChoiceError) Retryable ¶
func (e *UnsupportedToolChoiceError) Retryable() bool
func (*UnsupportedToolChoiceError) StatusCode ¶
func (e *UnsupportedToolChoiceError) StatusCode() int
type Usage ¶
type Usage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
TotalTokens int `json:"total_tokens"`
ReasoningTokens *int `json:"reasoning_tokens,omitempty"`
CacheReadTokens *int `json:"cache_read_tokens,omitempty"`
CacheWriteTokens *int `json:"cache_write_tokens,omitempty"`
Raw map[string]any `json:"raw,omitempty"`
}
Source Files
¶
- chan_stream.go
- client.go
- context_errors.go
- env_registry.go
- errors.go
- generate.go
- generate_object.go
- media_utils.go
- middleware.go
- model_catalog.go
- provider_event_codex.go
- provider_execution_policy.go
- rate_limit.go
- retry.go
- retry_util.go
- sdk_errors.go
- sse.go
- stream.go
- stream_accumulator.go
- stream_generate.go
- tool_validation.go
- types.go