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.
Index ¶
Constants ¶
const ( ProviderAnthropic = "anthropic" ProviderOpenAI = "openai" )
Provider ids.
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.
Variables ¶
var KnownHarnessIDs = []string{HarnessClaude, HarnessCodex, HarnessFake}
KnownHarnessIDs is the set of harness ids the registry may name in a Supported map, in registry order — the deterministic tiebreak order for harness resolution when a model's preferred harness is not enabled.
Functions ¶
func IsKnownHarnessID ¶
IsKnownHarnessID reports whether id names a harness the registry knows.
func IsProviderID ¶
IsProviderID reports whether id names a known vendor.
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: every input-side count (fresh input, cache reads, and cache writes) is priced at the input rate so the figure still reflects the whole session.
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"`
OutputUSD *float64 `json:"output_per_mtok"`
Supported map[string]string `json:"supported"`
Preferred string `json:"preferred"`
}
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 — this is where any harness/vendor id divergence lives. 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.
func AllModels ¶
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 create "which price won?" ambiguity); 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 (Model) BareID ¶
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 ¶
CLIModelID returns the harness-specific model-id string this model's --model flag expects for harnessID, and whether the harness supports it.
func (Model) SupportedHarnessIDs ¶
SupportedHarnessIDs lists the harness ids that can run this model, sorted for stable display.
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 ¶
ProviderByID returns the vendor with the given id, if any.