Documentation
¶
Overview ¶
Package providers manages AI provider configurations and pricing data. It integrates with Catwalk's provider configs to provide accurate cost estimates.
Index ¶
Constants ¶
const ( // CatwalkBaseURL is the base URL for Catwalk's provider configs on GitHub CatwalkBaseURL = "https://raw.githubusercontent.com/charmbracelet/catwalk/main/internal/providers/configs" // SchemaVersion is the current version of the provider config schema SchemaVersion = "1.0" )
Variables ¶
var ProviderFileNames = []string{
"aihubmix.json",
"anthropic.json",
"azure.json",
"bedrock.json",
"cerebras.json",
"chutes.json",
"deepseek.json",
"gemini.json",
"groq.json",
"huggingface.json",
"openai.json",
"openrouter.json",
"venice.json",
"vertexai.json",
"xai.json",
"zai.json",
}
ProviderFileNames lists all available provider config files from Catwalk
Functions ¶
This section is empty.
Types ¶
type Model ¶
type Model struct {
// ID is the unique identifier for the model (e.g., "claude-sonnet-4-5-20250929")
ID string `json:"id"`
// Name is the display name of the model
Name string `json:"name"`
// CostPer1MIn is the cost per 1 million input tokens in USD
CostPer1MIn float64 `json:"cost_per_1m_in"`
// CostPer1MOut is the cost per 1 million output tokens in USD
CostPer1MOut float64 `json:"cost_per_1m_out"`
// CostPer1MInCached is the cost per 1 million cached input tokens in USD
CostPer1MInCached float64 `json:"cost_per_1m_in_cached,omitempty"`
// CostPer1MOutCached is the cost per 1 million cached output tokens in USD
CostPer1MOutCached float64 `json:"cost_per_1m_out_cached,omitempty"`
// ContextWindow is the maximum context length in tokens
ContextWindow int `json:"context_window"`
// DefaultMaxTokens is the default maximum output tokens
DefaultMaxTokens int `json:"default_max_tokens"`
// CanReason indicates if the model supports extended reasoning
CanReason bool `json:"can_reason"`
// SupportsAttachments indicates if the model supports file attachments
SupportsAttachments bool `json:"supports_attachments"`
}
Model represents a specific AI model with its pricing and capabilities.
type Provider ¶
type Provider struct {
// Name is the display name of the provider (e.g., "Anthropic", "OpenAI")
Name string `json:"name"`
// ID is the unique identifier for the provider (e.g., "anthropic", "openai")
ID string `json:"id"`
// Type indicates the API compatibility (e.g., "openai", "anthropic")
Type string `json:"type"`
// APIKey is the environment variable name for the API key
APIKey string `json:"api_key,omitempty"`
// APIEndpoint is the base URL for API requests
APIEndpoint string `json:"api_endpoint,omitempty"`
// DefaultLargeModelID is the default large model for this provider
DefaultLargeModelID string `json:"default_large_model_id,omitempty"`
// DefaultSmallModelID is the default small model for this provider
DefaultSmallModelID string `json:"default_small_model_id,omitempty"`
// Models is the list of available models for this provider
Models []Model `json:"models"`
}
Provider represents an AI service provider configuration.
func FetchProviderFromCatwalk ¶
FetchProviderFromCatwalk fetches a single provider config from Catwalk's GitHub repository.
type ProviderConfig ¶
type ProviderConfig struct {
// Version is the schema version for future compatibility
Version string `json:"version"`
// UpdatedAt is the timestamp when this config was last updated
UpdatedAt string `json:"updated_at"`
// Source indicates where this config was fetched from
Source string `json:"source"`
// Providers is the list of all provider configurations
Providers []Provider `json:"providers"`
}
ProviderConfig represents the consolidated provider configuration file.
func FetchProvidersFromCatwalk ¶
func FetchProvidersFromCatwalk() (*ProviderConfig, error)
FetchProvidersFromCatwalk fetches all provider configs from Catwalk's GitHub repository and returns a consolidated ProviderConfig.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages provider configurations and pricing lookups.
func GetRegistry ¶
func GetRegistry() *Registry
GetRegistry returns the global provider registry singleton. It loads the embedded providers.json by default, but will override with ~/.agentpipe/providers.json if it exists.
func (*Registry) GetConfig ¶
func (r *Registry) GetConfig() *ProviderConfig
GetConfig returns the current provider configuration.
func (*Registry) GetModel ¶
GetModel performs smart model lookup: 1. Try exact match on model ID 2. Try prefix match (e.g., "claude-sonnet-4" matches "claude-sonnet-4-5") 3. Try fuzzy match (contains) Returns the model and the provider it belongs to.
func (*Registry) GetProvider ¶
GetProvider returns a provider by ID.
func (*Registry) ListProviders ¶
ListProviders returns all available providers.