Versions in this module Expand all Collapse all v1 v1.4.0 Oct 20, 2026 Changes in this version + const ProtocolAnthropic + const ProtocolOpenAI + var ErrCircuitOpen = errors.New("model provider circuit breaker open") + var ErrProviderRejected = errors.New("model provider rejected the request") + var ErrProviderUnavailable = errors.New("model provider unavailable") + var ErrStreamAborted = errors.New("model provider stream aborted after delivery") + func UsageKnownZero(err error) bool + type CapabilityProfile struct + JSONSchema *bool + MaxTokensField string + Reasoning *bool + RequestID *bool + StreamUsage *bool + ToolCalling *bool + Usage *bool + type CircuitAcquire struct + Cooldown time.Duration + Now time.Time + ProbeTTL time.Duration + Provider string + Threshold int + type CircuitBreaker interface + AcquireCircuit func(context.Context, CircuitAcquire) (CircuitPermit, error) + RecordCircuit func(context.Context, CircuitRecord) error + type CircuitPermit struct + ProbeToken string + type CircuitRecord struct + Now time.Time + ProbeToken string + Provider string + Retryable bool + Success bool + Threshold int + type Config struct + APIKey string + APIKeyEnv string + BaseURL string + BreakerCoolMs int64 + BreakerOpens int + Capabilities CapabilityProfile + ExtraHeaders map[string]string + HealthMethod string + HealthPath string + IdempotencyHeader string + MaxAttempts int + MaxConcurrent int + Name string + Protocol string + RetryAmbiguous bool + SupportsIdempotency bool + Timeout time.Duration + TimeoutMs int64 + Tokenizer string + type Executor struct + func NewExecutor(config Config, client *http.Client) *Executor + func (e *Executor) Complete(ctx context.Context, invocation Invocation) (Result, error) + func (e *Executor) Health(ctx context.Context) error + func (e *Executor) Name() string + func (e *Executor) Stream(ctx context.Context, invocation Invocation, onDelta func(string)) (Result, error) + func (e *Executor) StreamObserved(ctx context.Context, invocation Invocation, observer StreamObserver) (Result, error) + func (e *Executor) Tokenizer() string + func (e *Executor) WithCircuitBreaker(shared CircuitBreaker) *Executor + type Invocation struct + AttemptID string + IdempotencyKey string + MaxOutputTokens int32 + Messages []Message + ModelCallID string + ModelName string + Stream bool + TaskID string + Temperature *float64 + Tools []ToolDefinition + TraceID string + type Message struct + Content string + Role string + ToolCallID string + ToolCalls []ToolCall + type Registry struct + func LoadRegistryFile(path string) (*Registry, error) + func NewRegistry() *Registry + func (r *Registry) Names() []string + func (r *Registry) Register(config Config) error + func (r *Registry) RegisterRoute(route Route) error + func (r *Registry) Resolve(name string) (*Executor, error) + func (r *Registry) ResolveModel(modelRef string) (*Executor, string, error) + func (r *Registry) UseCircuitBreaker(breaker CircuitBreaker) + type Result struct + Content string + FinishReason string + InputTokens int64 + OutputTokens int64 + ProviderRequestID string + ToolCalls []ToolCall + UsageReported bool + type Route struct + Model string + ModelRef string + Provider string + type StreamObserver struct + OnContent func(string) + OnGenerated func(string) + OnThinking func(string) + type ToolCall struct + Arguments string + ID string + Name string + type ToolDefinition struct + Description string + Name string + Parameters json.RawMessage