modelsdev

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 7 Imported by: 0

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

func Fetch(ctx context.Context) (map[string]Provider, error)

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

func ResolvedNPM(p Provider, m Model) string

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

type ModelLimit struct {
	Context int `json:"context"`
	Output  int `json:"output"`
}

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.

Jump to

Keyboard shortcuts

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