Skip to content

fix(amazon-bedrock): skip encodeURIComponent for ARN model IDs#14138

Open
Gdhanush-13 wants to merge 1 commit into
vercel:mainfrom
Gdhanush-13:fix/bedrock-arn-model-id-encoding
Open

fix(amazon-bedrock): skip encodeURIComponent for ARN model IDs#14138
Gdhanush-13 wants to merge 1 commit into
vercel:mainfrom
Gdhanush-13:fix/bedrock-arn-model-id-encoding

Conversation

@Gdhanush-13
Copy link
Copy Markdown

What

Fixes #14117 - @ai-sdk/amazon-bedrock fails with The provided model identifier is invalid when using application inference profile ARNs as model IDs.

Root Cause

The provider constructs REST API URLs by passing model IDs through encodeURIComponent. For standard model IDs like us.amazon.nova-2-lite-v1:0, this produces valid URLs. For ARN-style IDs like arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/abc123xyz, the slashes and colons get percent-encoded, which Bedrock's API rejects.

Fix

When the model ID starts with arn:, skip encodeURIComponent and use the raw ARN directly in the URL path. Standard model IDs continue to be encoded as before.

Applied to all four URL construction sites:

  • bedrock-chat-language-model.ts
  • bedrock-image-model.ts
  • bedrock-embedding-model.ts
  • anthropic/bedrock-anthropic-provider.ts

ARN-style model IDs (e.g. application inference profile ARNs) contain
slashes and colons that must remain unencoded in the Bedrock REST API
URL path. encodeURIComponent encodes these characters, causing Bedrock
to reject the request with 'The provided model identifier is invalid'.

When the model ID starts with 'arn:', skip URL encoding and use the
raw ARN directly. Standard model IDs (e.g. 'us.amazon.nova-2-lite-v1:0')
continue to be encoded as before.

Applied to all four URL construction sites:
- bedrock-chat-language-model.ts
- bedrock-image-model.ts
- bedrock-embedding-model.ts
- anthropic/bedrock-anthropic-provider.ts

Fixes vercel#14117
@tigent tigent Bot added ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider labels Apr 5, 2026
@Gdhanush-13 Gdhanush-13 force-pushed the fix/bedrock-arn-model-id-encoding branch from 92eabf6 to 270e1ac Compare April 5, 2026 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai/provider related to a provider package. Must be assigned together with at least one `provider/*` label bug Something isn't working as documented provider/amazon-bedrock Issues related to the @ai-sdk/amazon-bedrock provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

generateText doesn't work with AWS Bedrock application inference profile ARNs

1 participant