Documentation
¶
Overview ¶
Package model resolves model identifiers to their context limits, pricing, and reasoning capabilities entirely at runtime.
There is no static registry: every model's Config is registered on demand (via Register) once it is resolved against the OpenRouter catalog — at startup for every model named in settings, and on the fly when the user searches the catalog through the /model command. Unknown models resolve to a zero Config via ForModel; use Lookup where a resolution failure needs to be reported.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Reasoning ¶ added in v0.2.0
func Reasoning(opts GenerationOptions) *components.ChatRequestReasoning
Reasoning maps provider-neutral GenerationOptions to the OpenRouter SDK's ChatRequestReasoning parameter.
An empty Effort disables reasoning entirely, returning nil so callers omit the field from the request rather than sending an explicit "none". A non-empty Effort maps directly to components.ChatRequestEffort.
Types ¶
type Config ¶
type Config struct {
ContextLimit int64 // max input tokens the model accepts per request
MaxTokens int64 // max output tokens per API request
ReasoningEfforts []string // ordered reasoning-effort values the model supports (empty = unsupported)
InputPrice float64 // catalog display: per-million-token input price
OutputPrice float64 // catalog display: per-million-token output price
}
Config holds the operational constraints and billing rates for one model.
ContextLimit is the maximum number of input-side tokens the model accepts in a single request; the TUI uses this to show a context-window fill percentage.
InputPrice and OutputPrice are catalog display metadata only (US dollars per million tokens). They feed the model-search results row; they are never used to compute session cost.
func ForModel ¶
ForModel returns the Config for the requested model.
If the model is not registered — for example an OpenRouter model that failed to resolve, or a stale identifier from before this session's startup resolution ran — it returns a zero Config rather than a plausible-looking fallback. A zero Config fails loudly at request time (MaxTokens 0) instead of silently producing confidently wrong pricing and context figures. This is safe because startup resolution guarantees every model actually configured is registered before a session can use it; callers that need to report a resolution failure explicitly should use Lookup instead.
func Lookup ¶ added in v0.2.0
Lookup returns the Config for id and whether it is registered at runtime (see Register). Callers that can surface a resolution failure to the user should prefer Lookup over ForModel, which returns a zero Config for an unknown identifier rather than reporting the failure.
type Entry ¶
Entry pairs a model identifier with its Config for use in listings.
type GenerationOptions ¶
type GenerationOptions struct {
Effort string
}
GenerationOptions carries provider-neutral generation settings across the provider boundary. Callers outside internal/provider (session, TUI) never need to know which provider a model belongs to.
Effort is the reasoning effort level (e.g. "low", "medium", "high", "max"); an empty string means reasoning is disabled.
Source Files
¶
- adapter.go
- model.go
- registry.go