modelsdev

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: AGPL-3.0 Imports: 26 Imported by: 0

README

modelsdev

Internal package modelsdev provides integration with the models.dev community repository.

modelsdev

import "github.com/agentstation/starmap/internal/sources/modelsdev"

Index

Constants

const (
    // ModelsDevAPIURL is the URL for the models.dev API.
    ModelsDevAPIURL = "https://models.dev/api.json"
    // HTTPCacheTTL is the cache time-to-live for HTTP responses.
    HTTPCacheTTL = 1 * time.Hour
)

const (
    // ModelsDevRepoURL is the URL for the models.dev git repository.
    ModelsDevRepoURL = "https://github.com/sst/models.dev.git"
)

func ConvertToStarmapModel

func ConvertToStarmapModel(mdModel Model) *catalogs.Model

ConvertToStarmapModel converts a models.dev model to a starmap model. This is shared between GitSource and HTTPSource to avoid duplication.

func CopyAuthorLogos

func CopyAuthorLogos(outputDir string, authors []catalogs.Author, providers catalogs.ProvidersReader) error

CopyAuthorLogos copies author logos from models.dev provider logos to author directories. Since models.dev doesn't have a separate authors directory, we copy from the provider directory when the author ID matches a provider ID (or alias).

func CopyProviderLogos

func CopyProviderLogos(outputDir string, providers []*catalogs.Provider) error

CopyProviderLogos copies provider logos from models.dev to output directory. It tries the provider ID first, then checks aliases if the primary ID isn't found.

type API

API represents the structure of models.dev api.json.

type API map[string]Provider

func ParseAPI
func ParseAPI(apiPath string) (*API, error)

ParseAPI parses the api.json file and returns an API.

func (*API) GetProvider
func (a *API) GetProvider(providerID catalogs.ProviderID) (*Provider, bool)

GetProvider returns a specific provider from the API data.

func (*API) UnmarshalJSON
func (a *API) UnmarshalJSON(data []byte) error

UnmarshalJSON bounds providers and model records before typed decoding.

type APIPromotion

APIPromotion describes a models.dev payload that passed typed and semantic validation and was atomically promoted to its destination.

type APIPromotion struct {
    Checksum           string `json:"checksum"`
    SizeBytes          int64  `json:"size_bytes"`
    ProviderCount      int    `json:"provider_count"`
    ModelCount         int    `json:"model_count"`
    RejectedModelCount int    `json:"rejected_model_count"`
}

func PromoteAPIFile
func PromoteAPIFile(candidatePath, destinationPath string) (APIPromotion, error)

PromoteAPIFile validates a downloaded models.dev payload against the same typed, semantic, and completeness policy used by runtime cache promotion, then atomically replaces the destination. A failed candidate leaves the destination byte-for-byte unchanged.

type Client

Client is an alias for backward compatibility.

type Client = GitClient

func NewClient
func NewClient(outputDir string) *Client

NewClient creates a new models.dev git client.

type Cost

Cost represents pricing information.

type Cost struct {
    Input           *float64    `json:"input,omitempty"`
    Output          *float64    `json:"output,omitempty"`
    Reasoning       *float64    `json:"reasoning,omitempty"`
    Cache           *float64    `json:"cache,omitempty"`       // Legacy cache field
    CacheRead       *float64    `json:"cache_read,omitempty"`  // Cache read costs
    CacheWrite      *float64    `json:"cache_write,omitempty"` // Cache write costs
    InputAudio      *float64    `json:"input_audio,omitempty"`
    OutputAudio     *float64    `json:"output_audio,omitempty"`
    Tiers           []CostTier  `json:"tiers,omitempty"`
    ContextOver200K *TierPrices `json:"context_over_200k,omitempty"`
}

type CostTier

CostTier represents a conditional pricing tier in models.dev.

type CostTier struct {
    TierPrices
    Tier CostTierInfo `json:"tier"`
}

type CostTierInfo

CostTierInfo represents the dimension and threshold for a models.dev pricing tier.

type CostTierInfo struct {
    Type string `json:"type"`
    Size int64  `json:"size"`
}

type Experimental

Experimental represents experimental models.dev model metadata.

type Experimental struct {
    Enabled bool                        `json:"-"`
    Modes   map[string]ExperimentalMode `json:"modes,omitempty"`
}

func (*Experimental) UnmarshalJSON
func (e *Experimental) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both the legacy boolean marker and the current object form containing mode overrides.

type ExperimentalMode

ExperimentalMode represents a mode-specific models.dev override.

type ExperimentalMode struct {
    Cost     *TierPrices               `json:"cost,omitempty"`
    Provider *ExperimentalModeProvider `json:"provider,omitempty"`
}

type ExperimentalModeProvider

ExperimentalModeProvider represents provider request overrides for a mode.

type ExperimentalModeProvider struct {
    Headers map[string]string `json:"headers,omitempty"`
    Body    map[string]any    `json:"body,omitempty"`
}

type GitClient

GitClient handles models.dev repository operations.

type GitClient struct {
    RepoPath string
    RepoURL  string
    Commit   string
}

func NewGitClient
func NewGitClient(outputDir string) *GitClient

NewGitClient creates a new models.dev git client.

func NewPinnedGitClient
func NewPinnedGitClient(outputDir, commit string) *GitClient

NewPinnedGitClient creates a Git client that checks out one exact commit.

func (*GitClient) BuildAPI
func (c *GitClient) BuildAPI(ctx context.Context) error

BuildAPI runs the build process to generate api.json.

func (*GitClient) Cleanup
func (c *GitClient) Cleanup() error

Cleanup removes the models.dev repository.

func (*GitClient) EnsureRepository
func (c *GitClient) EnsureRepository(ctx context.Context) error

EnsureRepository ensures the models.dev repository is available and up to date.

func (*GitClient) GetAPIPath
func (c *GitClient) GetAPIPath() string

GetAPIPath returns the path to the generated api.json file.

func (*GitClient) GetProvidersPath
func (c *GitClient) GetProvidersPath() string

GetProvidersPath returns the path to the providers directory.

func (*GitClient) PrepareRepository
func (c *GitClient) PrepareRepository(ctx context.Context) (GitInputs, error)

PrepareRepository checks out the configured commit and verifies its frozen lockfile.

type GitInputs

GitInputs records the exact source and dependency graph used for a build.

type GitInputs struct {
    Commit           string
    LockfilePath     string
    LockfileChecksum string
}

type GitSource

GitSource enhances models with models.dev data.

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

func NewGitSource
func NewGitSource(opts ...GitSourceOption) *GitSource

NewGitSource creates a new models.dev git source.

func (*GitSource) Cleanup
func (s *GitSource) Cleanup() error

Cleanup releases any resources.

func (*GitSource) Dependencies
func (s *GitSource) Dependencies() []sources.Dependency

Dependencies returns the list of external dependencies required by this source. Git source requires bun (for building) and git (for cloning).

func (*GitSource) ID
func (s *GitSource) ID() sources.ID

ID returns the ID of this source.

func (*GitSource) IsOptional
func (s *GitSource) IsOptional() bool

IsOptional returns whether this source is optional. Git source is optional - HTTP source provides the same data without dependencies.

func (*GitSource) Name
func (s *GitSource) Name() string

Name returns the human-friendly name of this source.

func (*GitSource) Observe
func (s *GitSource) Observe(ctx context.Context, opts ...sources.Option) (sources.Observation, error)

Observe returns a catalog with mapped models.dev data directly.

type GitSourceOption

GitSourceOption configures a GitSource.

type GitSourceOption func(*GitSource)

func WithGitCommit
func WithGitCommit(commit string) GitSourceOption

WithGitCommit pins Git verification to one exact commit.

func WithGitProviders
func WithGitProviders(providers catalogs.ProvidersReader) GitSourceOption

WithGitProviders configures canonical provider IDs and aliases.

func WithGitSourcesDir
func WithGitSourcesDir(dir string) GitSourceOption

WithGitSourcesDir is an alias for WithSourcesDir for backward compatibility.

func WithSourcesDir
func WithSourcesDir(dir string) GitSourceOption

WithSourcesDir configures the sources directory for the git source.

type HTTPAcquisition

HTTPAcquisition identifies which evidence path satisfied one HTTP load.

type HTTPAcquisition string

const (
    // HTTPAcquisitionFreshCache means a validated cache within TTL was used.
    HTTPAcquisitionFreshCache HTTPAcquisition = "fresh_cache"
    // HTTPAcquisitionDownloaded means a validated upstream response was promoted.
    HTTPAcquisitionDownloaded HTTPAcquisition = "downloaded"
    // HTTPAcquisitionRevalidatedCache means a conditional request returned 304.
    HTTPAcquisitionRevalidatedCache HTTPAcquisition = "revalidated_cache"
    // HTTPAcquisitionStaleCache means upstream failed and stale last-known-good evidence was used.
    HTTPAcquisitionStaleCache HTTPAcquisition = "stale_cache"
    // HTTPAcquisitionEmbeddedBootstrap means neither upstream nor cache was usable.
    HTTPAcquisitionEmbeddedBootstrap HTTPAcquisition = "embedded_bootstrap"
)

type HTTPAcquisitionResult

HTTPAcquisitionResult reports the evidence path and retained source revision.

type HTTPAcquisitionResult struct {
    Kind     HTTPAcquisition
    Revision sources.Revision
    // Issues contains classified evidence explaining why upstream data was
    // rejected before a fallback was selected.
    Issues []sources.ObservationIssue
}

type HTTPClient

HTTPClient handles HTTP downloading of models.dev api.json.

type HTTPClient struct {
    CacheDir string
    APIURL   string
    Client   *http.Client
    // contains filtered or unexported fields
}

func NewHTTPClient
func NewHTTPClient(outputDir string) *HTTPClient

NewHTTPClient creates a new models.dev HTTP client.

func (*HTTPClient) AcquireAPI
func (c *HTTPClient) AcquireAPI(ctx context.Context) (HTTPAcquisitionResult, error)

AcquireAPI ensures api.json is available and reports the exact evidence path.

func (*HTTPClient) Cleanup
func (c *HTTPClient) Cleanup() error

Cleanup removes the cache directory.

func (*HTTPClient) EnsureAPI
func (c *HTTPClient) EnsureAPI(ctx context.Context) error

EnsureAPI ensures the api.json is available and up to date.

func (*HTTPClient) GetAPIPath
func (c *HTTPClient) GetAPIPath() string

GetAPIPath returns the path to the cached api.json file.

type HTTPSource

HTTPSource enhances models with models.dev data via HTTP.

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

func NewHTTPSource
func NewHTTPSource(opts ...HTTPSourceOption) *HTTPSource

NewHTTPSource creates a new models.dev HTTP source.

func (*HTTPSource) Cleanup
func (s *HTTPSource) Cleanup() error

Cleanup releases any resources.

func (*HTTPSource) Dependencies
func (s *HTTPSource) Dependencies() []sources.Dependency

Dependencies returns the list of external dependencies. HTTP source has no external dependencies.

func (*HTTPSource) ID
func (s *HTTPSource) ID() sources.ID

ID returns the ID of this source.

func (*HTTPSource) IsOptional
func (s *HTTPSource) IsOptional() bool

IsOptional returns whether this source is optional. HTTP source is optional - git source provides same data, and we can work without models.dev.

func (*HTTPSource) Name
func (s *HTTPSource) Name() string

Name returns the human-friendly name of this source.

func (*HTTPSource) Observe
func (s *HTTPSource) Observe(ctx context.Context, opts ...sources.Option) (sources.Observation, error)

Observe returns a catalog with mapped models.dev data directly.

type HTTPSourceOption

HTTPSourceOption configures an HTTPSource.

type HTTPSourceOption func(*HTTPSource)

func WithHTTPProviders
func WithHTTPProviders(providers catalogs.ProvidersReader) HTTPSourceOption

WithHTTPProviders configures canonical provider IDs and aliases.

func WithHTTPSourcesDir
func WithHTTPSourcesDir(dir string) HTTPSourceOption

WithHTTPSourcesDir configures the sources directory for the HTTP source.

type Interleaved

Interleaved represents models.dev interleaved reasoning response metadata.

type Interleaved struct {
    Enabled bool
    Field   string
}

func (*Interleaved) UnmarshalJSON
func (i *Interleaved) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both boolean and object forms of models.dev interleaved metadata.

type Limit

Limit represents model limits.

type Limit struct {
    Context int `json:"context"`
    Input   int `json:"input"`
    Output  int `json:"output"`
    // contains filtered or unexported fields
}

func (*Limit) UnmarshalJSON
func (l *Limit) UnmarshalJSON(data []byte) error

UnmarshalJSON retains missing, null, zero, and non-zero limit states.

type Modalities

Modalities represents input/output modalities.

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

type Model

Model represents a model in models.dev.

type Model struct {
    ID               string                           `json:"id"`
    Name             string                           `json:"name"`
    Description      string                           `json:"description"`
    Family           string                           `json:"family"`
    Status           string                           `json:"status,omitempty"`
    Attachment       bool                             `json:"attachment"`
    Reasoning        bool                             `json:"reasoning"`
    ReasoningOptions []ReasoningOption                `json:"reasoning_options,omitempty"`
    StructuredOutput bool                             `json:"structured_output"`
    Temperature      bool                             `json:"temperature"`
    ToolCall         bool                             `json:"tool_call"`
    Knowledge        *string                          `json:"knowledge,omitempty"`
    Provider         *ModelProvider                   `json:"provider,omitempty"`
    Interleaved      *Interleaved                     `json:"interleaved,omitempty"`
    ReleaseDate      string                           `json:"release_date"`
    LastUpdated      string                           `json:"last_updated"`
    Modalities       Modalities                       `json:"modalities"`
    OpenWeights      *bool                            `json:"open_weights,omitempty"`
    Cost             *Cost                            `json:"cost,omitempty"`
    Limit            Limit                            `json:"limit"`
    Experimental     *Experimental                    `json:"experimental,omitempty"`
    UnknownFields    []sourcepayload.UnknownJSONField `json:"-"`
    // contains filtered or unexported fields
}

func (*Model) ToStarmapModel
func (m *Model) ToStarmapModel() (*catalogs.Model, error)

ToStarmapModel converts a Model to a starmap.Model.

func (*Model) UnmarshalJSON
func (m *Model) UnmarshalJSON(data []byte) error

UnmarshalJSON retains fingerprints for additive model fields.

type ModelProvider

ModelProvider represents model-level provider invocation metadata.

type ModelProvider struct {
    NPM   string `json:"npm,omitempty"`
    API   string `json:"api,omitempty"`
    Shape string `json:"shape,omitempty"`
}

type Provider

Provider represents a provider in models.dev.

type Provider struct {
    ID            string                           `json:"id"`
    Env           []string                         `json:"env"`
    NPM           string                           `json:"npm"`
    API           *string                          `json:"api,omitempty"`
    Name          string                           `json:"name"`
    Doc           string                           `json:"doc"`
    Models        map[string]Model                 `json:"models"`
    UnknownFields []sourcepayload.UnknownJSONField `json:"-"`
    RecordReport  sourcepayload.RecordReport       `json:"-"`
}

func (*Provider) Model
func (p *Provider) Model(modelID string) (*Model, bool)

Model returns a specific model from a provider.

func (*Provider) ToStarmapProvider
func (p *Provider) ToStarmapProvider() (*catalogs.Provider, error)

ToStarmapProvider converts a Provider to a starmap.Provider.

func (*Provider) UnmarshalJSON
func (p *Provider) UnmarshalJSON(data []byte) error

UnmarshalJSON retains fingerprints for additive provider fields.

type ReasoningOption

ReasoningOption represents a configurable reasoning option in models.dev.

type ReasoningOption struct {
    Type   string   `json:"type"`
    Values []string `json:"values"`
    Min    *int     `json:"min,omitempty"`
    Max    *int     `json:"max,omitempty"`
}

type TierPrices

TierPrices represents prices that may appear in a pricing tier.

type TierPrices struct {
    Input      *float64 `json:"input,omitempty"`
    Output     *float64 `json:"output,omitempty"`
    CacheRead  *float64 `json:"cache_read,omitempty"`
    CacheWrite *float64 `json:"cache_write,omitempty"`
    InputAudio *float64 `json:"input_audio,omitempty"`
}

Generated by gomarkdoc

Documentation

Index

Constants

View Source
const (
	// ModelsDevAPIURL is the URL for the models.dev API.
	ModelsDevAPIURL = "https://models.dev/api.json"
	// HTTPCacheTTL is the cache time-to-live for HTTP responses.
	HTTPCacheTTL = 1 * time.Hour
)
View Source
const (
	// ModelsDevRepoURL is the URL for the models.dev git repository.
	ModelsDevRepoURL = "https://github.com/sst/models.dev.git"
)

Variables

This section is empty.

Functions

func ConvertToStarmapModel

func ConvertToStarmapModel(mdModel Model) *catalogs.Model

ConvertToStarmapModel converts a models.dev model to a starmap model. This is shared between GitSource and HTTPSource to avoid duplication.

func CopyAuthorLogos added in v0.0.20

func CopyAuthorLogos(outputDir string, authors []catalogs.Author, providers catalogs.ProvidersReader) error

CopyAuthorLogos copies author logos from models.dev provider logos to author directories. Since models.dev doesn't have a separate authors directory, we copy from the provider directory when the author ID matches a provider ID (or alias).

func CopyProviderLogos

func CopyProviderLogos(outputDir string, providers []*catalogs.Provider) error

CopyProviderLogos copies provider logos from models.dev to output directory. It tries the provider ID first, then checks aliases if the primary ID isn't found.

Types

type API

type API map[string]Provider

API represents the structure of models.dev api.json.

func ParseAPI

func ParseAPI(apiPath string) (*API, error)

ParseAPI parses the api.json file and returns an API.

func (*API) GetProvider

func (a *API) GetProvider(providerID catalogs.ProviderID) (*Provider, bool)

GetProvider returns a specific provider from the API data.

func (*API) UnmarshalJSON added in v0.2.0

func (a *API) UnmarshalJSON(data []byte) error

UnmarshalJSON bounds providers and model records before typed decoding.

type APIPromotion added in v0.1.0

type APIPromotion struct {
	Checksum           string `json:"checksum"`
	SizeBytes          int64  `json:"size_bytes"`
	ProviderCount      int    `json:"provider_count"`
	ModelCount         int    `json:"model_count"`
	RejectedModelCount int    `json:"rejected_model_count"`
}

APIPromotion describes a models.dev payload that passed typed and semantic validation and was atomically promoted to its destination.

func PromoteAPIFile added in v0.1.0

func PromoteAPIFile(candidatePath, destinationPath string) (APIPromotion, error)

PromoteAPIFile validates a downloaded models.dev payload against the same typed, semantic, and completeness policy used by runtime cache promotion, then atomically replaces the destination. A failed candidate leaves the destination byte-for-byte unchanged.

type Client

type Client = GitClient

Client is an alias for backward compatibility.

func NewClient

func NewClient(outputDir string) *Client

NewClient creates a new models.dev git client.

type Cost

type Cost struct {
	Input           *float64    `json:"input,omitempty"`
	Output          *float64    `json:"output,omitempty"`
	Reasoning       *float64    `json:"reasoning,omitempty"`
	Cache           *float64    `json:"cache,omitempty"`       // Legacy cache field
	CacheRead       *float64    `json:"cache_read,omitempty"`  // Cache read costs
	CacheWrite      *float64    `json:"cache_write,omitempty"` // Cache write costs
	InputAudio      *float64    `json:"input_audio,omitempty"`
	OutputAudio     *float64    `json:"output_audio,omitempty"`
	Tiers           []CostTier  `json:"tiers,omitempty"`
	ContextOver200K *TierPrices `json:"context_over_200k,omitempty"`
}

Cost represents pricing information.

type CostTier added in v0.1.0

type CostTier struct {
	TierPrices
	Tier CostTierInfo `json:"tier"`
}

CostTier represents a conditional pricing tier in models.dev.

type CostTierInfo added in v0.1.0

type CostTierInfo struct {
	Type string `json:"type"`
	Size int64  `json:"size"`
}

CostTierInfo represents the dimension and threshold for a models.dev pricing tier.

type Experimental added in v0.1.0

type Experimental struct {
	Enabled bool                        `json:"-"`
	Modes   map[string]ExperimentalMode `json:"modes,omitempty"`
}

Experimental represents experimental models.dev model metadata.

func (*Experimental) UnmarshalJSON added in v0.1.0

func (e *Experimental) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both the legacy boolean marker and the current object form containing mode overrides.

type ExperimentalMode added in v0.1.0

type ExperimentalMode struct {
	Cost     *TierPrices               `json:"cost,omitempty"`
	Provider *ExperimentalModeProvider `json:"provider,omitempty"`
}

ExperimentalMode represents a mode-specific models.dev override.

type ExperimentalModeProvider added in v0.1.0

type ExperimentalModeProvider struct {
	Headers map[string]string `json:"headers,omitempty"`
	Body    map[string]any    `json:"body,omitempty"`
}

ExperimentalModeProvider represents provider request overrides for a mode.

type GitClient

type GitClient struct {
	RepoPath string
	RepoURL  string
	Commit   string
}

GitClient handles models.dev repository operations.

func NewGitClient

func NewGitClient(outputDir string) *GitClient

NewGitClient creates a new models.dev git client.

func NewPinnedGitClient added in v0.1.0

func NewPinnedGitClient(outputDir, commit string) *GitClient

NewPinnedGitClient creates a Git client that checks out one exact commit.

func (*GitClient) BuildAPI

func (c *GitClient) BuildAPI(ctx context.Context) error

BuildAPI runs the build process to generate api.json.

func (*GitClient) Cleanup

func (c *GitClient) Cleanup() error

Cleanup removes the models.dev repository.

func (*GitClient) EnsureRepository

func (c *GitClient) EnsureRepository(ctx context.Context) error

EnsureRepository ensures the models.dev repository is available and up to date.

func (*GitClient) GetAPIPath

func (c *GitClient) GetAPIPath() string

GetAPIPath returns the path to the generated api.json file.

func (*GitClient) GetProvidersPath

func (c *GitClient) GetProvidersPath() string

GetProvidersPath returns the path to the providers directory.

func (*GitClient) PrepareRepository added in v0.1.0

func (c *GitClient) PrepareRepository(ctx context.Context) (GitInputs, error)

PrepareRepository checks out the configured commit and verifies its frozen lockfile.

type GitInputs added in v0.1.0

type GitInputs struct {
	Commit           string
	LockfilePath     string
	LockfileChecksum string
}

GitInputs records the exact source and dependency graph used for a build.

type GitSource

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

GitSource enhances models with models.dev data.

func NewGitSource

func NewGitSource(opts ...GitSourceOption) *GitSource

NewGitSource creates a new models.dev git source.

func (*GitSource) Cleanup

func (s *GitSource) Cleanup() error

Cleanup releases any resources.

func (*GitSource) Dependencies added in v0.0.17

func (s *GitSource) Dependencies() []sources.Dependency

Dependencies returns the list of external dependencies required by this source. Git source requires bun (for building) and git (for cloning).

func (*GitSource) ID added in v0.0.15

func (s *GitSource) ID() sources.ID

ID returns the ID of this source.

func (*GitSource) IsOptional added in v0.0.17

func (s *GitSource) IsOptional() bool

IsOptional returns whether this source is optional. Git source is optional - HTTP source provides the same data without dependencies.

func (*GitSource) Name added in v0.0.17

func (s *GitSource) Name() string

Name returns the human-friendly name of this source.

func (*GitSource) Observe added in v0.1.0

func (s *GitSource) Observe(ctx context.Context, opts ...sources.Option) (sources.Observation, error)

Observe returns a catalog with mapped models.dev data directly.

type GitSourceOption added in v0.0.10

type GitSourceOption func(*GitSource)

GitSourceOption configures a GitSource.

func WithGitCommit added in v0.1.0

func WithGitCommit(commit string) GitSourceOption

WithGitCommit pins Git verification to one exact commit.

func WithGitProviders added in v0.2.0

func WithGitProviders(providers catalogs.ProvidersReader) GitSourceOption

WithGitProviders configures canonical provider IDs and aliases.

func WithGitSourcesDir added in v0.0.10

func WithGitSourcesDir(dir string) GitSourceOption

WithGitSourcesDir is an alias for WithSourcesDir for backward compatibility.

func WithSourcesDir added in v0.0.10

func WithSourcesDir(dir string) GitSourceOption

WithSourcesDir configures the sources directory for the git source.

type HTTPAcquisition added in v0.1.0

type HTTPAcquisition string

HTTPAcquisition identifies which evidence path satisfied one HTTP load.

const (
	// HTTPAcquisitionFreshCache means a validated cache within TTL was used.
	HTTPAcquisitionFreshCache HTTPAcquisition = "fresh_cache"
	// HTTPAcquisitionDownloaded means a validated upstream response was promoted.
	HTTPAcquisitionDownloaded HTTPAcquisition = "downloaded"
	// HTTPAcquisitionRevalidatedCache means a conditional request returned 304.
	HTTPAcquisitionRevalidatedCache HTTPAcquisition = "revalidated_cache"
	// HTTPAcquisitionStaleCache means upstream failed and stale last-known-good evidence was used.
	HTTPAcquisitionStaleCache HTTPAcquisition = "stale_cache"
	// HTTPAcquisitionEmbeddedBootstrap means neither upstream nor cache was usable.
	HTTPAcquisitionEmbeddedBootstrap HTTPAcquisition = "embedded_bootstrap"
)

type HTTPAcquisitionResult added in v0.1.0

type HTTPAcquisitionResult struct {
	Kind     HTTPAcquisition
	Revision sources.Revision
	// Issues contains classified evidence explaining why upstream data was
	// rejected before a fallback was selected.
	Issues []sources.ObservationIssue
}

HTTPAcquisitionResult reports the evidence path and retained source revision.

type HTTPClient

type HTTPClient struct {
	CacheDir string
	APIURL   string
	Client   *http.Client
	// contains filtered or unexported fields
}

HTTPClient handles HTTP downloading of models.dev api.json.

func NewHTTPClient

func NewHTTPClient(outputDir string) *HTTPClient

NewHTTPClient creates a new models.dev HTTP client.

func (*HTTPClient) AcquireAPI added in v0.1.0

func (c *HTTPClient) AcquireAPI(ctx context.Context) (HTTPAcquisitionResult, error)

AcquireAPI ensures api.json is available and reports the exact evidence path.

func (*HTTPClient) Cleanup

func (c *HTTPClient) Cleanup() error

Cleanup removes the cache directory.

func (*HTTPClient) EnsureAPI

func (c *HTTPClient) EnsureAPI(ctx context.Context) error

EnsureAPI ensures the api.json is available and up to date.

func (*HTTPClient) GetAPIPath

func (c *HTTPClient) GetAPIPath() string

GetAPIPath returns the path to the cached api.json file.

type HTTPSource

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

HTTPSource enhances models with models.dev data via HTTP.

func NewHTTPSource

func NewHTTPSource(opts ...HTTPSourceOption) *HTTPSource

NewHTTPSource creates a new models.dev HTTP source.

func (*HTTPSource) Cleanup

func (s *HTTPSource) Cleanup() error

Cleanup releases any resources.

func (*HTTPSource) Dependencies added in v0.0.17

func (s *HTTPSource) Dependencies() []sources.Dependency

Dependencies returns the list of external dependencies. HTTP source has no external dependencies.

func (*HTTPSource) ID added in v0.0.15

func (s *HTTPSource) ID() sources.ID

ID returns the ID of this source.

func (*HTTPSource) IsOptional added in v0.0.17

func (s *HTTPSource) IsOptional() bool

IsOptional returns whether this source is optional. HTTP source is optional - git source provides same data, and we can work without models.dev.

func (*HTTPSource) Name added in v0.0.17

func (s *HTTPSource) Name() string

Name returns the human-friendly name of this source.

func (*HTTPSource) Observe added in v0.1.0

func (s *HTTPSource) Observe(ctx context.Context, opts ...sources.Option) (sources.Observation, error)

Observe returns a catalog with mapped models.dev data directly.

type HTTPSourceOption added in v0.0.10

type HTTPSourceOption func(*HTTPSource)

HTTPSourceOption configures an HTTPSource.

func WithHTTPProviders added in v0.2.0

func WithHTTPProviders(providers catalogs.ProvidersReader) HTTPSourceOption

WithHTTPProviders configures canonical provider IDs and aliases.

func WithHTTPSourcesDir added in v0.0.10

func WithHTTPSourcesDir(dir string) HTTPSourceOption

WithHTTPSourcesDir configures the sources directory for the HTTP source.

type Interleaved added in v0.1.0

type Interleaved struct {
	Enabled bool
	Field   string
}

Interleaved represents models.dev interleaved reasoning response metadata.

func (*Interleaved) UnmarshalJSON added in v0.1.0

func (i *Interleaved) UnmarshalJSON(data []byte) error

UnmarshalJSON accepts both boolean and object forms of models.dev interleaved metadata.

type Limit

type Limit struct {
	Context int `json:"context"`
	Input   int `json:"input"`
	Output  int `json:"output"`
	// contains filtered or unexported fields
}

Limit represents model limits.

func (*Limit) UnmarshalJSON added in v0.2.0

func (l *Limit) UnmarshalJSON(data []byte) error

UnmarshalJSON retains missing, null, zero, and non-zero limit states.

type Modalities

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

Modalities represents input/output modalities.

type Model

type Model struct {
	ID               string                           `json:"id"`
	Name             string                           `json:"name"`
	Description      string                           `json:"description"`
	Family           string                           `json:"family"`
	Status           string                           `json:"status,omitempty"`
	Attachment       bool                             `json:"attachment"`
	Reasoning        bool                             `json:"reasoning"`
	ReasoningOptions []ReasoningOption                `json:"reasoning_options,omitempty"`
	StructuredOutput bool                             `json:"structured_output"`
	Temperature      bool                             `json:"temperature"`
	ToolCall         bool                             `json:"tool_call"`
	Knowledge        *string                          `json:"knowledge,omitempty"`
	Provider         *ModelProvider                   `json:"provider,omitempty"`
	Interleaved      *Interleaved                     `json:"interleaved,omitempty"`
	ReleaseDate      string                           `json:"release_date"`
	LastUpdated      string                           `json:"last_updated"`
	Modalities       Modalities                       `json:"modalities"`
	OpenWeights      *bool                            `json:"open_weights,omitempty"`
	Cost             *Cost                            `json:"cost,omitempty"`
	Limit            Limit                            `json:"limit"`
	Experimental     *Experimental                    `json:"experimental,omitempty"`
	UnknownFields    []sourcepayload.UnknownJSONField `json:"-"`
	// contains filtered or unexported fields
}

Model represents a model in models.dev.

func (*Model) ToStarmapModel

func (m *Model) ToStarmapModel() (*catalogs.Model, error)

ToStarmapModel converts a Model to a starmap.Model.

func (*Model) UnmarshalJSON added in v0.1.0

func (m *Model) UnmarshalJSON(data []byte) error

UnmarshalJSON retains fingerprints for additive model fields.

type ModelProvider added in v0.1.0

type ModelProvider struct {
	NPM   string `json:"npm,omitempty"`
	API   string `json:"api,omitempty"`
	Shape string `json:"shape,omitempty"`
}

ModelProvider represents model-level provider invocation metadata.

type Provider

type Provider struct {
	ID            string                           `json:"id"`
	Env           []string                         `json:"env"`
	NPM           string                           `json:"npm"`
	API           *string                          `json:"api,omitempty"`
	Name          string                           `json:"name"`
	Doc           string                           `json:"doc"`
	Models        map[string]Model                 `json:"models"`
	UnknownFields []sourcepayload.UnknownJSONField `json:"-"`
	RecordReport  sourcepayload.RecordReport       `json:"-"`
}

Provider represents a provider in models.dev.

func (*Provider) Model

func (p *Provider) Model(modelID string) (*Model, bool)

Model returns a specific model from a provider.

func (*Provider) ToStarmapProvider

func (p *Provider) ToStarmapProvider() (*catalogs.Provider, error)

ToStarmapProvider converts a Provider to a starmap.Provider.

func (*Provider) UnmarshalJSON added in v0.1.0

func (p *Provider) UnmarshalJSON(data []byte) error

UnmarshalJSON retains fingerprints for additive provider fields.

type ReasoningOption added in v0.1.0

type ReasoningOption struct {
	Type   string   `json:"type"`
	Values []string `json:"values"`
	Min    *int     `json:"min,omitempty"`
	Max    *int     `json:"max,omitempty"`
}

ReasoningOption represents a configurable reasoning option in models.dev.

type TierPrices added in v0.1.0

type TierPrices struct {
	Input      *float64 `json:"input,omitempty"`
	Output     *float64 `json:"output,omitempty"`
	CacheRead  *float64 `json:"cache_read,omitempty"`
	CacheWrite *float64 `json:"cache_write,omitempty"`
	InputAudio *float64 `json:"input_audio,omitempty"`
}

TierPrices represents prices that may appear in a pricing tier.

Jump to

Keyboard shortcuts

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