ANTHROPIC_MODELS has drifted from the CLI model list, so models offered by crewai create route to the OpenAI client
@Vidit-Ostwal is already working on this.
Since Aug 25, 2026.
- Dominant language
- Python
- Stars
- 58.8k
- Forks
- 8.5k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 109
Description
Per CONTRIBUTING: this issue was written with AI assistance. The
llm-generatedlabel is required but outside contributors cannot apply labels (403). Could a maintainer add it. Findings below were verified by hand against the files and line numbers cited.
What happens
LLM(model="claude-sonnet-4-6") constructs an OpenAICompletion, not AnthropicCompletion. No error is raised.
claude-sonnet-4-6 is the second entry in the Anthropic list that crewai create offers, so this is reachable straight from the CLI picker.
Two lists, out of sync
lib/cli/src/crewai_cli/constants.py:163 offers claude-opus-4-6 and claude-sonnet-4-6 at the top of the Anthropic menu.
Neither is in ANTHROPIC_MODELS in lib/crewai/src/crewai/llms/constants.py:212, which stops at claude-opus-4-5. The AnthropicModels Literal at :184 has the same gap.
Why the mismatch routes wrong
LLM._infer_provider_from_model in lib/crewai/src/crewai/llm.py:634 checks the five constant lists and falls back to "openai":
if model in ANTHROPIC_MODELS:
return "anthropic"
...
return "openai"
Its docstring describes different behavior:
This method first checks the hardcoded constants list for known models. If not found, it uses pattern matching to infer the provider from model name patterns. This allows supporting new models and "latest" versions without hardcoding.
There is no pattern matching in the function.
The sibling _validate_model_in_constants does exactly what that docstring describes: it checks the lists, then falls through to _matches_provider_pattern at :617. That helper already handles the claude- and anthropic. prefixes at :538. _infer_provider_from_model just never calls it.
The bare-model path at :473 sets use_native = True, so the inferred provider goes straight to _get_native_provider and the wrong client is constructed.
Also in ANTHROPIC_MODELS
claude-4-sonnet-20250514 and claude-4-opus-20250514 are not valid Anthropic ids. Anthropic moved to claude-<family>-<version> at Claude 3, and the correct claude-sonnet-4-20250514 and claude-opus-4-20250514 are already present in the same list.
Missing beyond the CLI gap: claude-opus-4-7, claude-opus-4-8, and the Claude 5 family (claude-opus-5, claude-sonnet-5, claude-fable-5).
Suggested fix
Have _infer_provider_from_model fall through to _matches_provider_pattern before defaulting to openai, which is what its docstring already promises and what makes the constants list a fast path rather than a gate. Then refresh ANTHROPIC_MODELS and drop the two invalid ids.
Happy to send a PR for this. Assign it to me if you want me to take it.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.