Documentation
¶
Overview ¶
Package modelsdev fetches and parses the models.dev public model database (https://models.dev/api.json). It is a read-only wire-format layer: it knows how to decode the catalog and resolve each model's AI SDK provider, but it does not know anything about ccl's provider model 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 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 Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Provider *ModelProvider `json:"provider"`
Limit ModelLimit `json:"limit"`
}
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, reasoning options, …) are intentionally omitted.