crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

[BUG] LLM(provider=...) with a provider-prefixed model sends the prefixed name to the API (404)

Open heyseere opened this issue 1 month ago • 2 comments

Label: llm-generated — this report was produced with AI assistance (ZCode agent) and human-reviewed. Please apply the llm-generated label.

Problem

An explicit provider= kwarg is documented as pinning the routing, but when the model string already carries that provider's prefix, the prefix is not stripped in the explicit_provider branch of LLM._resolve_route (lib/crewai/src/crewai/llm.py), so native providers put the prefixed name into the request verbatim and the API rejects it:

LLM(model="openai/gpt-4o").model                  # "gpt-4o"  (correct)
LLM(model="openai/gpt-4o", provider="openai").model  # "openai/gpt-4o"  → 404 model not found

The custom_openai branch of the same method already strips a matching openai/ prefix, so the two routing paths disagree today. This hits YAML/templated configs where provider and model are filled in separately.

Expected behavior

Adding a routing hint must not change the model string. If the prefix canonicalizes (via PROVIDER_ALIASES) to the same provider, strip it; unrelated prefixes (e.g. a namespaced model id) stay untouched. DeepInfra's org/model validation should apply to the stripped id.

A PR with regression tests is attached.

heyseere avatar Oct 28 '26 16:10 heyseere

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Nov 28 '26 12:11 github-actions[bot]

Related fix is up for review in #8740 (matching provider prefix is stripped when an explicit provider is given). Happy to iterate there.

heyseere avatar Nov 30 '26 09:11 heyseere