modelsdev

package
v0.629.1 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package modelsdev provides read-only access to the models.dev catalog (https://github.com/anomalyco/models.dev), a community-maintained database of model pricing and capabilities per provider.

Providers rarely report pricing through their own model-listing APIs, so Pando cannot show a session cost for most dynamically discovered models. The catalog fills those gaps. It is strictly best-effort: every failure path (no network, malformed payload, unknown provider or model) degrades to "no data" so callers keep their original behaviour.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDisabled

func IsDisabled() bool

IsDisabled reports the current switch position.

func Reset

func Reset()

Reset drops the memoized catalog so the next Get loads it again. Intended for tests; production code toggles the catalog with SetDisabled instead.

func SetDisabled

func SetDisabled(v bool)

SetDisabled turns the catalog off (true) or back on (false). Turning it on after startup is enough for the next Get to load the catalog; nothing needs to be reset.

Types

type Catalog

type Catalog struct {
	// contains filtered or unexported fields
}

Catalog is the parsed models.dev payload plus the lookup indexes built from it. The zero value is a valid, empty catalog: Lookup always reports "not found", which is exactly the fallback behaviour callers need.

func Get

func Get(ctx context.Context) (Catalog, error)

Get returns the models.dev catalog, loading it at most once per process. The first caller pays the ~3 MB download; everyone else gets the memoized value, including the memoized failure — a provider refresh must never retry that download once per model.

Resolution order: fresh on-disk copy, then network, then a stale on-disk copy. An error is only returned when all three fail, and callers are expected to treat it as "no enrichment available" rather than a hard error.

func (Catalog) Lookup

func (c Catalog) Lookup(providerID, modelID string) (Model, bool)

Lookup resolves a model within one models.dev provider. modelID is the provider's own API model identifier (Model.APIModel in Pando), which may carry a vendor prefix or a dated/versioned suffix the catalog does not use.

func (Catalog) LookupAny

func (c Catalog) LookupAny(providerIDs []string, modelID string) (Model, bool)

LookupAny tries several models.dev providers in order and returns the first hit. Used for Pando providers that front more than one upstream catalog (Antigravity, Bedrock, Vertex AI).

func (Catalog) Providers

func (c Catalog) Providers() map[string]Provider

Providers returns the raw provider map. Callers must not mutate it.

type Cost

type Cost struct {
	Input      float64 `json:"input"`
	Output     float64 `json:"output"`
	CacheRead  float64 `json:"cache_read"`
	CacheWrite float64 `json:"cache_write"`
}

Cost holds the per-million-token prices reported by models.dev, in USD.

type Limit

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

Limit holds the context window and max output tokens reported by models.dev.

type Modalities

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

Modalities lists the input/output modalities a model accepts.

type Model

type Model struct {
	ID               string            `json:"id"`
	Name             string            `json:"name"`
	Description      string            `json:"description"`
	Family           string            `json:"family"`
	Attachment       bool              `json:"attachment"`
	Reasoning        bool              `json:"reasoning"`
	ReasoningOptions []ReasoningOption `json:"reasoning_options"`
	ToolCall         bool              `json:"tool_call"`
	Temperature      bool              `json:"temperature"`
	Knowledge        string            `json:"knowledge"`
	ReleaseDate      string            `json:"release_date"`
	LastUpdated      string            `json:"last_updated"`
	Modalities       Modalities        `json:"modalities"`
	OpenWeights      bool              `json:"open_weights"`
	Cost             Cost              `json:"cost"`
	Limit            Limit             `json:"limit"`
}

Model is a single catalog entry.

func (Model) SupportsReasoningEffort

func (m Model) SupportsReasoningEffort() bool

SupportsReasoningEffort reports whether the model exposes an effort-style reasoning control, which is what Pando's UIs gate the effort selector on.

type Provider

type Provider struct {
	ID     string           `json:"id"`
	Name   string           `json:"name"`
	Doc    string           `json:"doc"`
	Models map[string]Model `json:"models"`
}

Provider is one provider entry of the catalog, keyed by its models.dev id.

type ReasoningOption

type ReasoningOption struct {
	Type   string   `json:"type"`
	Values []string `json:"values"`
}

ReasoningOption describes one reasoning control a model exposes (e.g. an "effort" selector with its allowed values).

Jump to

Keyboard shortcuts

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