model

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 4 Imported by: 0

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

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.

func Register added in v0.2.0

func Register(id ID, cfg Config)

Register adds or replaces a runtime Config for id.

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

func ForModel(m ID) Config

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

func Lookup(id ID) (Config, bool)

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.

func (Config) SupportsReasoning added in v0.2.0

func (c Config) SupportsReasoning() bool

SupportsReasoning reports whether the model supports reasoning. It returns true when ReasoningEfforts is non-empty.

type Entry

type Entry struct {
	Model  ID
	Config Config
}

Entry pairs a model identifier with its Config for use in listings.

func List

func List() []Entry

List returns every runtime-registered model (see Register) as a slice of Entry values, sorted by identifier for a deterministic order. Runtime entries have no inherent ordering of their own, unlike the old static display order this replaced.

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.

type ID

type ID string

ID identifies a model as a bare OpenRouter author/slug (e.g. "anthropic/claude-sonnet-5"). It is a plain string newtype so packages outside internal/provider can reference models without importing any provider SDK.

Source Files

  • adapter.go
  • model.go
  • registry.go

Directories

Path Synopsis
Package modeltest exports the canonical OpenRouter test identifiers and a Register helper that installs canned Configs for them.
Package modeltest exports the canonical OpenRouter test identifiers and a Register helper that installs canned Configs for them.

Jump to

Keyboard shortcuts

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