mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: support multiple keys per AI Bridge provider (#24683)
## Description Adds support for configuring multiple API keys per AI Bridge provider. This PR introduces the configuration parsing and validation only; wiring the key pools into the aibridge providers will happen in upstream PRs. ## Changes Providers now accept a comma-separated list of keys via the `KEYS` env var (or a single key via the existing `KEY` var). The two are mutually exclusive. Bedrock follows the same pattern with `BEDROCK_ACCESS_KEYS` / `BEDROCK_ACCESS_KEY_SECRETS`, with an additional validation that the two slices have matching lengths. Key validation at startup checks for empty values, duplicates, and a maximum of 5 keys per provider. Related to: https://github.com/coder/internal/issues/1445 > [!NOTE] > Initially generated by Coder Agents, modified and reviewed by @ssncferreira
This commit is contained in:
+15
-8
@@ -4110,20 +4110,27 @@ type AIBridgeProviderConfig struct {
|
||||
// Name is the unique instance identifier used for routing.
|
||||
// Defaults to Type if not provided.
|
||||
Name string `json:"name"`
|
||||
// Key is the API key for authenticating with the upstream provider.
|
||||
Key string `json:"-"`
|
||||
// Keys holds one or more API keys for authenticating with the
|
||||
// upstream provider. When multiple keys are configured, they
|
||||
// form a key pool for automatic failover.
|
||||
Keys []string `json:"-"`
|
||||
// BaseURL is the base URL of the upstream provider API.
|
||||
BaseURL string `json:"base_url"`
|
||||
// DumpDir is the directory path for dumping API requests and responses.
|
||||
DumpDir string `json:"dump_dir,omitempty"`
|
||||
|
||||
// Bedrock fields (only applicable when Type == "anthropic").
|
||||
BedrockBaseURL string `json:"-"`
|
||||
BedrockRegion string `json:"bedrock_region,omitempty"`
|
||||
BedrockAccessKey string `json:"-"`
|
||||
BedrockAccessKeySecret string `json:"-"`
|
||||
BedrockModel string `json:"bedrock_model,omitempty"`
|
||||
BedrockSmallFastModel string `json:"bedrock_small_fast_model,omitempty"`
|
||||
BedrockBaseURL string `json:"-"`
|
||||
BedrockRegion string `json:"bedrock_region,omitempty"`
|
||||
// BedrockAccessKeys and BedrockAccessKeySecrets hold one or
|
||||
// more AWS credential pairs for authenticating with Bedrock.
|
||||
// When multiple pairs are configured, they form a key pool
|
||||
// for automatic failover. The two slices must have the same
|
||||
// length.
|
||||
BedrockAccessKeys []string `json:"-"`
|
||||
BedrockAccessKeySecrets []string `json:"-"`
|
||||
BedrockModel string `json:"bedrock_model,omitempty"`
|
||||
BedrockSmallFastModel string `json:"bedrock_small_fast_model,omitempty"`
|
||||
}
|
||||
|
||||
type AIBridgeProxyConfig struct {
|
||||
|
||||
Reference in New Issue
Block a user