provider.go

 1// Package provider provides types and constants for AI providers.
 2package provider
 3
 4// Type represents the type of AI provider.
 5type Type string
 6
 7// All the supported AI provider types.
 8const (
 9	TypeOpenAI     Type = "openai"
10	TypeAnthropic  Type = "anthropic"
11	TypeGemini     Type = "gemini"
12	TypeAzure      Type = "azure"
13	TypeBedrock    Type = "bedrock"
14	TypeVertexAI   Type = "vertexai"
15	TypeXAI        Type = "xai"
16	TypeOpenRouter Type = "openrouter"
17)
18
19// InferenceProvider represents the inference provider identifier.
20type InferenceProvider string
21
22// All the inference providers supported by the system.
23const (
24	InferenceProviderOpenAI     InferenceProvider = "openai"
25	InferenceProviderAnthropic  InferenceProvider = "anthropic"
26	InferenceProviderGemini     InferenceProvider = "gemini"
27	InferenceProviderAzure      InferenceProvider = "azure"
28	InferenceProviderBedrock    InferenceProvider = "bedrock"
29	InferenceProviderVertexAI   InferenceProvider = "vertexai"
30	InferenceProviderXAI        InferenceProvider = "xai"
31	InferenceProviderOpenRouter InferenceProvider = "openrouter"
32)
33
34// Provider represents an AI provider configuration.
35type Provider struct {
36	Name           string            `json:"name"`
37	ID             InferenceProvider `json:"id"`
38	APIKey         string            `json:"api_key,omitempty"`
39	APIEndpoint    string            `json:"api_endpoint,omitempty"`
40	Type           Type              `json:"type,omitempty"`
41	DefaultModelID string            `json:"default_model_id,omitempty"`
42	Models         []Model           `json:"models,omitempty"`
43}
44
45// Model represents an AI model configuration.
46type Model struct {
47	ID                 string  `json:"id"`
48	Name               string  `json:"model"`
49	CostPer1MIn        float64 `json:"cost_per_1m_in"`
50	CostPer1MOut       float64 `json:"cost_per_1m_out"`
51	CostPer1MInCached  float64 `json:"cost_per_1m_in_cached"`
52	CostPer1MOutCached float64 `json:"cost_per_1m_out_cached"`
53	ContextWindow      int64   `json:"context_window"`
54	DefaultMaxTokens   int64   `json:"default_max_tokens"`
55	CanReason          bool    `json:"can_reason"`
56	SupportsImages     bool    `json:"supports_attachments"`
57}
58
59// KnownProviders returns all the known inference providers.
60func KnownProviders() []InferenceProvider {
61	return []InferenceProvider{
62		InferenceProviderOpenAI,
63		InferenceProviderAnthropic,
64		InferenceProviderGemini,
65		InferenceProviderAzure,
66		InferenceProviderBedrock,
67		InferenceProviderVertexAI,
68		InferenceProviderXAI,
69		InferenceProviderOpenRouter,
70	}
71}