modelsdev

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModelsDevAPIURL = "https://models.dev/api.json"
	CacheFileName   = "models_dev.json"
)

Variables

View Source
var ModelAliases = map[string]string{
	"anthropic/claude-sonnet-4-0": "anthropic/claude-sonnet-4-20250514",
}

ModelAliases maps alias model IDs to their actual model IDs

Functions

This section is empty.

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 Limit

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

Limit represents the context and output limitations of a model

type Modalities

type Modalities struct {
	Input  []string `json:"input"`
	Output []string `json:"output"`
}

Modalities represents the supported input and output types

type Model

type Model struct {
	ID          string     `json:"id"`
	Name        string     `json:"name"`
	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 Opt

type Opt func(*Store)

func WithCacheDir

func WithCacheDir(cacheDir string) Opt

func WithRefreshInterval

func WithRefreshInterval(refreshInterval time.Duration) Opt

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 the models.dev data with local caching

func NewStore

func NewStore(opts ...Opt) (*Store, error)

NewStore creates a new models.dev store instance

func (*Store) GetDatabase

func (s *Store) GetDatabase(ctx context.Context) (*Database, error)

GetDatabase returns the models.dev database, fetching from cache or API as needed

func (*Store) GetModel

func (s *Store) GetModel(ctx context.Context, id string) (*Model, error)

GetModel returns a specific model by provider ID and model ID

func (*Store) GetProvider

func (s *Store) GetProvider(ctx context.Context, providerID string) (*Provider, error)

GetProvider returns a specific provider by ID

Jump to

Keyboard shortcuts

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