feat: add ai:apikeyheader config field for custom auth headers - #3456
feat: add ai:apikeyheader config field for custom auth headers#3456jessesanford wants to merge 1 commit into
Conversation
Add optional ai:apikeyheader config field to allow enterprise LLM gateways (e.g., Apigee-fronted proxies) to use custom headers like x-api-key instead of the hardcoded Authorization: Bearer. Three-way conditional in buildChatHTTPRequest and buildOpenAIHTTPRequest: - Azure/AzureLegacy → api-key header (unchanged, takes precedence) - APIKeyHeader set → <header>: <token> (new, no Bearer prefix) - Default → Authorization: Bearer <token> (unchanged) Added APIKeyHeader to AIOptsType and AIModeConfigType, updated getWaveAISettings mapping, JSON schema, TypeScript types, docs, and unit tests (8 total, all passing). GitHub issue: wavetermdev#3453
|
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
WalkthroughWave AI configuration gains an optional Estimated code review effort: 3 (Moderate) | ~20 minutes ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Biome (2.5.5)frontend/types/gotypes.d.tsFile contains syntax errors that prevent linting: Line 1881: Expected a property, or a signature but instead found '#'.; Line 1881: Expected an expression, or an assignment but instead found ':'.; Line 1881: Expected an expression but instead found ']'.; Line 2194: Expected a statement but instead found '}'. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🟡 Not ready to approve
There are a few small but concrete correctness/conventions issues to address (misleading inline comment text and incorrect copyright year in newly added files).
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Adds support for enterprise/gateway-style authentication by introducing an optional ai:apikeyheader mode config field that allows sending the API token in a custom header (e.g. x-api-key: <token>) for non-Azure providers, while keeping Azure’s api-key behavior unchanged.
Changes:
- Adds
ai:apikeyheaderto the Wave AI mode config schema, Go config/types, and generated TypeScript types. - Updates OpenAI Chat Completions + OpenAI Responses request builders to use a three-way auth-header selection (Azure →
api-key, custom header →<header>: <token>, default →Authorization: Bearer <token>). - Adds unit tests for the new header behavior and updates documentation with an “Enterprise Gateways” section.
File summaries
| File | Description |
|---|---|
| schema/waveai.json | Adds ai:apikeyheader to the JSON schema for AI mode configs. |
| pkg/wconfig/settingsconfig.go | Extends AIModeConfigType with APIKeyHeader for config parsing/serialization. |
| pkg/aiusechat/usechat.go | Maps the new config field into runtime AI options. |
| pkg/aiusechat/uctypes/uctypes.go | Adds APIKeyHeader to AIOptsType so request builders can consume it. |
| pkg/aiusechat/openaichat/openaichat-convertmessage.go | Implements custom header behavior for Chat Completions requests. |
| pkg/aiusechat/openaichat/openaichat-convertmessage_test.go | New tests covering custom/default/Azure header selection for chat. |
| pkg/aiusechat/openai/openai-convertmessage.go | Implements custom header behavior for Responses API requests. |
| pkg/aiusechat/openai/openai-convertmessage_test.go | New tests covering custom/default/Azure header selection for responses. |
| frontend/types/gotypes.d.ts | Updates generated TS types to include ai:apikeyheader. |
| docs/docs/waveai-modes.mdx | Documents ai:apikeyheader usage and adds an enterprise gateway example. |
Review details
- Files reviewed: 9/10 changed files
- Comments generated: 3
- Review effort level: Low
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| AIMode string `json:"aimode,omitempty"` | ||
| Capabilities []string `json:"capabilities,omitempty"` | ||
| WaveAIPremium bool `json:"waveaipremium,omitempty"` | ||
| APIKeyHeader string `json:"apikeyheader,omitempty"` // Custom header name for API token (e.g. "x-api-key"); when empty, defaults to "Authorization: Bearer <token>" |
| @@ -0,0 +1,110 @@ | |||
| // Copyright 2025, Command Line Inc. | |||
| @@ -0,0 +1,110 @@ | |||
| // Copyright 2025, Command Line Inc. | |||
Add optional
ai:apikeyheaderconfig field to allow enterprise LLM gateways (e.g., Apigee-fronted proxies) to use custom headers likex-api-keyinstead of the hardcodedAuthorization: Bearer.Three-way conditional logic:
api-keyheader (unchanged, takes precedence)<header>: <token>(new, no Bearer prefix)Authorization: Bearer <token>(unchanged)Files changed:
pkg/aiusechat/openaichat/openaichat-convertmessage.go— auth header logic (chat completions)pkg/aiusechat/openai/openai-convertmessage.go— auth header logic (Responses API)pkg/aiusechat/uctypes/uctypes.go— AIOptsType.APIKeyHeader fieldpkg/wconfig/settingsconfig.go— AIModeConfigType.APIKeyHeader fieldpkg/aiusechat/usechat.go— getWaveAISettings mappingschema/waveai.json— JSON schema propertyfrontend/types/gotos.d.ts— TypeScript type (generated)docs/docs/waveai-modes.mdx— documentation with Enterprise Gateways sectionpkg/aiusechat/openaichat/openaichat-convertmessage_test.go— unit tests (chat)pkg/aiusechat/openai/openai-convertmessage_test.go— unit tests (Responses API)Validation: gofmt clean, go vet clean, go build ./... success, 8/8 tests pass.
GitHUb issue: #3453