Documentation
¶
Overview ¶
Package modeldb provides access to the models.dev model database.
This package embeds the full models.dev database for use by external consumers (CLI tools, UIs, model selectors). It is NOT used by provider implementations for pricing calculations - providers maintain their own pricing logic.
To update the embedded model database, run:
curl -sL https://models.dev/api.json -o modeldb/api.json
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ProviderMapping = map[string]string{
"bedrock": "amazon-bedrock",
"anthropic": "anthropic",
"openai": "openai",
"openrouter": "openrouter",
"google": "google",
}
ProviderMapping maps internal provider names to models.dev provider IDs.
Functions ¶
Types ¶
type Cost ¶
type Cost struct {
Input float64 `json:"input,omitempty"`
Output float64 `json:"output,omitempty"`
CacheRead float64 `json:"cache_read,omitempty"`
CacheWrite float64 `json:"cache_write,omitempty"`
ContextOver200k *Cost `json:"context_over_200k,omitempty"`
}
Cost represents pricing in USD per 1M tokens.
type Database ¶
Database is the root structure mapping provider IDs to providers.
type Interleaved ¶
Interleaved describes reasoning interleaving configuration. Can be unmarshaled from boolean true or object {"field": "reasoning_content"}.
func (Interleaved) MarshalJSON ¶
func (i Interleaved) MarshalJSON() ([]byte, error)
MarshalJSON serializes Interleaved back to JSON.
func (*Interleaved) UnmarshalJSON ¶
func (i *Interleaved) UnmarshalJSON(data []byte) error
UnmarshalJSON handles both boolean and object formats for interleaved config.
type Modalities ¶
type Modalities struct {
Input []string `json:"input,omitempty"`
Output []string `json:"output,omitempty"`
}
Modalities describes supported input/output types.
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
Family string `json:"family,omitempty"`
Attachment bool `json:"attachment,omitempty"`
Reasoning bool `json:"reasoning,omitempty"`
ToolCall bool `json:"tool_call,omitempty"`
StructuredOutput bool `json:"structured_output,omitempty"`
Temperature bool `json:"temperature,omitempty"`
Interleaved *Interleaved `json:"interleaved,omitempty"`
Knowledge string `json:"knowledge,omitempty"`
ReleaseDate string `json:"release_date,omitempty"`
LastUpdated string `json:"last_updated,omitempty"`
Modalities Modalities `json:"modalities,omitempty"`
OpenWeights bool `json:"open_weights,omitempty"`
Cost Cost `json:"cost,omitempty"`
Limit Limit `json:"limit,omitempty"`
}
Model represents a single LLM model with metadata and pricing.
type Provider ¶
type Provider struct {
ID string `json:"id"`
Name string `json:"name"`
Env []string `json:"env,omitempty"`
NPM string `json:"npm,omitempty"`
API string `json:"api,omitempty"`
Doc string `json:"doc,omitempty"`
Models map[string]Model `json:"models"`
}
Provider represents an LLM provider with its models.
func GetProvider ¶
GetProvider returns the provider for the given internal name. Uses ProviderMapping to translate internal names to models.dev IDs.