Generic Anthropic Providers
Relevant source files
The following files were used as context for generating this wiki page:
Generic Anthropic Providers within the shunt gateway refer to any LLM backend that adheres to the Anthropic Messages API protocol. These providers are integrated using the anthropic adapter kind, which facilitates transparent proxying of requests and responses while preserving streaming semantics and tool-use capabilities. This architecture allows shunt to support a wide range of third-party models—such as those from Kimi, DeepSeek, and MiniMax—without requiring custom code for each unique service, provided they implement the standard Anthropic interface.
The primary purpose of these providers is to allow users of Claude Code to redirect inference to alternative, potentially cheaper or more specialized models while maintaining the same client-side harness. The gateway ensures that unmapped traffic passes through to the default Anthropic service unchanged, while specifically routed model IDs are diverted to the configured generic upstreams.
Sources: ARCHITECTURE.md:6-18, blueprints/provider/_generic.md:12-16
Architecture and Protocol Handling
Generic Anthropic Providers utilize the anthropic adapter, which acts as a passthrough for the Anthropic Messages API. Unlike the responses adapter, which performs protocol translation from Anthropic to OpenAI, the generic Anthropic path maintains the native request and response shapes.
Request Pipeline
When a request is received, the gateway buffers the body and snapshots the configuration. The routing::resolve logic identifies the appropriate Route based on the requested model ID. If the route is associated with an anthropic adapter kind, the gateway forwards the request to the upstream base_url defined in the configuration.
The diagram above illustrates the high-level data flow for a request routed to a generic Anthropic provider.
Sources: ARCHITECTURE.md:14-22, blueprints/provider/_generic.md:14
Invariants and Constraints
- Streaming Semantics: The gateway must never buffer upstream Server-Sent Events (SSE) unless the client specifically requested non-streaming output. This preserves incremental rendering in Claude Code.
- Error Shaping: Errors generated by the gateway itself are reshaped into the Anthropic error envelope to ensure compatibility with the HTTP client.
- Configuration-Driven: Support for new providers is primarily added via configuration (
[[upstreams]]and[[models]]) rather than code changes.
Sources: ARCHITECTURE.md:23-26, blueprints/provider/_generic.md:46-52
Configuration and Integration
Integrating a generic Anthropic provider involves defining an upstream in the shunt.toml or shunt.yaml configuration files.
Upstream Definition
An upstream entry specifies the protocol kind, the base URL of the service, and the authentication method. For generic providers, kind must be set to "anthropic".
| Field | Description | Requirement |
|---|---|---|
name | A stable identifier for the upstream. | Required |
kind | Must be "anthropic" for generic compatible upstreams. | Required |
base_url | The API endpoint (e.g., https://api.deepseek.com). | Required |
auth | Authentication configuration (e.g., api_key or passthrough). | Required |
Sources: blueprints/upstream/_generic.md:31-40, blueprints/upstream/anthropic.md:19-24
Model Routing
Model routing maps a client-side model ID (the ID used by Claude Code) to the specific model identifier required by the upstream provider.
The diagram shows how a user-facing model ID is translated to a provider-specific ID.
Sources: blueprints/upstream/_generic.md:52-61, plugins/shunt-deepseek/agents/deepseek-v4-pro.md:1-5
Implementation Example
The following snippet demonstrates how to configure a generic upstream for a provider like DeepSeek using an environment variable for the API key.
[[upstreams]]
name = "deepseek"
kind = "anthropic"
base_url = "https://api.deepseek.com"
auth = { mode = "api_key", env = "DEEPSEEK_API_KEY" }
[[models]]
id = "deepseek-v4-pro"
display_name = "DeepSeek V4 Pro"
[models.upstream_model]
deepseek = "deepseek-chat"
Sources: blueprints/upstream/_generic.md:36-40, blueprints/upstream/anthropic.md:46-52
Supported Provider Agents
The project includes several predefined agent configurations that utilize generic Anthropic routing. These agents are designed to work within the Claude Code harness but execute on alternative backends.
| Agent Model | Provider | Description |
|---|---|---|
kimi-k3 | Moonshot AI | Flagship model with 1M-token context support. |
deepseek-v4-pro | DeepSeek | General-purpose professional tier model. |
minimax-m3 | MiniMax | High-context (1M-token) specialized model. |
mimo-v2.5-pro | Xiaomi | General-purpose engineering agent model. |
Sources: plugins/shunt-kimi/agents/kimi-k3.md:1-6, plugins/shunt-deepseek/agents/deepseek-v4-pro.md:1-5, plugins/shunt-minimax/agents/minimax-m3.md:1-6, plugins/shunt-mimo/agents/mimo-v2.5-pro.md:1-5
Validation and Testing
To ensure a generic provider is correctly integrated, the shunt check command is used to validate the configuration file for schema errors and mismatched provider kinds.
Verification Steps
- Config Check: Run
shunt checkto confirm the TOML/YAML structure is valid. - Discovery: Access the
/v1/modelsendpoint to verify the custom model is exposed. - Inference: Send a test message to the gateway to confirm the upstream successfully returns a response.
Summary
Generic Anthropic Providers allow the shunt gateway to remain extensible and vendor-neutral. By leveraging the anthropic adapter, the system can incorporate any third-party LLM that implements the Anthropic Messages protocol. This approach minimizes code duplication, relies on table-driven configuration, and ensures that the core features of the Claude Code environment—such as streaming and tool execution—remain functional across different model backends.