Documentation
¶
Index ¶
Constants ¶
const ( ModelsDevAPIURL = "https://models.dev/api.json" CacheFileName = "models_dev.json" )
Variables ¶
This section is empty.
Functions ¶
func ModelSupportsReasoning ¶ added in v1.19.3
ModelSupportsReasoning checks if the given model ID supports reasoning/thinking.
This function implements fail-open semantics:
- If modelID is empty or not in "provider/model" format, returns true (fail-open)
- If models.dev lookup fails for any reason, returns true (fail-open)
- If lookup succeeds, returns the model's Reasoning field value
Types ¶
type CachedData ¶
type CachedData struct {
Database Database `json:"database"`
CachedAt time.Time `json:"cached_at"`
LastRefresh time.Time `json:"last_refresh"`
}
CachedData represents the cached models.dev data with metadata
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"`
}
Cost represents the pricing information for a model
type Database ¶
type Database struct {
Providers map[string]Provider `json:"providers"`
UpdatedAt time.Time `json:"updated_at"`
}
Database represents the complete models.dev database
type Modalities ¶
Modalities represents the supported input and output types
type Model ¶
type Model struct {
ID string `json:"id"`
Name string `json:"name"`
Family string `json:"family,omitempty"`
Attachment bool `json:"attachment"`
Reasoning bool `json:"reasoning"`
Temperature bool `json:"temperature"`
ToolCall bool `json:"tool_call"`
Knowledge string `json:"knowledge,omitempty"`
ReleaseDate string `json:"release_date"`
LastUpdated string `json:"last_updated"`
OpenWeights bool `json:"open_weights"`
Cost *Cost `json:"cost,omitempty"`
Limit Limit `json:"limit"`
Modalities Modalities `json:"modalities"`
}
Model represents an AI model with its specifications and capabilities
type Provider ¶
type Provider struct {
ID string `json:"id"`
Name string `json:"name"`
Doc string `json:"doc,omitempty"`
API string `json:"api,omitempty"`
NPM string `json:"npm,omitempty"`
Env []string `json:"env,omitempty"`
Models map[string]Model `json:"models"`
}
Provider represents an AI model provider
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages access to the models.dev data. The database is loaded lazily on first access and cached for the lifetime of the Store. All methods are safe for concurrent use.
func NewDatabaseStore ¶ added in v1.23.1
NewDatabaseStore creates a Store pre-populated with the given database. The returned store serves data entirely from memory and never fetches from the network or touches the filesystem, making it suitable for tests and any scenario where the provider data is already known.
func NewStore ¶
NewStore returns the cached default store instance. The underlying database is fetched lazily on first access from a local cache file or the models.dev API.
func (*Store) GetDatabase ¶
GetDatabase returns the models.dev database, fetching from cache or API as needed.
func (*Store) GetProvider ¶
GetProvider returns a specific provider by ID.
func (*Store) ResolveModelAlias ¶ added in v1.18.8
ResolveModelAlias resolves a model alias to its pinned version. For example, ("anthropic", "claude-sonnet-4-5") might resolve to "claude-sonnet-4-5-20250929". If the model is not an alias (already pinned or unknown), the original model name is returned. This method uses the models.dev database to find the corresponding pinned version.