Skip to content

Per-model npm override in custom provider config is ignored #31919

Closed as not planned

Description

@christianherweg0807

Description

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.

Configuration

{
  "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": {
          "npm": "@ai-sdk/openai-compatible",
          "name": "GPT-4.1"
        }
      }
    }
  }
}

Expected behavior

  • litellm/claude-sonnet-4-6 → uses @ai-sdk/anthropic (provider default)
  • litellm/azure/gpt-4-1 → uses @ai-sdk/openai-compatible (per-model override)

Actual behavior

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.

Documentation reference

The Providers docs state under Troubleshooting:

"For mixed setups under one provider, you can override per model via provider.npm."

Workaround

Define two separate providers with different npm packages:

  • litellm with @ai-sdk/anthropic for Claude models
  • litellm-gpt with @ai-sdk/openai-compatible for GPT models

OpenCode version

1.17.1

Operating System

macOS

Activity

  1. OpeOginni commented on Jun 13, 2026

    @OpeOginni
    Contributor

    Hey @christianherweg0807 You have an issue with your config, the docs says its overridden by provider.npm, which means like <model_id>.provider.npm

    So 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!

  2. christianherweg0807 commented on Jun 15, 2026

    @christianherweg0807
    Author

    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.

  3. OpeOginni commented on Jun 15, 2026

    @OpeOginni
    Contributor

    @christianherweg0807 Did you make use of the new config shape I provioded in my reply?

  4. github-actions commented on Aug 15, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions