bestiary

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 12 Imported by: 0

README

bestiary

Go module and CLI for querying AI model metadata from models.dev.

Provides strongly-typed providers, model IDs, a static model registry (~110 models), an HTTP client with retry, and a local SQLite cache for offline queries.

Install

As a Go library:

go get github.com/dayvidpham/bestiary

As a CLI tool:

go install github.com/dayvidpham/bestiary/cmd/bestiary@latest

Requires Go 1.24+. Builds with CGO_ENABLED=0 (no C compiler needed).

Library usage

package main

import (
    "fmt"
    "github.com/dayvidpham/bestiary"
)

func main() {
    // Static registry (compiled-in, no network)
    models := bestiary.StaticModels()
    fmt.Printf("%d models available\n", len(models))

    // Lookup by ID
    if m, ok := bestiary.LookupModel("claude-opus-4-6"); ok {
        fmt.Printf("%s: %s (%s, %d ctx)\n",
            m.ID, m.DisplayName, m.Provider, m.ContextWindow)
    }

    // Filter by provider
    for _, m := range bestiary.ModelsByProvider(bestiary.ProviderAnthropic) {
        fmt.Println(m.ID)
    }

    // Filter by family
    for _, m := range bestiary.ModelsByFamily("claude-opus") {
        fmt.Println(m.ID)
    }
}

Fetching live data:

ctx := context.Background()
client := bestiary.NewClient(
    bestiary.WithTimeout(10 * time.Second),
    bestiary.WithRetries(3),
)

models, err := client.FetchModels(ctx)
// or filter by provider:
models, err := client.FetchModelsByProvider(ctx, bestiary.ProviderGoogle)

CLI

bestiary <list|show|sync> [flags]
Commands

list -- Query models from the static registry + local cache (offline).

bestiary list                                    # all models, JSON
bestiary list --provider anthropic --format table  # Anthropic models, table
bestiary list --format yaml                      # all models, YAML

show -- Show a single model by ID (offline).

bestiary show claude-opus-4-6 --format json
bestiary show gemini-2.0-flash --format table

sync -- Fetch models from the models.dev API and cache locally (online).

bestiary sync                                    # fetch all, print JSON
bestiary sync --provider anthropic --format table  # fetch Anthropic, table
bestiary sync --provider google --format yaml    # fetch Google, YAML

After syncing, list and show merge static + cached data. When both sources have the same model, the most recently synced version wins.

Flags
Flag Default Description
--provider (all) Filter by provider slug (e.g. anthropic, google, openai)
--format json Output format: json, yaml, table
--db-path $XDG_CACHE_HOME/bestiary/models.db SQLite cache location
Example output
$ bestiary list --provider anthropic --format table

ID                          Provider   Family          Context  MaxOutput  Reason  Tools  CostIn/MTok
--------------------------  ---------  --------------  -------  ---------  ------  -----  -----------
claude-3-5-haiku-20241022   anthropic  claude-haiku    200000       8192      no    yes        $0.80
claude-opus-4-6             anthropic  claude-opus    1000000     128000     yes    yes        $5.00
claude-sonnet-4-6           anthropic  claude-sonnet  1000000      64000     yes    yes        $3.00
...

Types

Type Description
Provider String type with well-known constants (ProviderAnthropic, ProviderGoogle, ProviderOpenAI, ProviderLocal). Any models.dev provider slug is valid.
ModelID String type for model identifiers (e.g. "claude-opus-4-6").
ModelInfo Canonical model metadata: all 17 API fields including capabilities, pricing, modalities.
Modality Int enum: ModalityText, ModalityImage, ModalityPDF, ModalityAudio, ModalityVideo.
Modalities Input []Modality and Output []Modality.
Capability Supported bool + Config map[string]string for polymorphic fields (e.g. Interleaved).

Schema versioning

bestiary tracks two schema versions (see version.go):

  • BestiarySchemaVersion -- Semver for bestiary's public Go types. The JSON Schema (bestiary.schema.json) documents this contract.
  • UpstreamSchemaVersion -- <YYYY.MM.DD>-<sha256> pinning the models.dev schema snapshot bestiary was built against.
  • UpstreamGitCommit / UpstreamGitRemote -- Git provenance for the upstream schema source.

Updating static data

The static model registry is code-generated from the models.dev API:

go generate ./...

This runs cmd/bestiary-gen which fetches https://models.dev/api.json, filters to anthropic/google/openai, and writes models_static_gen.go.

Dependencies

  • Go 1.24+
  • zombiezen.com/go/sqlite (CGO-free SQLite driver)
  • No other external dependencies

License

MIT

Documentation

Overview

Package bestiary provides a thin wrapper and CLI interface for the models.dev API. It exposes types for AI model metadata and a local SQLite cache for offline use.

Index

Constants

View Source
const BestiarySchemaVersion = "0.0.1"

BestiarySchemaVersion is the semantic version of the bestiary JSON Schema. It follows semver (major.minor.patch) and must be incremented whenever the schema changes in a backward-incompatible way.

View Source
const UpstreamGitCommit = "6a41e313"

UpstreamGitCommit is the short Git commit hash of the models.dev repository revision that corresponds to UpstreamSchemaVersion.

View Source
const UpstreamGitRemote = "git@github.com:anomalyco/models.dev.git"

UpstreamGitRemote is the canonical Git remote URL for the models.dev repository from which the upstream schema was sourced.

View Source
const UpstreamSchemaVersion = "2026.04.04-fd776194f63d717cce255cdfcff5ceaf18dccfe404a54f824a4b00afd354a8c6"

UpstreamSchemaVersion identifies the exact snapshot of the models.dev schema that this bestiary schema was derived from. Format: YYYY.MM.DD-sha256 where sha256 is the full 64 lowercase hex character SHA-256 hash of the upstream schema file (packages/core/src/schema.ts).

Variables

This section is empty.

Functions

func DefaultDBPath

func DefaultDBPath() (string, error)

DefaultDBPath returns the default path for the models database. It uses $XDG_CACHE_HOME/bestiary/models.db, falling back to ~/.cache/bestiary/models.db when XDG_CACHE_HOME is not set.

func FormatModel

func FormatModel(w io.Writer, model ModelInfo, format OutputFormat) error

FormatModel writes a single model to w in the specified format.

func FormatModels

func FormatModels(w io.Writer, models []ModelInfo, format OutputFormat) error

FormatModels writes a list of models to w in the specified format.

Types

type Capability

type Capability struct {
	Supported bool
	Config    map[string]string // nil when no extra config
}

Capability represents a model capability that may carry additional configuration. For most capabilities, Supported is the only relevant field. For interleaved, Config may hold additional details (e.g., {"field": "reasoning_details"}).

type Client

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

Client fetches model metadata from the models.dev API. Use NewClient to construct a Client with sensible defaults.

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient creates a Client with the given options applied on top of defaults. Defaults: 30 s timeout, 2 retries, "https://models.dev/api.json".

func (*Client) FetchModels

func (c *Client) FetchModels(ctx context.Context) ([]ModelInfo, error)

FetchModels retrieves all model metadata from the models.dev API. It retries on transient failures (non-2xx responses or network errors) up to c.retries additional times with linear backoff, honouring ctx between attempts.

On final failure it returns *ErrAPIUnavailable so callers can use errors.As to inspect structured fields.

LastSynced on each returned ModelInfo is left empty; the caller must set it when persisting the results.

func (*Client) FetchModelsByProvider

func (c *Client) FetchModelsByProvider(ctx context.Context, p Provider) ([]ModelInfo, error)

FetchModelsByProvider fetches all models and returns only those from the given provider. It is a convenience wrapper around FetchModels.

type ClientOption

type ClientOption func(*Client)

ClientOption is a functional option for configuring a Client.

func WithBaseURL

func WithBaseURL(url string) ClientOption

WithBaseURL overrides the API endpoint. The default is "https://models.dev/api.json".

func WithRetries

func WithRetries(n int) ClientOption

WithRetries sets the number of retry attempts after an initial failure. For example, WithRetries(2) means up to 3 total attempts. The default is 2 retries.

func WithTimeout

func WithTimeout(d time.Duration) ClientOption

WithTimeout sets the HTTP request timeout. The default is 30 seconds.

type ErrAPIUnavailable

type ErrAPIUnavailable struct {
	// URL is the endpoint that was contacted.
	URL string
	// Attempts is how many times the request was tried before giving up.
	Attempts int
	// Cause is the last error returned by the HTTP client.
	Cause error
}

ErrAPIUnavailable is returned when the models.dev API cannot be reached after one or more attempts. Cause holds the underlying network or HTTP error.

Use errors.As to extract structured fields; use Unwrap to inspect the root cause via errors.Is.

func (*ErrAPIUnavailable) Error

func (e *ErrAPIUnavailable) Error() string

Error implements the error interface. Format: "bestiary: API unavailable after <n> attempt(s) at <url>: <cause>"

func (*ErrAPIUnavailable) Unwrap

func (e *ErrAPIUnavailable) Unwrap() error

Unwrap returns the underlying cause so that errors.Is and errors.As can traverse the error chain.

type ErrNotFound

type ErrNotFound struct {
	// What describes the resource kind that was not found (e.g., "model").
	What string
	// Key is the identifier that was searched for (e.g., model ID).
	Key string
}

ErrNotFound is returned when a requested resource cannot be located in the local store or remote API.

What identifies the resource kind (e.g., "model"), and Key is the lookup value that was not found. Use errors.As to extract structured fields.

ErrNotFound has no Unwrap method by design: it is a sentinel-style error with no wrapped cause. Use errors.As to match.

func (*ErrNotFound) Error

func (e *ErrNotFound) Error() string

Error implements the error interface. Format: "bestiary: <what> not found: <key>"

type Family

type Family string

Family identifies the model family from the models.dev API. It is a named string type for type safety, following the same pattern as Provider.

const (
	FamilyAllam             Family = "allam"
	FamilyAllenai           Family = "allenai"
	FamilyAura              Family = "aura"
	FamilyAuto              Family = "auto"
	FamilyBaichuan          Family = "baichuan"
	FamilyBart              Family = "bart"
	FamilyBge               Family = "bge"
	FamilyBigPickle         Family = "big-pickle"
	FamilyCanopylabs        Family = "canopylabs"
	FamilyChutesai          Family = "chutesai"
	FamilyClaude            Family = "claude"
	FamilyClaudeHaiku       Family = "claude-haiku"
	FamilyClaudeOpus        Family = "claude-opus"
	FamilyClaudeSonnet      Family = "claude-sonnet"
	FamilyCodestral         Family = "codestral"
	FamilyCodestralEmbed    Family = "codestral-embed"
	FamilyCogito            Family = "cogito"
	FamilyCohereEmbed       Family = "cohere-embed"
	FamilyCommand           Family = "command"
	FamilyCommandA          Family = "command-a"
	FamilyCommandR          Family = "command-r"
	FamilyDallE             Family = "dall-e"
	FamilyDeepseek          Family = "deepseek"
	FamilyDeepseekThinking  Family = "deepseek-thinking"
	FamilyDevstral          Family = "devstral"
	FamilyDistilbert        Family = "distilbert"
	FamilyElevenlabs        Family = "elevenlabs"
	FamilyErnie             Family = "ernie"
	FamilyFlux              Family = "flux"
	FamilyGemini            Family = "gemini"
	FamilyGeminiEmbedding   Family = "gemini-embedding"
	FamilyGeminiFlash       Family = "gemini-flash"
	FamilyGeminiFlashLite   Family = "gemini-flash-lite"
	FamilyGeminiPro         Family = "gemini-pro"
	FamilyGemma             Family = "gemma"
	FamilyGlm               Family = "glm"
	FamilyGlmAir            Family = "glm-air"
	FamilyGlmFlash          Family = "glm-flash"
	FamilyGlmFree           Family = "glm-free"
	FamilyGlmZ              Family = "glm-z"
	FamilyGlmv              Family = "glmv"
	FamilyGPT               Family = "gpt"
	FamilyGPTCodex          Family = "gpt-codex"
	FamilyGPTCodexMini      Family = "gpt-codex-mini"
	FamilyGPTCodexSpark     Family = "gpt-codex-spark"
	FamilyGPTImage          Family = "gpt-image"
	FamilyGPTMini           Family = "gpt-mini"
	FamilyGPTNano           Family = "gpt-nano"
	FamilyGPTOss            Family = "gpt-oss"
	FamilyGPTPro            Family = "gpt-pro"
	FamilyGranite           Family = "granite"
	FamilyGrok              Family = "grok"
	FamilyGrokBeta          Family = "grok-beta"
	FamilyGrokVision        Family = "grok-vision"
	FamilyGroq              Family = "groq"
	FamilyHermes            Family = "hermes"
	FamilyHunyuan           Family = "hunyuan"
	FamilyIdeogram          Family = "ideogram"
	FamilyImagen            Family = "imagen"
	FamilyIndictrans        Family = "indictrans"
	FamilyIntellect         Family = "intellect"
	FamilyJais              Family = "jais"
	FamilyJamba             Family = "jamba"
	FamilyKatCoder          Family = "kat-coder"
	FamilyKimi              Family = "kimi"
	FamilyKimiFree          Family = "kimi-free"
	FamilyKimiThinking      Family = "kimi-thinking"
	FamilyLing              Family = "ling"
	FamilyLiquid            Family = "liquid"
	FamilyLlama             Family = "llama"
	FamilyLongcat           Family = "longcat"
	FamilyLucid             Family = "lucid"
	FamilyLyria             Family = "lyria"
	FamilyM2m               Family = "m2m"
	FamilyMagistral         Family = "magistral"
	FamilyMagistralMedium   Family = "magistral-medium"
	FamilyMagistralSmall    Family = "magistral-small"
	FamilyMai               Family = "mai"
	FamilyMelotts           Family = "melotts"
	FamilyMercury           Family = "mercury"
	FamilyMimo              Family = "mimo"
	FamilyMimoFlashFree     Family = "mimo-flash-free"
	FamilyMimoOmni          Family = "mimo-omni"
	FamilyMimoOmniFree      Family = "mimo-omni-free"
	FamilyMimoPro           Family = "mimo-pro"
	FamilyMimoProFree       Family = "mimo-pro-free"
	FamilyMinimax           Family = "minimax"
	FamilyMinimaxFree       Family = "minimax-free"
	FamilyMinimaxM25        Family = "minimax-m2.5"
	FamilyMinimaxM27        Family = "minimax-m2.7"
	FamilyMinistral         Family = "ministral"
	FamilyMistral           Family = "mistral"
	FamilyMistralEmbed      Family = "mistral-embed"
	FamilyMistralLarge      Family = "mistral-large"
	FamilyMistralMedium     Family = "mistral-medium"
	FamilyMistralNemo       Family = "mistral-nemo"
	FamilyMistralSmall      Family = "mistral-small"
	FamilyMixtral           Family = "mixtral"
	FamilyMmPoly            Family = "mm-poly"
	FamilyModelRouter       Family = "model-router"
	FamilyMorph             Family = "morph"
	FamilyNanoBanana        Family = "nano-banana"
	FamilyNemoretriever     Family = "nemoretriever"
	FamilyNemotron          Family = "nemotron"
	FamilyNemotronFree      Family = "nemotron-free"
	FamilyNousresearch      Family = "nousresearch"
	FamilyNova              Family = "nova"
	FamilyNovaLite          Family = "nova-lite"
	FamilyNovaMicro         Family = "nova-micro"
	FamilyNovaPro           Family = "nova-pro"
	FamilyO                 Family = "o"
	FamilyOMini             Family = "o-mini"
	FamilyOPro              Family = "o-pro"
	FamilyOpengvlab         Family = "opengvlab"
	FamilyOsmosis           Family = "osmosis"
	FamilyPalmyra           Family = "palmyra"
	FamilyPangu             Family = "pangu"
	FamilyParakeet          Family = "parakeet"
	FamilyPhi               Family = "phi"
	FamilyPixtral           Family = "pixtral"
	FamilyPlamo             Family = "plamo"
	FamilyQvq               Family = "qvq"
	FamilyQwen              Family = "qwen"
	FamilyQwenFree          Family = "qwen-free"
	FamilyQwerky            Family = "qwerky"
	FamilyRay               Family = "ray"
	FamilyRecraft           Family = "recraft"
	FamilyRednote           Family = "rednote"
	FamilyRing              Family = "ring"
	FamilyRnj               Family = "rnj"
	FamilyRunway            Family = "runway"
	FamilySeed              Family = "seed"
	FamilySkywork           Family = "skywork"
	FamilySmartTurn         Family = "smart-turn"
	FamilySolarMini         Family = "solar-mini"
	FamilySolarPro          Family = "solar-pro"
	FamilySonar             Family = "sonar"
	FamilySonarDeepResearch Family = "sonar-deep-research"
	FamilySonarPro          Family = "sonar-pro"
	FamilySonarReasoning    Family = "sonar-reasoning"
	FamilySora              Family = "sora"
	FamilySourceful         Family = "sourceful"
	FamilyStableDiffusion   Family = "stable-diffusion"
	FamilyStep              Family = "step"
	FamilyTako              Family = "tako"
	FamilyTextEmbedding     Family = "text-embedding"
	FamilyTitanEmbed        Family = "titan-embed"
	FamilyTngtech           Family = "tngtech"
	FamilyTopazlabs         Family = "topazlabs"
	FamilyTrinity           Family = "trinity"
	FamilyTrinityMini       Family = "trinity-mini"
	FamilyUnsloth           Family = "unsloth"
	FamilyV0                Family = "v0"
	FamilyVenice            Family = "venice"
	FamilyVeo               Family = "veo"
	FamilyVoxtral           Family = "voxtral"
	FamilyVoyage            Family = "voyage"
	FamilyWhisper           Family = "whisper"
	FamilyYi                Family = "yi"
)

func Families

func Families() []Family

Families returns all known Family values as a defensive copy.

type Harness

type Harness string

Harness identifies the coding tool or AI-assisted development environment that is driving the model interaction.

const (
	HarnessClaudeCode  Harness = "claude-code"
	HarnessGeminiCLI   Harness = "gemini-cli"
	HarnessCodex       Harness = "codex"
	HarnessOpenCode    Harness = "opencode"
	HarnessCursor      Harness = "cursor"
	HarnessAntigravity Harness = "antigravity"
)

func Harnesses

func Harnesses() []Harness

Harnesses returns all known Harness values. The returned slice is a defensive copy — modifying it does not affect the package state.

func (Harness) IsKnown

func (h Harness) IsKnown() bool

IsKnown reports whether h is one of the six declared Harness constants.

func (Harness) MarshalText

func (h Harness) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Harness) String

func (h Harness) String() string

String returns the string representation of the harness.

func (*Harness) UnmarshalText

func (h *Harness) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It accepts any string value; use IsKnown() to validate.

type Modalities

type Modalities struct {
	Input  []Modality
	Output []Modality
}

Modalities groups the input and output modalities supported by a model.

type Modality

type Modality int

Modality represents a type of input or output an AI model can process.

const (
	ModalityText  Modality = iota // "text"
	ModalityImage                 // "image"
	ModalityPDF                   // "pdf"
	ModalityAudio                 // "audio"
	ModalityVideo                 // "video"
)

func (Modality) MarshalText

func (m Modality) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Modality) String

func (m Modality) String() string

String returns the human-readable name of the modality. For out-of-range values it returns "Modality(<n>)" rather than panicking.

func (*Modality) UnmarshalText

func (m *Modality) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

type ModelID

type ModelID string

ModelID is the canonical identifier for an AI model (e.g., "claude-3-5-sonnet-20241022").

type ModelInfo

type ModelInfo struct {
	ID                    ModelID
	Provider              Provider
	DisplayName           string
	Family                Family
	ContextWindow         int
	MaxOutput             int
	Reasoning             bool
	ToolCall              bool
	Attachment            bool
	Temperature           bool
	StructuredOutput      bool
	Interleaved           Capability
	OpenWeights           bool
	CostInputPerMTok      *float64
	CostOutputPerMTok     *float64
	CostReasoningPerMTok  *float64
	CostCacheReadPerMTok  *float64
	CostCacheWritePerMTok *float64
	ReleaseDate           string
	Knowledge             string
	Modalities            Modalities
	LastSynced            string // RFC3339
}

ModelInfo holds metadata for a single AI model as returned by the models.dev API.

func LookupModel

func LookupModel(id ModelID) (ModelInfo, bool)

LookupModel searches the static registry for a model by its ID. It returns the model and true if found, or the zero value and false otherwise.

func LookupModelByProvider

func LookupModelByProvider(p Provider, name string) (ModelInfo, bool)

LookupModelByProvider searches the static registry for a model matching both the given provider and name (model ID string). It returns the model and true if found, or the zero value and false otherwise.

func MergeModels

func MergeModels(static, cached []ModelInfo) []ModelInfo

MergeModels merges static and cached model lists. Deduplicates by (ModelID, Provider) pair. When both sources have the same (ID, Provider), the entry with the more recent LastSynced timestamp wins. Models with the same ID but different providers are kept as distinct entries. Since LastSynced uses RFC3339 UTC format, lexicographic string comparison correctly determines recency.

func Models

func Models() []ModelInfo

Models returns all available models. It delegates to StaticModels and returns a defensive copy so callers cannot mutate the registry. This is the preferred API for external callers; StaticModels is an implementation detail.

func ModelsByFamily

func ModelsByFamily(family Family) []ModelInfo

ModelsByFamily returns all static models belonging to the given family.

func ModelsByProvider

func ModelsByProvider(p Provider) []ModelInfo

ModelsByProvider returns all static models from the given provider.

func StaticModels

func StaticModels() []ModelInfo

StaticModels returns a defensive copy of the compiled-in model data. Modifying the returned slice does not affect the registry.

func (ModelInfo) Ref

func (m ModelInfo) Ref() ModelRef

Ref returns a ModelRef for this ModelInfo. RawFamily is set from the API family field. Family and Variant are always empty strings — decomposition is deferred to the normalization epoch.

type ModelRef

type ModelRef struct {
	Provider  Provider // Hosting provider
	RawFamily Family   // API family field verbatim (e.g., "claude-opus")
	Family    string   // Empty until normalization epoch. TODO: determine if normalized family uses Family type or a distinct NormalizedFamily type.
	Variant   string   // Empty until normalization epoch
	Date      string   // Release date from ModelInfo.ReleaseDate (e.g., "2025-05-14")
}

ModelRef represents the canonical identity of a model. Family and Variant are empty strings until the normalization epoch, when a decomposition pipeline will split RawFamily into structured fields.

The 5-field tuple (Provider, RawFamily, Family, Variant, Date) provides a stable anchor for cross-provider queries and future normalization work.

type OutputFormat

type OutputFormat string

OutputFormat specifies how models are rendered for display.

const (
	FormatJSON  OutputFormat = "json"
	FormatYAML  OutputFormat = "yaml"
	FormatTable OutputFormat = "table"
)

type Provider

type Provider string

Provider identifies the organization that hosts or publishes an AI model.

const (
	Provider302AI                  Provider = "302ai"
	ProviderAbacus                 Provider = "abacus"
	ProviderAIHubMix               Provider = "aihubmix"
	ProviderAlibaba                Provider = "alibaba"
	ProviderAlibabaCN              Provider = "alibaba-cn"
	ProviderAlibabaCodingPlan      Provider = "alibaba-coding-plan"
	ProviderAlibabaCodingPlanCN    Provider = "alibaba-coding-plan-cn"
	ProviderAmazonBedrock          Provider = "amazon-bedrock"
	ProviderAnthropic              Provider = "anthropic"
	ProviderAzure                  Provider = "azure"
	ProviderAzureCognitiveServices Provider = "azure-cognitive-services"
	ProviderBailing                Provider = "bailing"
	ProviderBaseten                Provider = "baseten"
	ProviderBerget                 Provider = "berget"
	ProviderCerebras               Provider = "cerebras"
	ProviderChutes                 Provider = "chutes"
	ProviderClarifai               Provider = "clarifai"
	ProviderCloudFerroSherlock     Provider = "cloudferro-sherlock"
	ProviderCloudflareAIGateway    Provider = "cloudflare-ai-gateway"
	ProviderCloudflareWorkersAI    Provider = "cloudflare-workers-ai"
	ProviderCohere                 Provider = "cohere"
	ProviderCortecs                Provider = "cortecs"
	ProviderDeepinfra              Provider = "deepinfra"
	ProviderDeepSeek               Provider = "deepseek"
	ProviderDInference             Provider = "dinference"
	ProviderDrun                   Provider = "drun"
	ProviderEvroc                  Provider = "evroc"
	ProviderFastRouter             Provider = "fastrouter"
	ProviderFireworksAI            Provider = "fireworks-ai"
	ProviderFirmware               Provider = "firmware"
	ProviderFriendli               Provider = "friendli"
	ProviderGitHubCopilot          Provider = "github-copilot"
	ProviderGitHubModels           Provider = "github-models"
	ProviderGitLab                 Provider = "gitlab"
	ProviderGoogle                 Provider = "google"
	ProviderGoogleVertex           Provider = "google-vertex"
	ProviderGoogleVertexAnthropic  Provider = "google-vertex-anthropic"
	ProviderGroq                   Provider = "groq"
	ProviderHelicone               Provider = "helicone"
	ProviderHuggingface            Provider = "huggingface"
	ProviderIflowcn                Provider = "iflowcn"
	ProviderInception              Provider = "inception"
	ProviderInference              Provider = "inference"
	ProviderIONet                  Provider = "io-net"
	ProviderJiekou                 Provider = "jiekou"
	ProviderKilo                   Provider = "kilo"
	ProviderKimiForCoding          Provider = "kimi-for-coding"
	ProviderKUAECloudCodingPlan    Provider = "kuae-cloud-coding-plan"
	ProviderLlama                  Provider = "llama"
	ProviderLlmgateway             Provider = "llmgateway"
	ProviderLMStudio               Provider = "lmstudio"
	ProviderLucidQuery             Provider = "lucidquery"
	ProviderMeganova               Provider = "meganova"
	ProviderMiniMax                Provider = "minimax"
	ProviderMiniMaxCN              Provider = "minimax-cn"
	ProviderMiniMaxCNCodingPlan    Provider = "minimax-cn-coding-plan"
	ProviderMiniMaxCodingPlan      Provider = "minimax-coding-plan"
	ProviderMistral                Provider = "mistral"
	ProviderMixlayer               Provider = "mixlayer"
	ProviderMoark                  Provider = "moark"
	ProviderModelScope             Provider = "modelscope"
	ProviderMoonshotai             Provider = "moonshotai"
	ProviderMoonshotaiCN           Provider = "moonshotai-cn"
	ProviderMorph                  Provider = "morph"
	ProviderNanoGPT                Provider = "nano-gpt"
	ProviderNebius                 Provider = "nebius"
	ProviderNova                   Provider = "nova"
	ProviderNovitaAI               Provider = "novita-ai"
	ProviderNvidia                 Provider = "nvidia"
	ProviderOllamaCloud            Provider = "ollama-cloud"
	ProviderOpenAI                 Provider = "openai"
	ProviderOpenCode               Provider = "opencode"
	ProviderOpenCodeGo             Provider = "opencode-go"
	ProviderOpenRouter             Provider = "openrouter"
	ProviderOVHcloud               Provider = "ovhcloud"
	ProviderPerplexity             Provider = "perplexity"
	ProviderPerplexityAgent        Provider = "perplexity-agent"
	ProviderPoe                    Provider = "poe"
	ProviderPrivatemodeAI          Provider = "privatemode-ai"
	ProviderQiHangAI               Provider = "qihang-ai"
	ProviderQiniuAI                Provider = "qiniu-ai"
	ProviderRequesty               Provider = "requesty"
	ProviderSAPAICore              Provider = "sap-ai-core"
	ProviderScaleway               Provider = "scaleway"
	ProviderSiliconFlow            Provider = "siliconflow"
	ProviderSiliconFlowCN          Provider = "siliconflow-cn"
	ProviderSTACKIT                Provider = "stackit"
	ProviderStepFun                Provider = "stepfun"
	ProviderSubmodel               Provider = "submodel"
	ProviderSynthetic              Provider = "synthetic"
	ProviderTencentCodingPlan      Provider = "tencent-coding-plan"
	ProviderTheGridAI              Provider = "the-grid-ai"
	ProviderTogetherai             Provider = "togetherai"
	ProviderUpstage                Provider = "upstage"
	ProviderV0                     Provider = "v0"
	ProviderVenice                 Provider = "venice"
	ProviderVercel                 Provider = "vercel"
	ProviderVivgrid                Provider = "vivgrid"
	ProviderVultr                  Provider = "vultr"
	ProviderWandb                  Provider = "wandb"
	ProviderXAI                    Provider = "xai"
	ProviderXiaomi                 Provider = "xiaomi"
	ProviderXiaomiTokenPlanAMS     Provider = "xiaomi-token-plan-ams"
	ProviderXiaomiTokenPlanCN      Provider = "xiaomi-token-plan-cn"
	ProviderXiaomiTokenPlanSGP     Provider = "xiaomi-token-plan-sgp"
	ProviderZai                    Provider = "zai"
	ProviderZaiCodingPlan          Provider = "zai-coding-plan"
	ProviderZenMux                 Provider = "zenmux"
	ProviderZhipuai                Provider = "zhipuai"
	ProviderZhipuaiCodingPlan      Provider = "zhipuai-coding-plan"
)
const ProviderLocal Provider = "local"

ProviderLocal is a bestiary-specific provider for locally-hosted models. It is not derived from the models.dev API and is always included in knownProviders (generated in providers_gen.go, appended last).

func Providers

func Providers() []Provider

Providers returns all known Provider values as a defensive copy. The returned slice includes all API-derived providers plus ProviderLocal. Modifying the returned slice does not affect the package state.

func ProvidersForFamily

func ProvidersForFamily(family Family) []Provider

ProvidersForFamily returns the set of providers that host models with the given family string. The family parameter matches the raw API family field (e.g., "claude-opus", "gemini-flash"). The returned slice contains no duplicates. If no models match, a nil slice is returned.

func (Provider) IsKnown

func (p Provider) IsKnown() bool

IsKnown reports whether p is a recognized Provider. The known set is generated from the models.dev API at codegen time and includes ProviderLocal as the final entry.

func (Provider) MarshalText

func (p Provider) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (Provider) String

func (p Provider) String() string

String returns the string representation of the provider.

func (*Provider) UnmarshalText

func (p *Provider) UnmarshalText(b []byte) error

UnmarshalText implements encoding.TextUnmarshaler. It accepts any string value; use IsKnown() to validate.

type Store

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

Store is a SQLite-backed cache for AI model metadata. Use OpenStore to create, and Close when done.

func OpenStore

func OpenStore(path string) (*Store, error)

OpenStore opens (or creates) the SQLite database at path. It applies any pending schema migrations before returning. Caller must call Close when done.

func (*Store) Close

func (s *Store) Close() error

Close closes the underlying SQLite connection.

func (*Store) QueryModel

func (s *Store) QueryModel(ctx context.Context, id ModelID) (ModelInfo, error)

QueryModel returns the first model found with the given ID, or ErrNotFound if no model with that ID exists in the store. Note: with the composite (model_id, provider) primary key, multiple rows may share the same model_id across different providers. Use QueryModelsByID to retrieve all provider variants for a given model ID.

ctx is accepted for API compatibility; zombiezen.com/go/sqlite does not support per-operation context cancellation.

func (*Store) QueryModels

func (s *Store) QueryModels(ctx context.Context, provider Provider) ([]ModelInfo, error)

QueryModels returns all cached models. If provider is non-empty, results are filtered to only models from that provider. An empty provider string returns ALL models regardless of provider.

ctx is accepted for API compatibility; zombiezen.com/go/sqlite does not support per-operation context cancellation.

func (*Store) QueryModelsByID

func (s *Store) QueryModelsByID(ctx context.Context, id ModelID) ([]ModelInfo, error)

QueryModelsByID returns all cached models with the given ID across all providers. Returns an empty slice (not an error) if none are found.

ctx is accepted for API compatibility; zombiezen.com/go/sqlite does not support per-operation context cancellation.

func (*Store) UpsertModels

func (s *Store) UpsertModels(ctx context.Context, models []ModelInfo) error

UpsertModels inserts or replaces the given models in the store. It sets LastSynced to the current UTC time in RFC3339 format for each model. All upserts run inside a single transaction.

ctx is accepted for API compatibility; zombiezen.com/go/sqlite does not support per-operation context cancellation.

Directories

Path Synopsis
cmd
bestiary command
bestiary-gen command
bestiary-gen fetches the models.dev API and writes three generated files into the bestiary package root:
bestiary-gen fetches the models.dev API and writes three generated files into the bestiary package root:

Jump to

Keyboard shortcuts

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