Skip to content

feat(bedrock): add Anthropic Claude 4 support (fixes #5549)#5551

Closed
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1776698610-bedrock-claude-v4-support
Closed

feat(bedrock): add Anthropic Claude 4 support (fixes #5549)#5551
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1776698610-bedrock-claude-v4-support

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Apr 20, 2026

Summary

Fixes #5549. Adds Anthropic Claude 4 Bedrock cross-region inference profile model IDs to BEDROCK_MODELS (and the BedrockModels Literal type alias) in lib/crewai/src/crewai/llms/constants.py.

On AWS Bedrock, the Claude 4 family (Sonnet 4 / 4.5, Opus 4 / 4.1 / 4.5, Haiku 4.5) is only invocable through cross-region inference profile IDs (e.g. us.anthropic.claude-sonnet-4-5-20250929-v1:0, eu.anthropic.claude-sonnet-4-20250514-v1:0, global.anthropic.claude-haiku-4-5-20251001-v1:0), not the bare anthropic.claude-* IDs. Before this change those inference profile IDs were absent from BEDROCK_MODELS, so:

  • LLM._infer_provider_from_model("us.anthropic.claude-sonnet-4-5-20250929-v1:0") returned the default "openai" instead of "bedrock".
  • Users had to manually prefix the model with bedrock/ and/or specify provider="bedrock" to route the call correctly.

The fix lists the full Claude 4 inference-profile IDs across all Bedrock regional prefixes currently catalogued in LiteLLM's model_prices_and_context_window.json (us., us-gov., eu., apac., au., jp., global.).

Model IDs added (to both BedrockModels and BEDROCK_MODELS):

  • us.anthropic.claude-sonnet-4-20250514-v1:0, us.anthropic.claude-sonnet-4-5-20250929-v1:0
  • us.anthropic.claude-opus-4-20250514-v1:0, us.anthropic.claude-opus-4-1-20250805-v1:0, us.anthropic.claude-opus-4-5-20251101-v1:0
  • us.anthropic.claude-haiku-4-5-20251001-v1:0
  • eu.anthropic.claude-{sonnet,opus,haiku}-4-*-v1:0 variants
  • apac.anthropic.claude-{sonnet,haiku}-4-*-v1:0, au.anthropic.claude-{sonnet,haiku}-4-5-*-v1:0, jp.anthropic.claude-{sonnet,haiku}-4-5-*-v1:0
  • global.anthropic.claude-{sonnet,opus,haiku}-4-*-v1:0
  • us-gov.anthropic.claude-sonnet-4-5-20250929-v1:0

Tests (lib/crewai/tests/test_llm.py):

  • Extended test_validate_model_in_constants with Bedrock Claude 4 cross-region inference-profile assertions.
  • Added test_bedrock_claude_4_models_in_constants verifying both direct IDs and inference profiles are present in BEDROCK_MODELS.
  • Added test_infer_provider_for_bedrock_claude_4_models verifying _infer_provider_from_model returns "bedrock" for Claude 4 direct IDs and cross-region inference profiles.

All three tests pass locally (uv run pytest lib/crewai/tests/test_llm.py::test_validate_model_in_constants ::test_bedrock_claude_4_models_in_constants ::test_infer_provider_for_bedrock_claude_4_models). Ruff and mypy pass on the changed files.

Review & Testing Checklist for Human

  • Confirm the set of Claude 4 inference-profile IDs matches what your AWS accounts actually expose (I sourced them from the current LiteLLM model_prices_and_context_window.json, which may lag real Bedrock availability by region). If any of these aren't yet generally available in your regions, they can still be listed here — they simply won't resolve at call-time — but flag any you'd rather defer.
  • Intentional scope call: preview/future Claude 4.6 / 4.7 inference-profile IDs that appear in LiteLLM (e.g. us.anthropic.claude-opus-4-7, global.anthropic.claude-sonnet-4-6) are not included — they carry 2026 release dates and aren't generally available yet. If you'd like those added now, say the word.
  • Verify with an actual Bedrock call that e.g. LLM(model="bedrock/us.anthropic.claude-sonnet-4-5-20250929-v1:0") completes successfully end-to-end. I only validated the static constants/provider-inference behavior, not a live Bedrock invocation (that requires AWS credentials and model access).

Notes

  • No changes to _matches_provider_pattern for bedrock — its existing "." in model_lower fallback already accepts these IDs, so validation wasn't the blocker. The fix is specifically about _infer_provider_from_model and keeping the Literal type alias accurate.
  • There is a pre-existing PR #5550 from the issue reporter targeting the same issue. It's based on a significantly stale main (diff deletes ~1,300 files), so this PR starts fresh against current main and adds the inference-profile IDs plus tests. Happy to close either side depending on your preference.

Link to Devin session: https://app.devin.ai/sessions/e0c7012d0e26488ab18765a172e71307


Note

Low Risk
Low risk constants/test update that only affects provider inference for specific Bedrock Claude 4 model ID strings, ensuring they no longer fall back to the default provider.

Overview
Fixes Bedrock provider inference for Anthropic Claude 4 by adding cross-region inference profile model IDs (e.g. us., eu., apac., global., etc.) to the BedrockModels literal and BEDROCK_MODELS list in constants.py.

Extends test_validate_model_in_constants and adds targeted tests to assert Claude 4 direct IDs + inference profiles are present in BEDROCK_MODELS and that LLM._infer_provider_from_model() returns "bedrock" for those IDs (preventing an "openai" fallback).

Reviewed by Cursor Bugbot for commit 04dcabc. Bugbot is set up for automated code reviews on this repo. Configure here.

…models

Fixes #5549 — adds Bedrock cross-region inference profile IDs for the
Claude 4 family (Sonnet 4/4.5, Opus 4/4.1/4.5, Haiku 4.5) to
BEDROCK_MODELS and BedrockModels so provider inference and validation
work out-of-the-box for these identifiers.

Co-Authored-By: João <joao@crewai.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

Prompt hidden (unlisted session)

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE] Anthropic V4 support in Bedrock LLM's

1 participant