Documentation
¶
Index ¶
- Constants
- func ConvertToStarmapModel(mdModel Model) *catalogs.Model
- func CopyAuthorLogos(outputDir string, authors []catalogs.Author, ...) error
- func CopyProviderLogos(outputDir string, providers []*catalogs.Provider) error
- type API
- type APIPromotion
- type Client
- type Cost
- type CostTier
- type CostTierInfo
- type Experimental
- type ExperimentalMode
- type ExperimentalModeProvider
- type GitClient
- func (c *GitClient) BuildAPI(ctx context.Context) error
- func (c *GitClient) Cleanup() error
- func (c *GitClient) EnsureRepository(ctx context.Context) error
- func (c *GitClient) GetAPIPath() string
- func (c *GitClient) GetProvidersPath() string
- func (c *GitClient) PrepareRepository(ctx context.Context) (GitInputs, error)
- type GitInputs
- type GitSource
- func (s *GitSource) Cleanup() error
- func (s *GitSource) Dependencies() []sources.Dependency
- func (s *GitSource) ID() sources.ID
- func (s *GitSource) IsOptional() bool
- func (s *GitSource) Name() string
- func (s *GitSource) Observe(ctx context.Context, opts ...sources.Option) (sources.Observation, error)
- type GitSourceOption
- type HTTPAcquisition
- type HTTPAcquisitionResult
- type HTTPClient
- type HTTPSource
- func (s *HTTPSource) Cleanup() error
- func (s *HTTPSource) Dependencies() []sources.Dependency
- func (s *HTTPSource) ID() sources.ID
- func (s *HTTPSource) IsOptional() bool
- func (s *HTTPSource) Name() string
- func (s *HTTPSource) Observe(ctx context.Context, opts ...sources.Option) (sources.Observation, error)
- type HTTPSourceOption
- type Interleaved
- type Limit
- type Modalities
- type Model
- type ModelProvider
- type Provider
- type ReasoningOption
- type TierPrices
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"
)
Variables ¶
This section is empty.
Functions ¶
func ConvertToStarmapModel ¶
ConvertToStarmapModel converts a models.dev model to a Starmap model. GitSource and HTTPSource share it to avoid duplicate conversion logic.
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 does not have a separate authors directory, we copy from the provider directory when the author ID matches a provider ID (or alias).
Types ¶
type API ¶
API represents the structure of models.dev api.json.
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
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 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
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 ¶
GitClient handles models.dev repository operations.
func NewGitClient ¶
NewGitClient creates a new models.dev git client.
func NewPinnedGitClient ¶ added in v0.1.0
NewPinnedGitClient creates a Git client that checks out one exact commit.
func (*GitClient) EnsureRepository ¶
EnsureRepository verifies the models.dev repository is available and up to date.
func (*GitClient) GetAPIPath ¶
GetAPIPath returns the path to the generated api.json file.
func (*GitClient) GetProvidersPath ¶
GetProvidersPath returns the path to the providers directory.
type GitInputs ¶ added in v0.1.0
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) 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) IsOptional ¶ added in v0.0.17
IsOptional returns whether this source is optional. Git source is optional - HTTP source provides the same data without dependencies.
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 fresh cache entry satisfied the load. HTTPAcquisitionFreshCache HTTPAcquisition = "fresh_cache" // HTTPAcquisitionDownloaded means a successful request supplied new data. HTTPAcquisitionDownloaded HTTPAcquisition = "downloaded" // HTTPAcquisitionRevalidatedCache means a conditional request returned 304. HTTPAcquisitionRevalidatedCache HTTPAcquisition = "revalidated_cache" // HTTPAcquisitionStaleCache means a stale cache entry supplied fallback data. 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 explains why validation rejected upstream data and selected a fallback.
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 verifies 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 verifies 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) 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
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
UnmarshalJSON retains missing, null, zero, and non-zero limit states.
type Modalities ¶
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 ¶
ToStarmapModel converts a Model to a starmap.Model.
func (*Model) UnmarshalJSON ¶ added in v0.1.0
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) ToStarmapProvider ¶
ToStarmapProvider converts a Provider to a starmap.Provider.
func (*Provider) UnmarshalJSON ¶ added in v0.1.0
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.