-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat: add base_url and custom_headers inputs for LLM Gateway integration #841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GuitaristForEver
wants to merge
21
commits into
anthropics:main
Choose a base branch
from
GuitaristForEver:feat/native-gateway-inputs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: add base_url and custom_headers inputs for LLM Gateway integration #841
GuitaristForEver
wants to merge
21
commits into
anthropics:main
from
GuitaristForEver:feat/native-gateway-inputs
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Adds native support for LLM Gateway integration and custom HTTP headers without requiring env block configuration. Inputs take precedence but fall back to environment variables for backwards compatibility. Closes anthropics#840 Related: anthropics#272, anthropics#575, anthropics#704
Mirrors the root action's inputs for standalone base-action usage. Falls back to env vars for backwards compatibility.
Documents new base_url and custom_headers inputs with examples for Portkey, LiteLLM, Azure APIM, and other gateway integrations.
When use_bedrock is enabled and base_url is provided, the action now
correctly sets ANTHROPIC_BEDROCK_BASE_URL from inputs.base_url instead
of only setting ANTHROPIC_BASE_URL.
This enables using Bedrock mode with API Management gateways that:
- Route Bedrock-format requests (/bedrock/model/{model}/invoke)
- Use custom HTTP headers for authentication (not AWS credentials)
- Require custom base URLs (e.g., Azure APIM endpoints)
Changes:
- Set ANTHROPIC_BEDROCK_BASE_URL from inputs.base_url when use_bedrock=true
- Skip AWS credential validation when using custom Bedrock endpoints
- Add tests for custom Bedrock endpoint scenarios
Fixes the issue where Bedrock mode ignored inputs.base_url and failed
to send custom headers to API Management gateways.
Enables using Bedrock API format with custom HTTP headers by creating a local translation proxy that: 1. Receives Anthropic API format from Claude SDK (HTTP requests) 2. Translates to Bedrock API format 3. Forwards to APIM/gateway with custom headers 4. Translates responses back to Anthropic format This allows: - use_bedrock: true (Bedrock API format) - base_url: custom endpoint (APIM gateway) - custom_headers: authentication and routing headers Without requiring AWS SDK or AWS credentials. How it works: - When use_bedrock + base_url + custom_headers are all present - Action starts local HTTP proxy on port 8765 - SDK sends to localhost:8765 in Anthropic format - Proxy translates and forwards to APIM in Bedrock format - APIM routes to AWS Bedrock backend This keeps APIM configuration unchanged while supporting custom headers. Tests: All 143 tests passing including 34 validation tests
Added comprehensive documentation for the Bedrock HTTP proxy feature: - docs/configuration.md: Detailed explanation with benefits and workflow - base-action/README.md: Example usage with API Management gateways Documents how the proxy enables: - Bedrock API format with custom HTTP headers - API Management gateway integration (Azure APIM, AWS API Gateway) - Authentication via custom headers instead of AWS credentials - Automatic translation between Anthropic and Bedrock API formats
… from applying headers twice
The Anthropic API expects model names like 'claude-sonnet-4-20250514' without the 'anthropic.' prefix. The prefix is only used in Bedrock model IDs when making requests, not in response model names. This was causing 'No assistant message found' errors because the SDK couldn't recognize the model name.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds native
base_urlandcustom_headersinputs to eliminate the need forenv:block scripting when integrating with LLM Gateways and API management solutions.Problem
Users in discussions #272, #575, and #704 are struggling to integrate with:
The current workaround requires undiscoverable
env:blocks and users don't know the JSON format for headers.Solution
Changes
action.yml- Addbase_urlandcustom_headersinputsbase-action/action.yml- Mirror inputs for standalone usagedocs/configuration.md- Add LLM Gateway section with examplesdocs/cloud-providers.md- Reference new configurationbase-action/README.md- Update inputs tablebase-action/test/validate-env.test.ts- Add test coverage (31 tests pass)Test Plan
Closes #840
Note to reviewers: This unblocks users in #704, #575, and addresses the pattern requested in #272.