provider.go

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