crewai - ✅(Solved) Fix [FEATURE] Anthropic V4 support in Bedrock LLM's [2 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Fix Action

Fixed

PR fix notes

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

Description (problem / solution / changelog)

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

<!-- CURSOR_SUMMARY -->

[!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).

<sup>Reviewed by Cursor Bugbot for commit 04dcabca0393293ee0e1fbeeb03e7b992dd522bb. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai/src/crewai/llms/constants.py (modified, +48/-0)
  • lib/crewai/tests/test_llm.py (modified, +98/-0)
RAW_BUFFERClick to expand / collapse

Feature Area

Core functionality

Is your feature request related to a an existing bug? Please link it here.

Bedrock's Anthropic V3 models or no longer available at AWS (only for legacy customers). The V4 models aren't available in CrewAI

Describe the solution you'd like

To be able to use the Bedrock Anthropic V4 models as the LLM in my crews

Describe alternatives you've considered

No response

Additional context

No response

Willingness to Contribute

Yes, I'd be happy to submit a pull request

extent analysis

TL;DR

The issue can be addressed by integrating Bedrock Anthropic V4 models into CrewAI, potentially through a pull request.

Guidance

  • Investigate the compatibility and requirements of Bedrock Anthropic V4 models with CrewAI to understand the necessary integration steps.
  • Review the existing implementation of Bedrock Anthropic V3 models in CrewAI to identify potential areas that need modification for V4 support.
  • Consider reaching out to the maintainers of CrewAI or Bedrock for guidance on integrating V4 models, as they may have existing plans or documentation for this feature.
  • Evaluate the feasibility of submitting a pull request to add V4 model support, given the willingness to contribute.

Notes

The solution may depend on the specific requirements and constraints of both Bedrock Anthropic V4 models and CrewAI, which are not fully detailed in the issue.

Recommendation

Apply workaround: Integrate Bedrock Anthropic V4 models into CrewAI through a custom implementation or pull request, as there is no indication of an existing fix or upgrade path.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING