model

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 7 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

Overview

Package model defines the model vendors (Anthropic, OpenAI) and their canonical models: provider-qualified ids, the harnesses each model can be driven by, and per-token pricing.

It is a leaf domain package (it imports no other internal package), so both the controllers and the in-pod agent-runner can share one source of truth for which harness runs a model and what CLI model-id that harness expects. A model's identity (its provider-qualified ID) is independent of the executing harness: the Supported map records the harness-specific CLI id each driver needs, and Preferred names the default driver. The harness package layers resolution (ResolveModel/ValidateAllowlist) on top, filtering by which harnesses are enabled in a given deployment.

Model ids resolve in three tiers (Resolve / Lookup):

  • exact: a registered canonical id ("anthropic/claude-opus-5-5");
  • alias: a family alias with no version ("anthropic/claude-opus") resolves to the newest registered version of that family. Controllers resolve aliases once at startup (Canonicalize), so only the concrete id flows downstream (pod env, CRD status, rollups) and stats and pricing stay per-version;
  • pattern: a well-formed but unregistered Anthropic version id ("anthropic/claude-opus-6") is synthesized as a claude-harness-only, unpriced model, so a new Anthropic release runs before patchy registers it. The claude CLI reports its own cost, so the missing rates matter only for display until the model is registered.

Index

Constants

View Source
const (
	ProviderAnthropic = "anthropic"
	ProviderOpenAI    = "openai"
)

Provider ids.

View Source
const (
	HarnessClaude = "claude"
	HarnessCodex  = "codex"
	HarnessFake   = "fake"
)

Harness ids, referenced by the Supported maps below. The harness package owns the Harness implementations; these constants are the shared vocabulary so the registry can name executors without importing that package.

View Source
const (
	// DefaultAlias is the default stage model (the analysis and the fallback
	// remediation model).
	DefaultAlias = "anthropic/claude-sonnet"
	// DefaultAllowlist is the default remediation model allowlist.
	DefaultAllowlist = "anthropic/claude-sonnet,anthropic/claude-opus"
)

Shipped default model ids (the controllers' flag defaults and the pod-side fallback). Family aliases track the newest registered version.

Variables

KnownHarnessIDs is the set of harness ids the registry may name in a Supported map, in registry order. That order is the deterministic tiebreak for harness resolution when a model's preferred harness is not enabled.

Functions

func Canonicalize added in v0.14.0

func Canonicalize(ids []string) ([]string, error)

Canonicalize maps every id to the concrete canonical id it resolves to against the builtins (aliases become the newest registered version), trims blanks, and drops duplicates while keeping first-seen order. It errors on an alias of an unknown family and on an id that is neither registered nor a well-formed Anthropic version id.

func Concrete added in v0.14.0

func Concrete(id string) string

Concrete maps id to the concrete canonical id it resolves to against the builtins, or returns it unchanged when it does not resolve. It is the lenient form of Canonicalize for places that must not fail (pod-side defaults); controllers validate with Canonicalize at startup.

func IsAlias added in v0.14.0

func IsAlias(id string) bool

IsAlias reports whether id is a family alias (anthropic/claude-<family>): a name for "the newest registered version of this family" rather than a concrete model.

func IsKnownHarnessID

func IsKnownHarnessID(id string) bool

IsKnownHarnessID reports whether id names a harness the registry knows.

func IsProviderID

func IsProviderID(id string) bool

IsProviderID reports whether id names a known vendor.

func ParseClaudeID added in v0.14.0

func ParseClaudeID(bare string) (family string, major, minor int, ok bool)

ParseClaudeID parses a vendor-bare Anthropic model id of the form claude-<family>-<major>[-<minor>]. A missing minor is 0. Dated, version-first or otherwise unrecognised ids return ok=false.

func Synthesized added in v0.14.0

func Synthesized(m Model) bool

Synthesized reports whether m was synthesized by the pattern tier rather than registered: it runs on the claude harness only and carries no pricing.

func UsageCostUSD

func UsageCostUSD(m Model, inputTokens, cacheReadTokens, cacheCreationTokens, outputTokens int) *float64

UsageCostUSD prices a measured token usage at the model's rates, or nil when the model has no published pricing. It is the fallback for a harness that reports no cost of its own, so it prices every input-side count rather than just the fresh tokens.

Cache reads bill at CachedInputUSD, roughly a tenth of the base rate, which is where the bulk of a long agent session's input lands. Cache writes bill at the base input rate: OpenAI does not price them separately, and while Anthropic charges a 1.25x premium on a 5m write, the claude CLI reports a cost of its own, so that path only ever cross-checks a figure the harness already gave us.

Types

type Model

type Model struct {
	ID             string            `json:"id"`
	ProviderID     string            `json:"provider_id"`
	Name           string            `json:"name"`
	InputUSD       *float64          `json:"input_per_mtok"`
	CachedInputUSD *float64          `json:"cached_input_per_mtok"`
	OutputUSD      *float64          `json:"output_per_mtok"`
	Supported      map[string]string `json:"supported"`
	Preferred      string            `json:"preferred"`
	// contains filtered or unexported fields
}

Model is one canonical, vendor-owned model. ID is provider-qualified ("anthropic/claude-sonnet-5") and is the stable id patchy stores in config, the investigation report, and the CRDs; the executing harness never appears in it.

Supported maps each harness id that can run this model to the CLI-specific model-id string that harness's --model flag expects. Any harness/vendor id divergence lives here. Preferred is the harness chosen when several supported harnesses are enabled; it is always a key of Supported.

InputUSD/OutputUSD are USD per 1M tokens (standard tier, cache-miss rates); nil means the vendor has not published per-token pricing. They exist so a harness that reports token usage but not cost (codex) can still be priced. CachedInputUSD is the cache-read (cache-hit) rate, an order of magnitude below InputUSD on both vendors; nil falls back to InputUSD.

func AllModels

func AllModels(overrides map[string][]Model) []Model

AllModels returns the canonical model registry with any per-provider config override applied. overrides maps a provider id to a replacement model list (replace, not merge: partial merges make it unclear which price won); only models whose ProviderID is overridden are replaced.

func Builtins

func Builtins() []Model

Builtins returns the canonical model registry (no overrides). It is the default set patchy resolves models against.

func Lookup added in v0.14.0

func Lookup(id string) (Model, bool)

Lookup resolves id against the builtin registry: Resolve(Builtins(), id).

func ModelByID

func ModelByID(models []Model, id string) (Model, bool)

ModelByID returns the model with exactly the given canonical id from models, if any. It does no alias or pattern resolution; consumers validating a configured or reported id use Resolve / Lookup instead.

func Resolve added in v0.14.0

func Resolve(models []Model, id string) (Model, bool)

Resolve looks id up in models in three tiers, returning the first hit:

  1. exact: a registered model with that canonical id;
  2. alias: anthropic/claude-<family> resolves to the highest (major, minor) registered Anthropic model of that family, or ok=false when the family has no registered model;
  3. pattern: a well-formed anthropic/claude-<family>-<major>[-<minor>] with no registry entry is synthesized as a claude-harness-only, unpriced model (see Synthesized), so an Anthropic release patchy has not registered yet still runs.

It is the one lookup every consumer validating a configured or reported model id uses.

func WithResolved added in v0.14.0

func WithResolved(models []Model, ids ...string) []Model

WithResolved returns models plus a synthesized entry for every id that resolves only through the pattern tier, so code that iterates a model list (provider.EffectiveModelMap deriving Bedrock/Vertex ids) covers those too. models itself is not modified.

func (Model) BareID

func (m Model) BareID() string

BareID is the id without its provider prefix ("claude-sonnet-5"): the vendor's own model id, independent of the executing harness.

func (Model) CLIModelID

func (m Model) CLIModelID(harnessID string) (string, bool)

CLIModelID returns the harness-specific model-id string this model's --model flag expects for harnessID, and whether the harness supports it.

func (Model) Key

func (m Model) Key() string

Key is the canonical, provider-qualified id ("anthropic/claude-sonnet-5").

func (Model) SupportedHarnessIDs

func (m Model) SupportedHarnessIDs() []string

SupportedHarnessIDs lists the harness ids that can run this model, sorted for stable display.

func (Model) Supports

func (m Model) Supports(harnessID string) bool

Supports reports whether harnessID can run this model.

type Provider

type Provider struct {
	ID   string `json:"id"`   // registry key, e.g. "anthropic"
	Name string `json:"name"` // human name, e.g. "Anthropic"
}

Provider is a model vendor: the entity that owns and prices a family of models (Anthropic, OpenAI). It is distinct from a harness (the CLI that drives a model) because several harnesses can in principle run one vendor's model, and the vendor id keys pricing while the harness id keys execution.

func ProviderByID

func ProviderByID(id string) (Provider, bool)

ProviderByID returns the vendor with the given id, if any.

func Providers

func Providers() []Provider

Providers returns the model vendors in display order.

Jump to

Keyboard shortcuts

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