Skip to content

feat: add ai:apikeyheader config field for custom auth headers - #3456

Closed
jessesanford wants to merge 1 commit into
wavetermdev:mainfrom
jessesanford:feat/apikeyheader
Closed

feat: add ai:apikeyheader config field for custom auth headers#3456
jessesanford wants to merge 1 commit into
wavetermdev:mainfrom
jessesanford:feat/apikeyheader

Conversation

@jessesanford

Copy link
Copy Markdown

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 logic:

  • Azure/AzureLegacy → api-key header (unchanged, takes precedence)
  • APIKeyHeader set → <header>: <token> (new, no Bearer prefix)
  • Default → 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 field
  • pkg/wconfig/settingsconfig.go — AIModeConfigType.APIKeyHeader field
  • pkg/aiusechat/usechat.go — getWaveAISettings mapping
  • schema/waveai.json — JSON schema property
  • frontend/types/gotos.d.ts — TypeScript type (generated)
  • docs/docs/waveai-modes.mdx — documentation with Enterprise Gateways section
  • pkg/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

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
Copilot AI review requested due to automatic review settings July 30, 2026 05:18
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 81d0fd0a-214d-46b0-a325-21ebabf04ac9

📥 Commits

Reviewing files that changed from the base of the PR and between a4447c1 and 25b54bb.

📒 Files selected for processing (10)
  • docs/docs/waveai-modes.mdx
  • frontend/types/gotypes.d.ts
  • pkg/aiusechat/openai/openai-convertmessage.go
  • pkg/aiusechat/openai/openai-convertmessage_test.go
  • pkg/aiusechat/openaichat/openaichat-convertmessage.go
  • pkg/aiusechat/openaichat/openaichat-convertmessage_test.go
  • pkg/aiusechat/uctypes/uctypes.go
  • pkg/aiusechat/usechat.go
  • pkg/wconfig/settingsconfig.go
  • schema/waveai.json

Walkthrough

Wave AI configuration gains an optional ai:apikeyheader field that is propagated into backend request options. OpenAI Responses and chat-completions requests use the configured custom header for non-Azure providers, while default bearer authentication and Azure api-key behavior remain supported. Unit tests cover each authentication path. The JSON schema, frontend types, and documentation describe the new field, and telemetry types add an optional block:subblock property.

Estimated code review effort: 3 (Moderate) | ~20 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.ts

File 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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:apikeyheader to 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants