provider.go

  1package catwalk
  2
  3// Type represents the type of AI provider.
  4type Type string
  5
  6// All the supported AI provider types.
  7const (
  8	TypeOpenAI       Type = "openai"
  9	TypeOpenAICompat Type = "openai-compat"
 10	TypeOpenRouter   Type = "openrouter"
 11	TypeAnthropic    Type = "anthropic"
 12	TypeGoogle       Type = "google"
 13	TypeAzure        Type = "azure"
 14	TypeBedrock      Type = "bedrock"
 15	TypeVertexAI     Type = "google-vertex"
 16)
 17
 18// InferenceProvider represents the inference provider identifier.
 19type InferenceProvider string
 20
 21// All the inference providers supported by the system.
 22const (
 23	InferenceProviderOpenAI      InferenceProvider = "openai"
 24	InferenceProviderAnthropic   InferenceProvider = "anthropic"
 25	InferenceProviderSynthetic   InferenceProvider = "synthetic"
 26	InferenceProviderGemini      InferenceProvider = "gemini"
 27	InferenceProviderAzure       InferenceProvider = "azure"
 28	InferenceProviderBedrock     InferenceProvider = "bedrock"
 29	InferenceProviderVertexAI    InferenceProvider = "vertexai"
 30	InferenceProviderXAI         InferenceProvider = "xai"
 31	InferenceProviderZAI         InferenceProvider = "zai"
 32	InferenceProviderGROQ        InferenceProvider = "groq"
 33	InferenceProviderOpenRouter  InferenceProvider = "openrouter"
 34	InferenceProviderCerebras    InferenceProvider = "cerebras"
 35	InferenceProviderVenice      InferenceProvider = "venice"
 36	InferenceProviderChutes      InferenceProvider = "chutes"
 37	InferenceProviderHuggingFace InferenceProvider = "huggingface"
 38	InferenceAIHubMix            InferenceProvider = "aihubmix"
 39	InferenceKimiCoding          InferenceProvider = "kimi-coding"
 40	InferenceProviderCopilot     InferenceProvider = "copilot"
 41)
 42
 43// Provider represents an AI provider configuration.
 44type Provider struct {
 45	Name                string            `json:"name"`
 46	ID                  InferenceProvider `json:"id"`
 47	APIKey              string            `json:"api_key,omitempty"`
 48	APIEndpoint         string            `json:"api_endpoint,omitempty"`
 49	Type                Type              `json:"type,omitempty"`
 50	DefaultLargeModelID string            `json:"default_large_model_id,omitempty"`
 51	DefaultSmallModelID string            `json:"default_small_model_id,omitempty"`
 52	Models              []Model           `json:"models,omitempty"`
 53	DefaultHeaders      map[string]string `json:"default_headers,omitempty"`
 54}
 55
 56// ModelOptions stores extra options for models.
 57type ModelOptions struct {
 58	Temperature      *float64       `json:"temperature,omitempty"`
 59	TopP             *float64       `json:"top_p,omitempty"`
 60	TopK             *int64         `json:"top_k,omitempty"`
 61	FrequencyPenalty *float64       `json:"frequency_penalty,omitempty"`
 62	PresencePenalty  *float64       `json:"presence_penalty,omitempty"`
 63	ProviderOptions  map[string]any `json:"provider_options,omitempty"`
 64}
 65
 66// Model represents an AI model configuration.
 67type Model struct {
 68	ID                     string       `json:"id"`
 69	Name                   string       `json:"name"`
 70	CostPer1MIn            float64      `json:"cost_per_1m_in"`
 71	CostPer1MOut           float64      `json:"cost_per_1m_out"`
 72	CostPer1MInCached      float64      `json:"cost_per_1m_in_cached"`
 73	CostPer1MOutCached     float64      `json:"cost_per_1m_out_cached"`
 74	ContextWindow          int64        `json:"context_window"`
 75	DefaultMaxTokens       int64        `json:"default_max_tokens"`
 76	CanReason              bool         `json:"can_reason"`
 77	ReasoningLevels        []string     `json:"reasoning_levels,omitempty"`
 78	DefaultReasoningEffort string       `json:"default_reasoning_effort,omitempty"`
 79	SupportsImages         bool         `json:"supports_attachments"`
 80	Options                ModelOptions `json:"options"`
 81}
 82
 83// KnownProviders returns all the known inference providers.
 84func KnownProviders() []InferenceProvider {
 85	return []InferenceProvider{
 86		InferenceProviderOpenAI,
 87		InferenceProviderSynthetic,
 88		InferenceProviderAnthropic,
 89		InferenceProviderGemini,
 90		InferenceProviderAzure,
 91		InferenceProviderBedrock,
 92		InferenceProviderVertexAI,
 93		InferenceProviderXAI,
 94		InferenceProviderZAI,
 95		InferenceProviderGROQ,
 96		InferenceProviderOpenRouter,
 97		InferenceProviderCerebras,
 98		InferenceProviderVenice,
 99		InferenceProviderChutes,
100		InferenceProviderHuggingFace,
101		InferenceAIHubMix,
102		InferenceKimiCoding,
103		InferenceProviderCopilot,
104	}
105}
106
107// KnownProviderTypes returns all the known inference providers types.
108func KnownProviderTypes() []Type {
109	return []Type{
110		TypeOpenAI,
111		TypeOpenAICompat,
112		TypeOpenRouter,
113		TypeAnthropic,
114		TypeGoogle,
115		TypeAzure,
116		TypeBedrock,
117		TypeVertexAI,
118	}
119}