Skip to content

make anthropic beta header usage consistent#1491

Merged
VisargD merged 1 commit into
Portkey-AI:mainfrom
narengogi:fix/anthropic-beta
Jan 12, 2026
Merged

make anthropic beta header usage consistent#1491
VisargD merged 1 commit into
Portkey-AI:mainfrom
narengogi:fix/anthropic-beta

Conversation

@narengogi

Copy link
Copy Markdown
Member

Description: (required)
-This PR makes anthropic beta header usage consistent across multiple providers (vertex, anthropic and bedrock)

  • the precedence order now is header > body as it should've been all along

Type of Change:

  • New feature (non-breaking change which adds functionality)

@narengogi narengogi requested review from b4s36t4 and Copilot December 29, 2025 13:16

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR standardizes how Anthropic beta headers (anthropic_version and anthropic_beta) are handled across multiple providers (Vertex AI, Bedrock, and Anthropic). The key improvement is establishing a consistent precedence order where header values take priority over body parameters.

Key changes:

  • Modified transform functions across Vertex AI and Bedrock providers to accept providerOptions and prioritize header-sourced values
  • Updated constructConfigFromRequestHeaders to extract both anthropicBeta and anthropicVersion from request headers for Bedrock and Vertex configurations
  • Ensured consistent precedence: providerOptions (from headers) > body parameters > defaults

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/providers/google-vertex-ai/messages.ts Added transform function to prioritize anthropicVersion from headers over body params
src/providers/google-vertex-ai/chatComplete.ts Added transform function to prioritize anthropicVersion from headers over body params
src/providers/bedrock/utils/messagesUtils.ts Updated to accept providerOptions and prioritize header values for both anthropicVersion and anthropicBeta
src/providers/bedrock/utils.ts Updated to accept providerOptions and prioritize header values for both anthropicVersion and anthropicBeta
src/providers/bedrock/messages.ts Updated all transform function signatures to pass providerOptions through
src/providers/bedrock/chatComplete.ts Updated all transform function signatures to pass providerOptions through
src/handlers/handlerUtils.ts Added extraction of anthropicVersion from headers for both Bedrock and Vertex configurations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/providers/bedrock/utils.ts
@VisargD VisargD merged commit 5316fa7 into Portkey-AI:main Jan 12, 2026
1 check passed
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