[BUG] Claude Code Bedrock Model Configuration Error

Status Fixed / completed
Maintainer reply ✓ Yes — ant-kurt
Activity 11 comments · opened May 30, 2025 · closed Jun 4, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

Environment

  • Platform (select one):
  • [ ] Anthropic API
  • [X] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: <!-- output of claude --version -->
  • Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 -->
  • Terminal: <!-- e.g. iTerm2, Terminal App -->

Bug Description

Unable to configure Claude Code to use AWS Bedrock with Claude Sonnet 4. Getting a "provided model identifier is invalid" error when attempting to set the global configuration for Bedrock usage.

Steps to Reproduce

  1. Run the following command to configure Claude Code for AWS Bedrock:

``bash
claude config set --global env '{"CLAUDE_CODE_USE_BEDROCK": "true", "ANTHROPIC_MODEL": "apac.anthropic.claude-sonnet-4-20250514-v1:0"}'
``

  1. Attempt to use Claude Code with the Bedrock configuration
  2. Error occurs immediately

Expected Behavior

Claude Code should successfully configure to use AWS Bedrock with Claude Sonnet 4 model and allow normal operation through Bedrock API.

Actual Behavior

Configuration fails with the following error:

API Error (apac.anthropic.claude-sonnet-4-20250514-v1:0): 400 The provided model identifier is invalid.

arn:aws:bedrock:ap-northeast-1:XXXX:inference-profile/apac.anthropic.claude-sonnet-4-20250514-v1:0

Interrupted by user

Additional Context

  • Using AWS region: ap-northeast-1 (Asia Pacific - Tokyo)
  • The error shows Claude Code is attempting to construct an ARN with an inference profile
  • The model identifier format apac.anthropic.claude-sonnet-4-20250514-v1:0 appears to be incorrect for AWS Bedrock
  • Standard Bedrock model identifiers typically use format like anthropic.claude-3-5-sonnet-20241022-v2:0
  • May be related to regional model availability or incorrect model ID format for Bedrock

View original on GitHub ↗

11 Comments

ant-kurt collaborator · 1 year ago

Hi @cloudeep-innovation,

That inference profile looks like the correct specifier, from https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html (section "APAC Claude Sonnet 4"). Can you try setting AWS_REGION=ap-northeast-1 too?

If that doesn't work, can you try directly invoking the model via the AWS CLI to confirm model availability and region, something like:

aws bedrock-runtime invoke-model \
    --model-id apac.anthropic.claude-sonnet-4-20250514-v1:0 \
    --body '{"anthropic_version": "bedrock-2023-05-31", "max_tokens": 1000, "messages": [{"role": "user", "content": "Hello, how are you?"}]}' \
    --cli-binary-format raw-in-base64-out \
    response.json
mattbolgercsiro · 1 year ago

Seeing this same issue. Suggested "aws bedrock-runtime invoke-model" call above from @ant-kurt works with region set to either ap-southeast-2 or the suggested ap-northeast-1 but Claude Code reports
API Error (apac.anthropic.claude-sonnet-4-20250514-v1:0): 400 The provided model identifier is invalid.

syn-ack-ai · 1 year ago

Seeing the same issue with Bedrock.

This works, but with claude code with model set to "arn:aws:bedrock:us-west-2:xxxxxxxxx:application-inference-profile/xxxxxxxxx"

I get: API Error (arn:aws:bedrock:us-west-2:xxxxxxxxx:application-inference-profile/xxxxxxxxx ): 400 The provided model identifier is invalid.

This also works in Clint in VS Code, and Pydentic AI framework.

aws bedrock-runtime invoke-model \
  --region us-west-2 \
  --model-id arn:aws:bedrock:us-west-2:xxxxxxxxx:application-inference-profile/xxxxxxxxx \
  --content-type application/json \
  --accept application/json \
  --body fileb://prompt.json \
  response.json
{
    "contentType": "application/json"
}
cat response.json
{"id":"msg_bdrk_0144e5kPDZBLLZfMJSFrdeNg","type":"message","role":"assistant","model":"claude-opus-4-20250514","content":[{"type":"text","text":"Pong! How can I help you today?"}],"stop_reason":"end_turn","stop_sequence":null,"usage":{"input_tokens":8,"cache_creation_input_tokens":0,"cache_read_input_tokens":0,"output_tokens":14}}% 
K3UL · 1 year ago

I am seeing the same issue with my region set to eu-central-1. It works with the aws command but claude code is showing an error 400.

ant-kurt collaborator · 1 year ago

Ensure you're setting the AWS_REGION or AWS_DEFAULT_REGION environment variables for the Claude Code process, to a value that matches where the inference profile is available.

# this fails because neither AWS_REGION nor AWS_DEFAULT_REGION were available
# thus Claude Code defaulted to `us-east-1`
CLAUDE_CODE_USE_BEDROCK=1 ANTHROPIC_MODEL=eu.anthropic.claude-sonnet-4-20250514-v1:0 claude -p hi

API Error (eu.anthropic.claude-sonnet-4-20250514-v1:0): 400 The provided model identifier is invalid.
mattbolgercsiro · 1 year ago

@ant-kurt, thanks. Setting AWS_REGION fixed the issue for me. Region was set in ~/.aws/config which I guess explains why other applications and the aws bedrock-runtime invoke-model test work but looks like Claude Code doesn't use this and needs the explicit AWS_REGION environment variable set.

#!/bin/sh
export CLAUDE_CODE_USE_BEDROCK=1
export AWS_REGION=ap-southeast-2
export ANTHROPIC_MODEL="apac.anthropic.claude-sonnet-4-20250514-v1:0"
claude
K3UL · 1 year ago
@ant-kurt, thanks. Setting AWS_REGION fixed the issue for me. Region was set in ~/.aws/config which I guess explains why other applications and the aws bedrock-runtime invoke-model test work but looks like Claude Code doesn't use this and needs the explicit AWS_REGION environment variable set. `` #!/bin/sh export CLAUDE_CODE_USE_BEDROCK=1 export AWS_REGION=ap-southeast-2 export ANTHROPIC_MODEL="apac.anthropic.claude-sonnet-4-20250514-v1:0" claude ``

Same here. The doc says to use aws configure which sets this config file, so it seemed natural that claude code would use it, just as it uses the credentials file.

Thank you @ant-kurt

syn-ack-ai · 1 year ago

Adding the region worked, thanks! @ant-kurt

ant-kurt collaborator · 1 year ago

Closing this one out since it looks like adding env var AWS_REGION fixed this.

We have some upcoming docs updates that should make this requirement more clear, and may also explore reading from AWS config in the future.

noamta-gloat · 1 year ago

If anyone is reading this -- does it mean that (for example) I can only invoke Sonnet 4 from eu-south-2? And I can't even call Opus 4 from EU?

@ant-kurt

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.