Skip to content

feat: add defaultHeaders support to all LLM providers#17

Draft
marckong wants to merge 2 commits intomainfrom
feat/add-default-headers
Draft

feat: add defaultHeaders support to all LLM providers#17
marckong wants to merge 2 commits intomainfrom
feat/add-default-headers

Conversation

@marckong
Copy link
Collaborator

Add defaultHeaders configuration option to all LLM providers (OpenAI, Anthropic, Azure, Mistral, Llama, Bedrock, Vertex Studio), enabling custom metadata and authentication mechanisms similar to the official OpenAI client.

  • Add mergeHeaders utility function for proper header precedence
  • Update all provider config types to include defaultHeaders field
  • Implement header merging in all fetch calls and SDK initializations
  • Priority: required headers > default headers (prevents auth override)

Add defaultHeaders configuration option to all LLM providers (OpenAI,
Anthropic, Azure, Mistral, Llama, Bedrock, Vertex Studio), enabling
custom metadata and authentication mechanisms similar to the official
OpenAI client.

- Add mergeHeaders utility function for proper header precedence
- Update all provider config types to include defaultHeaders field
- Implement header merging in all fetch calls and SDK initializations
- Priority: required headers > default headers (prevents auth override)
@CLAassistant
Copy link

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.

@marckong marckong requested a review from gperanich October 17, 2025 00:14
Add unit tests for defaultHeaders support across all LLM providers:

- Test mergeHeaders utility function (7 tests)
  - Verify proper header precedence (required > default)
  - Test edge cases (empty, undefined, overlapping headers)

- Test fetch-based providers (12 tests)
  - Anthropic: defaultHeaders in fetch calls
  - Mistral: header merging with Authorization
  - Llama: header merging with custom and auth headers
  - Vertex Studio: Content-Type precedence
  - Azure: header merging with apiKey and accessToken auth

- Test OpenAI SDK integration (8 tests)
  - llmOpenAI: defaultHeaders passed to SDK constructor
  - llmOpenAIResponses: defaultHeaders with jsonSchema config
  - Verify baseURL and defaultHeaders work together

All 27 new tests pass. Existing unit tests remain unaffected.
@subnetmarco
Copy link
Member

Needs documentation too.

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