mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: route extra ai_provider_types through OpenAI and Anthropic providers (#25722)
_Disclosure:_ _produced_ _with_ _Claude_ _Opus_ _4\.7_ AI Gateway only supports Anthropic (+Bedrock), OpenAI, and Copilot providers at present. All other types (Vercel, Gemini, etc) will be mapped to OpenAI since they support OpenAI-compatible endpoints.
This commit is contained in:
+12
-6
@@ -175,9 +175,12 @@ type AIBridgeListSessionsFilter struct {
|
||||
Initiator string `json:"initiator,omitempty"`
|
||||
StartedBefore time.Time `json:"started_before,omitempty" format:"date-time"`
|
||||
StartedAfter time.Time `json:"started_after,omitempty" format:"date-time"`
|
||||
// Provider matches the provider type column (openai, anthropic,
|
||||
// copilot). Retained for backward compatibility; new clients should
|
||||
// prefer ProviderName, which scopes to a specific configured row.
|
||||
// Provider matches the runtime provider type column (openai,
|
||||
// anthropic, copilot). The runtime type collapses the configured
|
||||
// ai_provider_type: azure, google, openai-compat, openrouter, and
|
||||
// vercel route through openai; bedrock routes through anthropic.
|
||||
// Retained for backward compatibility; new clients should prefer
|
||||
// ProviderName, which scopes to a specific configured row.
|
||||
Provider string `json:"provider,omitempty"`
|
||||
ProviderName string `json:"provider_name,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
@@ -202,9 +205,12 @@ type AIBridgeListInterceptionsFilter struct {
|
||||
Initiator string `json:"initiator,omitempty"`
|
||||
StartedBefore time.Time `json:"started_before,omitempty" format:"date-time"`
|
||||
StartedAfter time.Time `json:"started_after,omitempty" format:"date-time"`
|
||||
// Provider matches the provider type column (openai, anthropic,
|
||||
// copilot). Retained for backward compatibility; new clients should
|
||||
// prefer ProviderName, which scopes to a specific configured row.
|
||||
// Provider matches the runtime provider type column (openai,
|
||||
// anthropic, copilot). The runtime type collapses the configured
|
||||
// ai_provider_type: azure, google, openai-compat, openrouter, and
|
||||
// vercel route through openai; bedrock routes through anthropic.
|
||||
// Retained for backward compatibility; new clients should prefer
|
||||
// ProviderName, which scopes to a specific configured row.
|
||||
Provider string `json:"provider,omitempty"`
|
||||
ProviderName string `json:"provider_name,omitempty"`
|
||||
Model string `json:"model,omitempty"`
|
||||
|
||||
+16
-2
@@ -224,10 +224,24 @@ func (req CreateAIProviderRequest) Validate() []ValidationError {
|
||||
validations = append(validations, validateAIProviderName(req.Name)...)
|
||||
validations = append(validations, validateRequiredAIProviderBaseURL(req.BaseURL)...)
|
||||
validations = append(validations, validateAIProviderAPIKeys(req.APIKeys)...)
|
||||
if req.Settings.Bedrock != nil && req.Type != AIProviderTypeAnthropic {
|
||||
if req.Settings.Bedrock != nil &&
|
||||
req.Type != AIProviderTypeAnthropic &&
|
||||
req.Type != AIProviderTypeBedrock {
|
||||
validations = append(validations, ValidationError{
|
||||
Field: "settings",
|
||||
Detail: "bedrock settings are only valid for type=anthropic",
|
||||
Detail: "bedrock settings are only valid for type=anthropic or type=bedrock",
|
||||
})
|
||||
}
|
||||
if req.Type == AIProviderTypeBedrock && (req.Settings.Bedrock == nil || !req.Settings.Bedrock.IsConfigured()) {
|
||||
validations = append(validations, ValidationError{
|
||||
Field: "settings",
|
||||
Detail: "type=bedrock requires bedrock settings",
|
||||
})
|
||||
}
|
||||
if req.Type == AIProviderTypeBedrock && len(req.APIKeys) > 0 {
|
||||
validations = append(validations, ValidationError{
|
||||
Field: "api_keys",
|
||||
Detail: "type=bedrock does not accept api_keys",
|
||||
})
|
||||
}
|
||||
return validations
|
||||
|
||||
@@ -4684,7 +4684,9 @@ type AIBridgeBedrockConfig struct {
|
||||
// CODER_AIBRIDGE_PROVIDER_<N>_<KEY> is also accepted as a deprecated alias.
|
||||
// This follows the same indexed pattern as ExternalAuthConfig.
|
||||
type AIProviderConfig struct {
|
||||
// Type is the provider type: "openai", "anthropic", or "copilot".
|
||||
// Type is the provider type. Valid values are: "openai",
|
||||
// "anthropic", "azure", "bedrock", "google", "openai-compat",
|
||||
// "openrouter", "vercel", "copilot".
|
||||
Type string `json:"type"`
|
||||
// Name is the unique instance identifier used for routing.
|
||||
// Defaults to Type if not provided.
|
||||
|
||||
Reference in New Issue
Block a user