You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: implement autoconfig for ANTHROPIC_API_KEY in standalone mode (#1424)
**Description**
This change adds support for configuring AI Gateway with Anthropic in
standalone mode using the ANTHROPIC_API_KEY environment variable,
following the same pattern as OpenAI.
## Usage
Configure Anthropic backend by setting the environment variable:
```bash
export ANTHROPIC_API_KEY="sk-ant-your-key-here"
aigw run
```
Optional: Use custom base URL for testing or custom deployments:
```bash
export ANTHROPIC_BASE_URL="https://custom.anthropic.com/v1"
aigw run
```
**Note**: When both OPENAI_API_KEY and ANTHROPIC_API_KEY are set, OpenAI
takes precedence.
## Implementation
- Added `AnthropicConfig` struct to hold Anthropic-specific
configuration
- Implemented `PopulateAnthropicEnvConfig()` function to parse
environment variables
- Updated configuration template to render Anthropic resources
(AIGatewayRoute, AIServiceBackend, BackendSecurityPolicy)
- Modified CLI validation to accept ANTHROPIC_API_KEY as a valid
configuration option
- OpenAI takes precedence when both API keys are present to avoid
configuration conflicts
Fixes#1390
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: Ignasi Barrera <[email protected]>
Copy file name to clipboardExpand all lines: cmd/aigw/main.go
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -34,7 +34,7 @@ type (
34
34
// cmdRun corresponds to `aigw run` command.
35
35
cmdRunstruct {
36
36
Debugbool`help:"Enable debug logging emitted to stderr."`
37
-
Pathstring`arg:"" name:"path" optional:"" help:"Path to the AI Gateway configuration yaml file. Optional when at least OPENAI_API_KEYor AZURE_OPENAI_API_KEY is set." type:"path"`
37
+
Pathstring`arg:"" name:"path" optional:"" help:"Path to the AI Gateway configuration yaml file. Optional when at least OPENAI_API_KEY, AZURE_OPENAI_API_KEY, or ANTHROPIC_API_KEY is set." type:"path"`
38
38
AdminPortint`help:"HTTP port for the admin server (serves /metrics and /health endpoints)." default:"1064"`
39
39
McpConfigstring`name:"mcp-config" help:"Path to MCP servers configuration file." type:"path"`
40
40
McpJSONstring`name:"mcp-json" help:"JSON string of MCP servers configuration."`
0 commit comments