Documentation
¶
Index ¶
- Constants
- func CanonicalProviderID(providerID string) string
- func DefaultReasoningEffortForModel(providerID string, providerType string, modelID string) string
- func DefaultReasoningEffortForProvider(providerID string, providerType string) string
- func NormalizeModelID(providerID string, providerType string, modelID string) string
- func NormalizeOptionalProviderType(providerType string) string
- func NormalizeProviderID(value string) string
- func NormalizeProviderType(providerType string) string
- func NormalizeReasoningEffort(value string) string
- func NormalizeReasoningEffortForModel(providerID string, providerType string, modelID string, value string) string
- func NormalizeReasoningEffortForProvider(providerID string, providerType string, value string) string
- func NormalizeToolSchema(schema json.RawMessage, dialect ToolSchemaDialect) json.RawMessage
- func ProviderRequiresAPIKey(providerID string, providerType string) bool
- func ReasoningEfforts() []string
- func ReasoningEffortsForModel(providerID string, providerType string, modelID string) []string
- func ReasoningEffortsForProvider(providerID string, providerType string) []string
- func RegisterContextWindowTokens(providerID string, providerType string, modelID string, tokens int)
- func RegisterModelMetadata(providerID string, providerType string, modelID string, ...)
- func ResolveContextWindowTokens(providerID string, providerType string, modelID string) int
- func RuntimeProviderTypeFor(providerID string, providerType string) string
- func RuntimeProviderTypeForTransport(transport ProviderTransport, providerType string) string
- func ScanSSE(ctx context.Context, body io.Reader, handle func(SSEEvent) error) error
- func StreamText(ctx context.Context, delta string) error
- func WithTextStream(ctx context.Context, fn TextStreamFunc) context.Context
- type BaseURLOption
- type Capabilities
- type CatalogEntry
- type ImageContent
- type Message
- type ModelCapabilities
- type ModelCapabilityInput
- type ModelCapabilitySet
- type ModelMetadata
- type ModelMetadataRegistration
- type ModelMetadataSource
- type OpenAIChatMaxTokensField
- type OpenAIChatOptions
- type OpenAIChatRequestQuirks
- type ProviderAuthMode
- type ProviderPolicy
- type ProviderProfile
- type ProviderSpec
- type ProviderTransport
- type ReasoningMode
- type Request
- type Response
- type Runtime
- type RuntimeCapabilityProvider
- type RuntimeProfile
- type RuntimeProfiler
- type SSEEvent
- type TextStreamFunc
- type ToolCall
- type ToolDefinition
- type ToolSchemaDialect
- type ToolUseMode
- type Usage
Constants ¶
View Source
const ( TypeOpenAICompat = "openai-compatible" TypeOpenAICodex = "openai-codex" TypeAnthropic = "anthropic-compatible" TypeGemini = "gemini" DefaultOpenAICompatModel = "gpt-5.4-mini" DefaultOpenAICodexModel = "gpt-5.4" DefaultAnthropicModel = "claude-sonnet-4-5" DefaultGeminiModel = "gemini-2.5-flash" DefaultReasoningEffort = "medium" )
View Source
const ( ReasoningEffortNone = "none" ReasoningEffortMinimal = "minimal" ReasoningEffortLow = "low" ReasoningEffortMedium = DefaultReasoningEffort ReasoningEffortHigh = "high" ReasoningEffortXHigh = "xhigh" )
View Source
const DefaultFallbackContextWindowTokens = 256_000
Variables ¶
This section is empty.
Functions ¶
func CanonicalProviderID ¶ added in v0.1.11
func DefaultReasoningEffortForModel ¶ added in v0.1.4
func NormalizeModelID ¶
func NormalizeOptionalProviderType ¶ added in v0.1.5
func NormalizeProviderID ¶
func NormalizeProviderType ¶ added in v0.1.5
func NormalizeReasoningEffortForModel ¶ added in v0.1.4
func NormalizeToolSchema ¶
func NormalizeToolSchema(schema json.RawMessage, dialect ToolSchemaDialect) json.RawMessage
func ProviderRequiresAPIKey ¶ added in v0.1.11
func ReasoningEfforts ¶
func ReasoningEfforts() []string
func ReasoningEffortsForModel ¶ added in v0.1.4
func ReasoningEffortsForProvider ¶ added in v0.1.1
func RegisterContextWindowTokens ¶ added in v0.1.10
func RegisterModelMetadata ¶ added in v0.1.11
func RegisterModelMetadata(providerID string, providerType string, modelID string, metadata ModelMetadataRegistration)
func ResolveContextWindowTokens ¶ added in v0.1.10
func RuntimeProviderTypeFor ¶ added in v0.1.11
func RuntimeProviderTypeForTransport ¶ added in v0.1.11
func RuntimeProviderTypeForTransport(transport ProviderTransport, providerType string) string
func StreamText ¶
StreamText forwards a streamed text delta to the sink attached to ctx.
func WithTextStream ¶
func WithTextStream(ctx context.Context, fn TextStreamFunc) context.Context
WithTextStream attaches an optional text delta sink to the request context.
Types ¶
type BaseURLOption ¶ added in v0.1.1
type Capabilities ¶
type Capabilities struct {
ModelDiscovery bool `json:"model_discovery,omitempty"`
ReasoningEffort bool `json:"reasoning_effort,omitempty"`
ToolCalling bool `json:"tool_calling,omitempty"`
NormalizeModel bool `json:"normalize_model,omitempty"`
}
func ProviderCapabilities ¶ added in v0.1.1
func ProviderCapabilities(providerID string, providerType string) Capabilities
type CatalogEntry ¶
type CatalogEntry struct {
ID string `json:"id"`
CatalogID string `json:"catalog_id,omitempty"`
Name string `json:"name"`
Type string `json:"type"`
Implemented bool `json:"implemented"`
RequiresBaseURL bool `json:"requires_base_url"`
Capabilities Capabilities `json:"capabilities"`
DefaultBaseURL string `json:"default_base_url,omitempty"`
BaseURLOptions []BaseURLOption `json:"base_url_options,omitempty"`
DefaultModel string `json:"default_model,omitempty"`
APIKeyEnv string `json:"api_key_env,omitempty"`
Notes string `json:"notes,omitempty"`
}
func AvailableCatalog ¶
func AvailableCatalog() []CatalogEntry
func Catalog ¶
func Catalog() []CatalogEntry
func CatalogEntryByID ¶
func CatalogEntryByID(providerID string) (CatalogEntry, bool)
type ImageContent ¶
type Message ¶
type Message struct {
Role string
Content string
ReasoningContent *string
Images []ImageContent
ToolCallID string
ToolCalls []ToolCall
}
func NormalizeMessages ¶
func NormalizeMessages(messages []Message, mode ToolUseMode) []Message
type ModelCapabilities ¶ added in v0.1.1
type ModelCapabilities struct {
ToolCalling bool
ToolSchemaDialect ToolSchemaDialect
ParallelToolCalls bool
ReasoningEffort bool
ReasoningMode ReasoningMode
ReasoningWithTools bool
ThoughtSignatures bool
NormalizeModel bool
}
func ModelRuntimeCapabilities ¶ added in v0.1.4
func ModelRuntimeCapabilities(providerID string, providerType string, modelID string) ModelCapabilities
func ProviderRuntimeCapabilities ¶ added in v0.1.2
func ProviderRuntimeCapabilities(providerID string, providerType string) ModelCapabilities
type ModelCapabilityInput ¶ added in v0.1.4
type ModelCapabilitySet ¶ added in v0.1.4
type ModelCapabilitySet struct {
ProviderCapabilities Capabilities
RuntimeCapabilities ModelCapabilities
ReasoningEfforts []string
DefaultReasoningEffort string
}
func ResolveModelCapabilities ¶ added in v0.1.1
func ResolveModelCapabilities(input ModelCapabilityInput) ModelCapabilitySet
type ModelMetadata ¶ added in v0.1.11
type ModelMetadata struct {
ID string `json:"id,omitempty"`
ContextWindow int `json:"context_window,omitempty"`
ToolCalling bool `json:"tool_calling,omitempty"`
ParallelToolCalls bool `json:"parallel_tool_calls,omitempty"`
ReasoningEffort bool `json:"reasoning_effort,omitempty"`
ReasoningMode ReasoningMode `json:"reasoning_mode,omitempty"`
ReasoningWithTools bool `json:"reasoning_with_tools,omitempty"`
ReasoningEfforts []string `json:"reasoning_efforts,omitempty"`
DefaultReasoningEffort string `json:"default_reasoning_effort,omitempty"`
SupportedParameters []string `json:"supported_parameters,omitempty"`
Source ModelMetadataSource `json:"source,omitempty"`
ContextSource ModelMetadataSource `json:"context_source,omitempty"`
CapabilitySource ModelMetadataSource `json:"capability_source,omitempty"`
}
func ResolveModelMetadata ¶ added in v0.1.11
func ResolveModelMetadata(providerID string, providerType string, modelID string) ModelMetadata
type ModelMetadataRegistration ¶ added in v0.1.11
type ModelMetadataSource ¶ added in v0.1.11
type ModelMetadataSource string
const ( ModelMetadataSourceLiveCatalog ModelMetadataSource = "live_catalog" ModelMetadataSourceStaticRule ModelMetadataSource = "static_rule" ModelMetadataSourceFallback ModelMetadataSource = "fallback" )
type OpenAIChatMaxTokensField ¶ added in v0.1.11
type OpenAIChatMaxTokensField string
const ( OpenAIChatMaxTokensAuto OpenAIChatMaxTokensField = "" OpenAIChatMaxTokens OpenAIChatMaxTokensField = "max_tokens" OpenAIChatMaxCompletionTokens OpenAIChatMaxTokensField = "max_completion_tokens" )
type OpenAIChatOptions ¶ added in v0.1.11
type OpenAIChatOptions struct {
DefaultHeaders map[string]string
MaxTokensField OpenAIChatMaxTokensField
RequestQuirks OpenAIChatRequestQuirks
}
func ResolveOpenAIChatOptions ¶ added in v0.1.11
func ResolveOpenAIChatOptions(profile ProviderProfile, baseURL string, model string) OpenAIChatOptions
type OpenAIChatRequestQuirks ¶ added in v0.1.11
type ProviderAuthMode ¶ added in v0.1.11
type ProviderAuthMode string
const ( ProviderAuthAPIKey ProviderAuthMode = "api_key" ProviderAuthOAuth ProviderAuthMode = "oauth" ProviderAuthExternal ProviderAuthMode = "external" )
func ProviderAuthModeFor ¶ added in v0.1.11
func ProviderAuthModeFor(providerID string, providerType string) ProviderAuthMode
type ProviderPolicy ¶ added in v0.1.11
type ProviderPolicy struct {
RequestedID string
CatalogID string
Known bool
Implemented bool
Name string
Type string
AuthMode ProviderAuthMode
RequiresAPIKey bool
AuthStatusLabel string
Transport ProviderTransport
RuntimeProviderType string
RequiresBaseURL bool
Capabilities Capabilities
ModelsURL string
PublicModelCatalog bool
SupportsHealthCheck bool
OpenAIChat OpenAIChatOptions
DefaultBaseURL string
BaseURLOptions []BaseURLOption
DefaultModel string
APIKeyEnv string
Notes string
}
func PolicyForProvider ¶ added in v0.1.11
func PolicyForProvider(providerID string, providerType string) ProviderPolicy
type ProviderProfile ¶
type ProviderProfile struct {
ProviderID string
Model string
ProviderType string
RuntimeProviderType string
AuthMode ProviderAuthMode
Transport ProviderTransport
RuntimeProfile RuntimeProfile
Capabilities ModelCapabilities
SupportsReasoningEffort bool
OpenAIChat OpenAIChatOptions
}
func ProfileForModel ¶ added in v0.1.1
func ProfileForModel(providerID string, providerType string, modelID string) ProviderProfile
func ProfileForProvider ¶
func ProfileForProvider(providerType string) ProviderProfile
func (ProviderProfile) IsZero ¶ added in v0.1.11
func (p ProviderProfile) IsZero() bool
func (ProviderProfile) RuntimeProfileWithOverrides ¶
func (p ProviderProfile) RuntimeProfileWithOverrides(profile RuntimeProfile) RuntimeProfile
type ProviderSpec ¶ added in v0.1.11
type ProviderSpec struct {
Order int
Entry CatalogEntry
Aliases []string
Auth ProviderAuthMode
Transport ProviderTransport
RuntimeProviderType string
ModelsURL string
PublicModelCatalog bool
DisableHealthCheck bool
OpenAIChat OpenAIChatOptions
}
func ProviderSpecByID ¶ added in v0.1.11
func ProviderSpecByID(providerID string) (ProviderSpec, bool)
func ProviderSpecs ¶ added in v0.1.11
func ProviderSpecs() []ProviderSpec
type ProviderTransport ¶ added in v0.1.11
type ProviderTransport string
const ( ProviderTransportOpenAIChat ProviderTransport = "openai_chat" ProviderTransportOpenAIResponses ProviderTransport = "openai_responses" ProviderTransportAnthropicMessage ProviderTransport = "anthropic_messages" ProviderTransportGeminiNative ProviderTransport = "gemini_native" )
func ProviderTransportFor ¶ added in v0.1.11
func ProviderTransportFor(providerID string, providerType string) ProviderTransport
type ReasoningMode ¶ added in v0.1.1
type ReasoningMode string
const ( ReasoningModeNone ReasoningMode = "" ReasoningModeOpenAIEffort ReasoningMode = "openai_effort" ReasoningModeGeminiThinking ReasoningMode = "gemini_thinking" )
type Request ¶
type Request struct {
RunID string
SessionID string
SystemPrompt string
CustomInstructions string
Messages []Message
Tools []ToolDefinition
}
func NormalizeRequest ¶
func NormalizeRequest(request Request, profile RuntimeProfile) Request
type RuntimeCapabilityProvider ¶ added in v0.1.1
type RuntimeCapabilityProvider interface {
ModelCapabilities() ModelCapabilities
}
type RuntimeProfile ¶
type RuntimeProfile struct {
ToolSchemaDialect ToolSchemaDialect
ToolUseMode ToolUseMode
}
func NormalizeRuntimeProfile ¶
func NormalizeRuntimeProfile(profile RuntimeProfile) RuntimeProfile
type RuntimeProfiler ¶
type RuntimeProfiler interface {
RuntimeProfile() RuntimeProfile
}
type TextStreamFunc ¶
func TextStreamFromContext ¶
func TextStreamFromContext(ctx context.Context) TextStreamFunc
TextStreamFromContext returns the text delta sink attached to ctx, if any.
type ToolCall ¶
type ToolCall struct {
ID string `json:"id"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
type ToolDefinition ¶
type ToolDefinition struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
InputSchema json.RawMessage `json:"input_schema,omitempty"`
}
func NormalizeTools ¶
func NormalizeTools(tools []ToolDefinition, dialect ToolSchemaDialect, mode ToolUseMode) []ToolDefinition
type ToolSchemaDialect ¶
type ToolSchemaDialect string
const ( ToolSchemaJSONSchema ToolSchemaDialect = "json_schema" ToolSchemaGemini ToolSchemaDialect = "gemini" )
func NormalizeToolSchemaDialect ¶
func NormalizeToolSchemaDialect(value ToolSchemaDialect) ToolSchemaDialect
type ToolUseMode ¶
type ToolUseMode string
const ( ToolUseNative ToolUseMode = "native" ToolUseDisabled ToolUseMode = "disabled" )
func NormalizeOptionalToolUseMode ¶
func NormalizeOptionalToolUseMode(value ToolUseMode) ToolUseMode
func NormalizeToolUseMode ¶
func NormalizeToolUseMode(value ToolUseMode) ToolUseMode
Source Files
¶
- catalog.go
- context_window.go
- context_window_cache.go
- contract.go
- model_capabilities.go
- model_metadata.go
- openai_chat_options.go
- policy.go
- provider_anthropic.go
- provider_gemini.go
- provider_openai.go
- provider_openai_compatible_gateways.go
- provider_profile.go
- provider_qwen.go
- provider_specs_helpers.go
- registry.go
- request_normalize.go
- schema_normalize.go
- sse.go
- stream.go
Click to show internal directories.
Click to hide internal directories.