You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Per-model npm override in custom provider config is ignored #31919
When configuring a custom provider with a per-model npm override (as documented in the Providers page under "Troubleshooting"), the override is silently ignored. The provider-level npm package is always used regardless of model-level overrides.
Use case
We run a LiteLLM proxy that serves both Claude (via Bedrock) and GPT (via Azure). LiteLLM exposes both /v1/messages (Anthropic-native) and /v1/chat/completions (OpenAI-compatible) on the same endpoint.
We need Claude models to use @ai-sdk/anthropic (→ /v1/messages) and GPT models to use @ai-sdk/openai-compatible (→ /v1/chat/completions) under a single provider.
Both models use the provider-level @ai-sdk/anthropic. The per-model npm field is ignored.
Also tested the inverse (provider default @ai-sdk/openai-compatible, Claude models with "npm": "@ai-sdk/anthropic" override) — same result: override ignored.
We tested the per-model npm override workaround from the docs and confirmed the bug reproduces with the following stacktrace:
Type validation failed: Value: {"error":{"message":"list index out of range\n\nTraceback (most recent call last):\n File \"/app/.venv/lib/python3.13/site-packages/litellm/proxy/common_request_processing.py\", line 2022, in async_streaming_data_generator\n ...\n File \"/app/.venv/lib/python3.13/site-packages/litellm/llms/anthropic/experimental_pass_through/adapters/streaming_iterator.py\", line 819, in _should_start_new_content_block\n if chunk.choices[0].finish_reason is not None:\n ~~~~~~~~~~~~~^^^\nIndexError: list index out of range\n"}}
The root cause is visible in the trace: LiteLLM's Anthropic pass-through streaming adapter (experimental_pass_through/adapters/streaming_iterator.py) is being used to process responses from the Azure OpenAI backend (azure/gpt-4-1-nano). Because the per-model npm override is ignored, the request goes to Azure via the correct endpoint but the response is then deserialized by the Anthropic adapter, which crashes when it encounters an OpenAI-style chunk with an empty choices list.
This confirms the bug: the per-model npm field has no effect on which streaming adapter is used. The provider-level @ai-sdk/anthropic is applied unconditionally.
We are currently using the two-provider workaround as described in the issue.
Activity
OpeOginni commentedon Jun 13, 2026
Hey @christianherweg0807 You have an issue with your config, the docs says its overridden by
provider.npm, which means like<model_id>.provider.npmSo what you should have is
{ "provider": { "litellm": { "npm": "@ai-sdk/anthropic", "options": { "baseURL": "https://litellm.example.com/v1", "apiKey": "{env:LITELLM_VIRTUAL_KEY}" }, "models": { "claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" }, "azure/gpt-4-1": { "provider": { "npm": "@ai-sdk/openai-compatible", }, "name": "GPT-4.1" } } } } }Try this and should work. If it does please go ahead and close the issue!
christianherweg0807 commentedon Jun 15, 2026
We tested the per-model
npmoverride workaround from the docs and confirmed the bug reproduces with the following stacktrace:The root cause is visible in the trace: LiteLLM's Anthropic pass-through streaming adapter (
experimental_pass_through/adapters/streaming_iterator.py) is being used to process responses from the Azure OpenAI backend (azure/gpt-4-1-nano). Because the per-modelnpmoverride is ignored, the request goes to Azure via the correct endpoint but the response is then deserialized by the Anthropic adapter, which crashes when it encounters an OpenAI-style chunk with an emptychoiceslist.This confirms the bug: the per-model
npmfield has no effect on which streaming adapter is used. The provider-level@ai-sdk/anthropicis applied unconditionally.We are currently using the two-provider workaround as described in the issue.
OpeOginni commentedon Jun 15, 2026
@christianherweg0807 Did you make use of the new config shape I provioded in my reply?
github-actions commentedon Aug 15, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.