providers

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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 CanonicalProviderID(providerID string) string

func DefaultReasoningEffortForModel added in v0.1.4

func DefaultReasoningEffortForModel(providerID string, providerType string, modelID string) string

func DefaultReasoningEffortForProvider

func DefaultReasoningEffortForProvider(providerID string, providerType string) string

func NormalizeModelID

func NormalizeModelID(providerID string, providerType string, modelID string) string

func NormalizeOptionalProviderType added in v0.1.5

func NormalizeOptionalProviderType(providerType string) string

func NormalizeProviderID

func NormalizeProviderID(value string) string

func NormalizeProviderType added in v0.1.5

func NormalizeProviderType(providerType string) string

func NormalizeReasoningEffort

func NormalizeReasoningEffort(value string) string

func NormalizeReasoningEffortForModel added in v0.1.4

func NormalizeReasoningEffortForModel(providerID string, providerType string, modelID string, value string) string

func NormalizeReasoningEffortForProvider

func NormalizeReasoningEffortForProvider(providerID string, providerType string, value string) string

func NormalizeToolSchema

func NormalizeToolSchema(schema json.RawMessage, dialect ToolSchemaDialect) json.RawMessage

func ProviderRequiresAPIKey added in v0.1.11

func ProviderRequiresAPIKey(providerID string, providerType string) bool

func ReasoningEfforts

func ReasoningEfforts() []string

func ReasoningEffortsForModel added in v0.1.4

func ReasoningEffortsForModel(providerID string, providerType string, modelID string) []string

func ReasoningEffortsForProvider added in v0.1.1

func ReasoningEffortsForProvider(providerID string, providerType string) []string

func RegisterContextWindowTokens added in v0.1.10

func RegisterContextWindowTokens(providerID string, providerType string, modelID string, tokens int)

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 ResolveContextWindowTokens(providerID string, providerType string, modelID string) int

func RuntimeProviderTypeFor added in v0.1.11

func RuntimeProviderTypeFor(providerID string, providerType string) string

func RuntimeProviderTypeForTransport added in v0.1.11

func RuntimeProviderTypeForTransport(transport ProviderTransport, providerType string) string

func ScanSSE

func ScanSSE(ctx context.Context, body io.Reader, handle func(SSEEvent) error) error

ScanSSE reads SSE frames from body and invokes handle for each event payload.

func StreamText

func StreamText(ctx context.Context, delta string) error

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 BaseURLOption struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

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 ImageContent struct {
	MIMEType    string `json:"mime_type,omitempty"`
	DataBase64  string `json:"data_base64,omitempty"`
	Name        string `json:"name,omitempty"`
	StoragePath string `json:"storage_path,omitempty"`
	Temporary   bool   `json:"temporary,omitempty"`
	Size        int64  `json:"size,omitempty"`
}

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 ModelCapabilityInput struct {
	ProviderID   string
	ProviderType string
	ModelID      string
}

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 ModelMetadataRegistration struct {
	ContextWindow       int
	ToolCalling         *bool
	ReasoningEffort     *bool
	ReasoningEfforts    []string
	SupportedParameters []string
}

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 OpenAIChatRequestQuirks struct {
	RetryUnsupportedReasoningEffort bool
	RetryMaxTokensField             bool
	RetryAssistantReasoningContent  bool
}

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 Response

type Response struct {
	Text             string
	ReasoningContent *string
	Model            string
	Provider         string
	ToolCalls        []ToolCall
	Usage            Usage
}

type Runtime

type Runtime interface {
	Generate(ctx context.Context, request Request) (Response, error)
}

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 SSEEvent

type SSEEvent struct {
	Type string
	Data string
}

type TextStreamFunc

type TextStreamFunc func(delta string) error

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

type Usage

type Usage struct {
	InputTokens     int64
	OutputTokens    int64
	TotalTokens     int64
	CachedTokens    int64
	ReasoningTokens int64
	ProviderRaw     json.RawMessage
}

Directories

Path Synopsis
ai

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL