Add AWS Bedrock support to ai-gateway-provider#521
Open
vikas-shopos wants to merge 1 commit intocloudflare:mainfrom
Open
Add AWS Bedrock support to ai-gateway-provider#521vikas-shopos wants to merge 1 commit intocloudflare:mainfrom
vikas-shopos wants to merge 1 commit intocloudflare:mainfrom
Conversation
Bedrock was listed as a provider but requests failed with "provider not
supported" because no URL regex or endpoint transform existed in the
provider registry. This commit wires up full support:
- Add provider config for aws-bedrock in providers.ts with URL regex
matching bedrock-runtime.{region}.amazonaws.com and endpoint transform
that produces bedrock-runtime/{region}/{path}
- Fix amazon-bedrock.ts provider wrapper to inject CF_TEMP_TOKEN into
accessKeyId/secretAccessKey (Bedrock uses AWS SigV4, not apiKey)
- Add extraStripHeaders for AWS SigV4 companion headers (x-amz-date,
x-amz-security-token, x-amz-content-sha256), stripped only when
BYOK mode is detected via CF_TEMP_TOKEN — real credentials are
preserved when provided by the user
- Add ProviderConfig type to providers.ts for type safety
- Add endpoint transform tests including URL-encoded model IDs
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
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
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
ai-gateway-providerpackagebedrock-runtime.{region}.amazonaws.comwith endpoint transform producingbedrock-runtime/{region}/{path}(matching Cloudflare AI Gateway's expected format)amazon-bedrock.tsprovider wrapper to handle Bedrock's AWS SigV4 auth model (accessKeyId/secretAccessKey) instead of the genericauthWrapperwhich only supportsapiKeyx-amz-date,x-amz-security-token,x-amz-content-sha256) only in BYOK mode (whenCF_TEMP_TOKENis detected) — user-provided credentials are preservedProviderConfigtype for type safety across the provider registryv1%3A0)Context
The Bedrock provider wrapper existed (
providers/amazon-bedrock.ts) but requests failed with"provider not supported"because:providers.tsmatched Bedrock'sbedrock-runtime.{region}.amazonaws.comURLsauthWrappertried to setapiKey, but Bedrock usesaccessKeyId/secretAccessKeyfor AWS SigV4 signingUsage
Test plan
🤖 Generated with Claude Code