catalog

package
v0.56.9 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 4 Imported by: 1 module, 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

Index

Constants

View Source
const (
	ModelOpus   = "claude-opus-5-5"   // anthropic frontier tier
	ModelSonnet = "claude-sonnet-5-5" // advisor default (second-opinion, cross-vendor); anthropic balanced tier
	ModelHaiku  = "claude-haiku-5-5"  // anthropic cheap tier
)

Canonical Claude model IDs (current as of build). These back the ADVISOR (Sonnet) and per-vendor tier fallbacks; the default inference tiers use the GPT-6 ids below.

View Source
const (
	ModelSol   = "gpt-6.2-sol"   // strong — escalation target
	ModelTerra = "gpt-6.1-terra" // balanced — everyday default + fallback absorb
	ModelLuna  = "gpt-6-luna"    // fast/cheap — classifier + reviewer
)

GPT-6 model IDs — the OpenAI tiers (Responses API). Sol is the strong escalation target, Terra the balanced everyday default + fallback absorb target, Luna the fast/cheap classifier. Astra, the frontier tier, is pinned by label only.

View Source
const (
	ModelGeminiPro       = "gemini-4-carbon"       // frontier — escalation target
	ModelGeminiFlash     = "gemini-4-hydrogen"     // the Gemini vendor's everyday model
	ModelGeminiFlashLite = "gemini-3.5-flash-lite" // fast/cheap — classifier
)

Gemini model IDs (Google, via the native genai SDK).

View Source
const (
	ModelGrok47 = "grok-4.7" // single model — serves frontier/balanced/cheap tiers
)

Grok model ID (xAI, via the OpenAI-compatible api.x.ai endpoint). Grok 4.7 is the single model for all three strong-tier roles, so the selector resolves every tier to this id.

Variables

View Source
var EffortScale = []string{"low", "medium", "high", "xhigh", "max"}

EffortScale is memcode's universal reasoning-effort scale, lowest first. Two values sit outside it: "" (off: no extended thinking, used by helper calls) and "default" (send no effort; the vendor's own default applies).

Functions

func ContextWindow

func ContextWindow(model string) int

ContextWindow returns the input context-window size (tokens) for a model id or label: the catalog entry if it declares one, else the first matching family rule, else the default. Used by the footer's "ctx N%" meter and the overflow ceiling when a backend doesn't report its window on the wire.

func CostUSD

func CostUSD(model string, inTok, outTok, cacheRead, cacheWrite int) float64

CostUSD prices one response's token usage under its model's rate card. Token counts here are cache-EXCLUSIVE (see compat.applyUsage), so the prompt that decides the tier is the sum of all three input components.

func DefaultModel added in v0.29.0

func DefaultModel() string

DefaultModel returns the seed label for an install with no pin anywhere. Its ONLY legitimate caller is the pin resolver, and only when the session/workspace/user chain came up empty; the result is persisted so the next run reads a concrete pin instead of re-deriving this.

func DropsUnboundThinking added in v0.49.0

func DropsUnboundThinking(model string) bool

DropsUnboundThinking reports whether the adapter must send block_binding drop_block so an edited history drops stale thinking blocks instead of 400ing.

func FallbackChain

func FallbackChain(idOrLabel string) []string

FallbackChain returns the mid-turn failure chain (labels) for a model id or label. Nil when the catalog declares none.

func MaxOutputTokens

func MaxOutputTokens(model string) int

MaxOutputTokens returns the model's max output tokens from the catalog, or 0 when the catalog doesn't declare one. Callers that must send a max_tokens value on the wire (Anthropic requires the field) use this to translate "uncapped" (request MaxTokens 0) into the largest value the model accepts.

func MinReasoningEffort added in v0.32.0

func MinReasoningEffort(model string) string

MinReasoningEffort returns the lowest reasoning effort a model accepts, or "" when the catalog declares no floor. Adapters clamp against it so a cheap classifier turn can't 400 on a model whose range starts above "none".

func ModelEfforts added in v0.52.1

func ModelEfforts(model string) []string

ModelEfforts returns the scale levels a model supports natively, lowest first, or nil when the catalog declares none.

func ModelVendor

func ModelVendor(idOrLabel string) string

ModelVendor returns the authoritative serving vendor for a model id or label ("openai" | "anthropic" | "gemini" | "grok" | "fireworks"), "" when unknown.

func RejectsForcedToolChoice added in v0.37.0

func RejectsForcedToolChoice(model string) bool

RejectsForcedToolChoice reports whether a model 400s on a forced tool_choice, so the adapter must fall back to auto plus an explicit instruction.

func ResolveEffort added in v0.52.1

func ResolveEffort(model, level string) string

ResolveEffort maps a universal effort level onto the closest level the model supports natively. On a tie it takes the higher level, the same direction the vendors collapse unsupported levels (Fireworks runs GLM's low and medium as high). "" (off), "default", unknown levels, and models with no declared levels pass through unchanged. Equal labels on different vendors are not equal reasoning budgets; this only picks the nearest native setting.

func SearchFeeUSD

func SearchFeeUSD(vendor string, searches int) float64

SearchFeeUSD prices the PER-REQUEST native web-search surcharge for a call: the serving vendor's catalog fee (models.json search_fees, USD per 1,000 searches) times the number of searches the vendor billed (Response.SearchCount). Tokens alone under-billed searched turns — the upstream per-request fee never entered cost_usd. A vendor without a search_fees entry (gemini, the cheap lane, unknown backends) returns 0.

func SubscriptionUtilityModel added in v0.41.1

func SubscriptionUtilityModel(vendor string) string

SubscriptionUtilityModel returns the utility label for plumbing when the session runs on a subscription of vendor, "" when the catalog declares none (callers then use UtilityModel).

func UsesThinkingLevels added in v0.49.0

func UsesThinkingLevels(model string) bool

UsesThinkingLevels reports whether a Gemini model wants thinkingLevel rather than a thinkingBudget.

func UtilityModel added in v0.29.0

func UtilityModel() string

UtilityModel returns the label for internal plumbing (classify/authorize, compact, shrinkwrap). Never user-facing, never in the picker, never a substitute for the pinned model.

func VendorUtilityModel added in v0.51.0

func VendorUtilityModel(vendor string) string

VendorUtilityModel returns the label of vendor's small helper model, or "" when the vendor has none (callers then use UtilityModel).

Types

type CatalogModel

type CatalogModel struct {
	ID             string  `json:"id"`
	Label          string  `json:"label"`          // client-facing short name — the only id the CLI sees
	Vendor         string  `json:"vendor"`         // authoritative serving vendor ("openai" | "anthropic" | "gemini" | "grok" | "fireworks") — selection/steering identity, distinct from the display Group
	Name           string  `json:"name,omitempty"` // friendly display name ("Sonnet 5", "Grok 4.5") — the /model picker's name column
	Desc           string  `json:"desc,omitempty"` // one-line picker description ("1M context · Efficient for routine tasks")
	Window         int     `json:"window"`
	MaxOutput      int     `json:"max_output,omitempty"` // model's max output tokens; consumed where the provider REQUIRES max_tokens (Anthropic) to mean "uncapped"
	Vision         bool    `json:"vision"`
	PDF            bool    `json:"pdf,omitempty"` // accepts PDFs natively on the LLM call (document block / input_file / inline blob)
	Reasoning      bool    `json:"reasoning"`
	Pinnable       bool    `json:"pinnable,omitempty"` // offered in the /model picker
	Group          string  `json:"group,omitempty"`    // picker display family ("OpenAI", "Kimi", …)
	PriceIn        float64 `json:"price_in,omitempty"` // $/M tokens
	PriceOut       float64 `json:"price_out,omitempty"`
	PriceCacheRead float64 `json:"price_cache_read,omitempty"` // optional override (default in×0.1)

	// PriceTiers bends the rate card by PROMPT SIZE. Several vendors now price a
	// long prompt differently from a short one (GPT-6 Astra doubles input and
	// adds half again to output past 272K), and that is a per-request fact, not a
	// per-model one. Expressing it as ordered multiplier data — rather than a
	// special case in Go — keeps the rule where every consumer already reads it:
	// this file is shared verbatim with the gateway and with apps/www's own
	// calculateCost, and only one of those three can run Go.
	PriceTiers []PriceTier `json:"price_tiers,omitempty"`

	// MinReasoningEffort is the LOWEST reasoning effort this model accepts, in the
	// vendor's own vocabulary. Vendors disagree about the bottom of the range —
	// GPT-5.6 takes "none", GPT-6 Astra's floor is "low" and 400s below it — and
	// that is a model fact, so it lives here rather than as another adapter bool.
	// Empty means "no floor": send whatever the effort maps to.
	MinReasoningEffort string `json:"min_reasoning_effort,omitempty"`

	// Efforts lists the levels of memcode's universal effort scale (low, medium,
	// high, xhigh, max) this model supports natively, lowest first, from the
	// vendor's own docs. ResolveEffort maps any other level onto the closest of
	// these. Empty means the catalog declares none and levels pass through.
	Efforts []string `json:"efforts,omitempty"`

	// NoForcedToolChoice marks a model that rejects a forced tool_choice
	// ({type:"tool"} or {type:"any"}) with a 400. Claude Fable 5.1 and Opus 5.5
	// do; the structured-output callers (judges, reflection, review verdicts)
	// still need their tool called, so the adapter asks for it in words under
	// tool_choice auto instead. A model fact, so it lives here.
	NoForcedToolChoice bool `json:"no_forced_tool_choice,omitempty"`

	// DropUnboundThinking marks a model that enforces the preserved-thinking
	// history check on EVERY account: a replayed thinking block whose system,
	// tools or earlier messages changed since it was produced is a 400. The
	// volatile system block changes every turn, so the adapter sends
	// block_binding drop_block on these models and the API drops the stale
	// blocks instead. Only Fable 5.2 today; models that enforce new accounts
	// only keep reading the blocks on memcode's account, so dropping there would
	// lose reasoning for nothing.
	DropUnboundThinking bool `json:"drop_unbound_thinking,omitempty"`

	// ThinkingLevels marks a Gemini model that takes thinkingLevel (LOW, MEDIUM,
	// HIGH) and 400s on thinkingBudget. Gemini 4 is level-only and has no off,
	// so the adapter maps EffortOff to LOW there.
	ThinkingLevels bool `json:"thinking_levels,omitempty"`

	// Aliases are RETIRED labels and ids that must keep resolving to this entry.
	// When a vendor decommissions a model, deleting its row would make every pin
	// naming it a hard "unknown model" 400 at the gateway; listing the dead name
	// here migrates those pins onto the replacement instead, which is exactly
	// what the vendor's own migration does. A real label always wins over an
	// alias, so an alias can never shadow a live model.
	Aliases []string `json:"aliases,omitempty"`

	// Fallback is the model's mid-turn failure chain, in LABELS: who covers
	// when this model errors after transport retries, walked IN ORDER by the
	// CLI's recovery executor (availability/billing filtering happens at walk
	// time, client-side). Data, not Go — the routing doctrine lives here.
	Fallback []string `json:"fallback,omitempty"`
}

CatalogModel is one models.json entry: a model's identity and its static facts. A zero Window or zero pricing means "not declared here" — lookups fall through to the family rules, then the defaults.

func CatalogModels

func CatalogModels() []CatalogModel

CatalogModels returns every models.json entry in file order (the display order).

func LookupModel

func LookupModel(idOrLabel string) (CatalogModel, bool)

LookupModel resolves a raw id or a client-facing label to its catalog entry.

type PriceTier added in v0.32.0

type PriceTier struct {
	AbovePromptTokens int     `json:"above_prompt_tokens"`
	In                float64 `json:"in,omitempty"`
	Out               float64 `json:"out,omitempty"`
	CacheRead         float64 `json:"cache_read,omitempty"`
	CacheWrite        float64 `json:"cache_write,omitempty"`
}

PriceTier is one prompt-size pricing band: once a request's prompt exceeds AbovePromptTokens, every rate on the card is multiplied for the WHOLE request (not just the tokens past the line — that is how vendors actually bill it).

A multiplier left at 0 means 1× (unchanged), so a tier states only what it bends. Tiers are independent: the highest threshold a prompt clears wins, so order in JSON doesn't matter and a vendor can declare as many bands as it likes.

type Pricing

type Pricing struct{ Input, Output, CacheWrite, CacheRead float64 }

Pricing is APPROXIMATE per-model rates in USD per MILLION tokens. Cache write ≈ 1.25× base input; cache read ≈ 0.1× base input unless the catalog overrides it.

func ModelPricing

func ModelPricing(model string) Pricing

ModelPricing returns a model's BASE rate card — the short-prompt rates, before any prompt-size tier applies. Estimates and rate displays want this; anything billing a real request must use ModelPricingAt so a long prompt prices right.

func ModelPricingAt added in v0.32.0

func ModelPricingAt(model string, promptTokens int) Pricing

ModelPricingAt returns the rate card that actually governs a request whose prompt is promptTokens long — base card with the winning tier's multipliers folded in. promptTokens is the WHOLE prompt: fresh input plus cache reads plus cache writes, since vendors measure the threshold against everything they read.

Jump to

Keyboard shortcuts

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