Documentation
¶
Overview ¶
Package model provides a centralised registry of LLM model metadata: context windows, pricing, and capability flags (vision, audio, etc.).
Consumption pattern:
meta, ok := model.Global.Lookup(modelID)
if ok && meta.Capabilities.Vision {
// attach image content
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Global = NewRegistry()
Global is the package-level registry. It starts empty and is populated at startup by internal/providers (model_sync.go init), which is the single source of truth for model metadata. Tests may construct their own registry with NewRegistry().
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
type Capabilities struct {
// Vision indicates the model can process image content blocks.
Vision bool
// Audio indicates the model can process audio content.
Audio bool
// FunctionCalling indicates tool/function-call support.
FunctionCalling bool
// Streaming indicates server-sent-event streaming support.
Streaming bool
// PromptCaching indicates provider-level prompt caching support.
PromptCaching bool
// StructuredOutput indicates native JSON schema output support.
StructuredOutput bool
}
Capabilities describes what a specific model variant can do.
type ContextWindow ¶
type ContextWindow struct {
// MaxTokens is the maximum combined input+output tokens.
MaxTokens int
// MaxOutputTokens is the cap on generated tokens per call.
MaxOutputTokens int
}
ContextWindow describes the token budget for a model.
type Metadata ¶
type Metadata struct {
// ID is the canonical model identifier string (e.g. "claude-3-5-sonnet-20241022").
ID string
// Provider is the upstream provider name (e.g. "anthropic").
Provider string
// Description is a human-readable summary.
Description string
// ContextWindow contains token budget information.
ContextWindow ContextWindow
// DefaultTemperature is the provider-recommended sampling temperature.
DefaultTemperature float64
// Capabilities lists what the model supports.
Capabilities Capabilities
// Pricing holds per-token cost data (zero = unknown).
Pricing Pricing
}
Metadata aggregates all model-level metadata.
type Pricing ¶
type Pricing struct {
// InputPerMTok is the cost for input (prompt) tokens.
InputPerMTok float64
// OutputPerMTok is the cost for output (completion) tokens.
OutputPerMTok float64
// CacheReadPerMTok is the discounted cost for cache-hit input tokens.
CacheReadPerMTok float64
// CacheWritePerMTok is the premium charged when writing to the prompt cache.
CacheWritePerMTok float64
}
Pricing holds per-token costs in USD per 1 million tokens (MTok). Zero values mean pricing is unknown or not applicable.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is a lookup table from (provider, modelID) → Metadata. It is safe for concurrent reads; writes happen only at init time via Register or the package-level Global variable.
func (*Registry) ContextWindowFor ¶
func (r *Registry) ContextWindowFor(provider, modelID string) ContextWindow
ContextWindowFor returns the ContextWindow for the given (provider, modelID), or (128000, 4096) as a conservative default when the model is unknown.
func (*Registry) Lookup ¶
Lookup returns the Metadata for a (provider, modelID) pair. provider may be empty to fall back to a model-ID-only search across all providers.
func (*Registry) VisionCapable ¶
VisionCapable returns true when the model supports image content blocks.