Documentation
¶
Overview ¶
Package modelsdev provides read-only access to the models.dev catalog (https://github.com/anomalyco/models.dev), a community-maintained database of model pricing and capabilities per provider.
Providers rarely report pricing through their own model-listing APIs, so Pando cannot show a session cost for most dynamically discovered models. The catalog fills those gaps. It is strictly best-effort: every failure path (no network, malformed payload, unknown provider or model) degrades to "no data" so callers keep their original behaviour.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeBaseURL ¶ added in v1.2.6
NormalizeBaseURL reduces a base URL to a comparable key: scheme, "www.", trailing slashes and a trailing "/v1" are dropped and the result is lowercased, so "https://api.deepseek.com/v1/" and "https://api.deepseek.com" compare equal. URLs containing template placeholders yield "".
func Reset ¶
func Reset()
Reset drops the memoized catalog so the next Get loads it again. Intended for tests; production code toggles the catalog with SetDisabled instead.
func SetDisabled ¶
func SetDisabled(v bool)
SetDisabled turns the catalog off (true) or back on (false). Turning it on after startup is enough for the next Get to load the catalog; nothing needs to be reset.
Types ¶
type Catalog ¶
type Catalog struct {
// contains filtered or unexported fields
}
Catalog is the parsed models.dev payload plus the lookup indexes built from it. The zero value is a valid, empty catalog: Lookup always reports "not found", which is exactly the fallback behaviour callers need.
func Get ¶
Get returns the models.dev catalog, loading it at most once per process. The first caller pays the ~3 MB download; everyone else gets the memoized value, including the memoized failure — a provider refresh must never retry that download once per model.
Resolution order: fresh on-disk copy, then network, then a stale on-disk copy. An error is only returned when all three fail, and callers are expected to treat it as "no enrichment available" rather than a hard error.
func (Catalog) Lookup ¶
Lookup resolves a model within one models.dev provider. modelID is the provider's own API model identifier (Model.APIModel in Pando), which may carry a vendor prefix or a dated/versioned suffix the catalog does not use.
func (Catalog) LookupAny ¶
LookupAny tries several models.dev providers in order and returns the first hit. Used for Pando providers that front more than one upstream catalog (Bedrock, Vertex AI).
func (Catalog) ProvidersForBaseURL ¶ added in v1.2.6
ProvidersForBaseURL returns the models.dev provider ids whose API base URL matches baseURL. Used to enrich models of user-configured openai-compatible accounts (Kilo, OpenCode Zen, DeepSeek, …), whose Pando provider type says nothing about which upstream catalog describes them.
type Cost ¶
type Cost struct {
Input float64 `json:"input"`
Output float64 `json:"output"`
CacheRead float64 `json:"cache_read"`
CacheWrite float64 `json:"cache_write"`
}
Cost holds the per-million-token prices reported by models.dev, in USD.
type Modalities ¶
Modalities lists the input/output modalities a model accepts.
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Family string `json:"family"`
Attachment bool `json:"attachment"`
Reasoning bool `json:"reasoning"`
ReasoningOptions []ReasoningOption `json:"reasoning_options"`
ToolCall bool `json:"tool_call"`
Temperature bool `json:"temperature"`
Knowledge string `json:"knowledge"`
ReleaseDate string `json:"release_date"`
LastUpdated string `json:"last_updated"`
Modalities Modalities `json:"modalities"`
OpenWeights bool `json:"open_weights"`
Cost Cost `json:"cost"`
Limit Limit `json:"limit"`
}
Model is a single catalog entry.
func (Model) ReasoningEffortValues ¶ added in v0.646.4
ReasoningEffortValues returns the allowed values for the "effort" reasoning control, if the model advertises one. It is the ordered list (weakest to strongest) that Pando copies onto models.Model.ReasoningEfforts.
func (Model) SupportsReasoningEffort ¶
SupportsReasoningEffort reports whether the model exposes an effort-style reasoning control, which is what Pando's UIs gate the effort selector on.
type Provider ¶
type Provider struct {
ID string `json:"id"`
Name string `json:"name"`
Doc string `json:"doc"`
// API is the provider's base URL for OpenAI-compatible style providers
// (e.g. "https://api.kilo.ai/api/gateway"). It lets Pando identify which
// catalog entry describes a user-configured openai-compatible account.
API string `json:"api"`
Models map[string]Model `json:"models"`
}
Provider is one provider entry of the catalog, keyed by its models.dev id.
type ReasoningOption ¶
ReasoningOption describes one reasoning control a model exposes (e.g. an "effort" selector with its allowed values).