Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWindowTokens ¶
ContextWindowTokens returns the known context window size in tokens for modelID, or 0 if the model is unknown. Uses the same qualified→bare lookup chain as CostUSD.
func CostUSD ¶
CostUSD returns the estimated USD cost for a completed run.
qualifiedID should be the OpenRouter-style "provider/model" key (e.g. "anthropic/claude-sonnet-4-6"). Native adapters pass their provider prefix; OpenRouter adapters pass the model ID as-is.
Returns 0 for unknown models — the UI omits the cost field in that case.
func LoadPricing ¶
func LoadPricing(cacheFile string)
LoadPricing populates the dynamic pricing table at startup using OpenRouter's public model listing as the data source.
Fallback chain:
fresh local cache (< 24 h) → OpenRouter fetch + update cache → stale local cache → hardcoded pricingTable
Blocking with a 5-second HTTP timeout. Safe to call before any goroutines start.
func PricingFor ¶
PricingFor returns the per-million-token USD rates for a model. qualifiedID follows the same "provider/model" convention as CostUSD (e.g. "anthropic/claude-sonnet-4-6"). Returns ok=false for unknown models.
func ProviderQualifiedID ¶
CostUSD returns the estimated USD cost for a completed run.
qualifiedID should be the OpenRouter-style "provider/model" key (e.g. "anthropic/claude-sonnet-4-6"). Native adapters pass their provider prefix; OpenRouter adapters pass the model ID as-is.
Lookup order:
- qualifiedID in dynamic pricing (OpenRouter data)
- qualifiedID in hardcoded table
- bare portion after the first "/" in both tables (for native-adapter fallback)
Returns 0 for unknown models — the UI omits the cost field in that case. ProviderQualifiedID returns the OpenRouter-style "provider/model" key for a model ID from a given provider. For OpenRouter and LiteLLM the model ID already carries the required prefix and is returned as-is.
Types ¶
This section is empty.