Documentation
¶
Overview ¶
Package modelsdev fetches and parses the models.dev public model database (https://models.dev/api.json). It owns the catalog wire format and an optional offline metadata cache. It resolves model capabilities and AI SDK providers without knowing CCL's provider configuration, credentials or protocol dispatch.
models.dev is the metadata source OpenCode itself uses to decide which AI SDK provider (and therefore which wire protocol) each model speaks. A provider carries a default npm package (e.g. "@ai-sdk/openai-compatible") and individual models may override it via their own provider.npm field.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CachePath ¶ added in v1.7.17
CachePath is separate from provider configuration and OAuth credentials.
func CacheStamp ¶ added in v1.7.17
func CacheStamp() string
CacheStamp lets an explicitly requested proxy start notice a metadata refresh without reading/decoding the catalog or changing provider config.
func Fetch ¶
Fetch downloads and decodes the models.dev catalog. The top level is a map of provider id → provider with no envelope key, so it is decoded with a raw map and tolerant of entries that do not parse into a full provider (they are skipped rather than failing the whole fetch).
func ResolvedNPM ¶
ResolvedNPM returns the AI SDK package that describes a model's protocol: the model-level provider.npm when present, otherwise the provider default.
Types ¶
type Cache ¶ added in v1.7.17
Cache downloads public metadata only; it never receives provider credentials. URL and Client can point to local services in isolated tests.
type Index ¶ added in v1.7.17
type Index struct {
// contains filtered or unexported fields
}
Index retains only reasoning metadata and exact aliases from a catalog. It is immutable after construction and safe for concurrent lookups.
func CachedIndex ¶ added in v1.7.17
CachedIndex is read-only and performs no network access. A cached immutable index is reused until the snapshot file changes (for example via ccl set).
func (*Index) Efforts ¶ added in v1.7.17
Efforts resolves an exact provider entry first, then a canonical/reference entry. Conflicting equal-priority aliases are not merged or guessed. Found with an empty slice means the model has no selectable reasoning tiers. The returned slice is a copy so callers cannot mutate the shared index.
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Provider *ModelProvider `json:"provider"`
Limit ModelLimit `json:"limit"`
CanonicalID string `json:"canonical_model_id"`
Reasoning bool `json:"reasoning"`
ReasoningOptions []ReasoningOption `json:"reasoning_options"`
}
Model is a single model under a provider. Status is optional ("deprecated", "beta", …); most models omit it.
type ModelLimit ¶
ModelLimit carries the advertised context/output token limits.
type ModelProvider ¶
type ModelProvider struct {
NPM string `json:"npm"`
}
ModelProvider carries a model-level npm override. Absent means the model inherits its provider's default npm.
type Provider ¶
type Provider struct {
ID string `json:"id"`
Name string `json:"name"`
NPM string `json:"npm"`
API string `json:"api"`
Env []string `json:"env"`
Doc string `json:"doc"`
Models map[string]Model `json:"models"`
}
Provider is one entry in the models.dev catalog, keyed by its id at the top level. Fields we do not consume (cost, modalities, …) are intentionally omitted.
type ReasoningOption ¶ added in v1.7.17
ReasoningOption distinguishes selectable effort tiers from thinking switches and token budgets. A reasoning model need not support selectable efforts.