Currently Available: Need a skilled Software Developer for your next project?
Categories
Coding Agents

How to Use Claude Code With DeepSeek or Another Anthropic-Compatible Provider

Claude Code is Anthropic’s command-line coding assistant. It sends requests to a model provider, which reads the prompt and returns responses, including instructions for working with code. DeepSeek and some other providers accept requests in Anthropic’s Messages API format, the structure Claude Code uses to communicate with models.

To connect Claude Code to one of these providers, set its API address, credentials, and model name as environment variables, which are settings that programs read when they start. Do this before launching Claude Code. Claude Code remains the coding interface, and the provider you choose handles the model requests. A provider that accepts Anthropic’s API format can still use its own models, support only some Claude Code features, and fall outside Anthropic’s support for non-Claude models.

Connect Claude Code to DeepSeek

Install Claude Code using Anthropic’s current setup instructions, then create a DeepSeek API key. In macOS or Linux, use the terminal where you plan to run Claude Code to configure its endpoint. The commands below also set the API key and model:

export ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="YOUR_DEEPSEEK_API_KEY"
export ANTHROPIC_MODEL="deepseek-flash[1m]"

cd /path/to/project
claude

ANTHROPIC_BASE_URL tells Claude Code which API address to send requests to. ANTHROPIC_AUTH_TOKEN supplies your API key, and ANTHROPIC_MODEL selects a model name DeepSeek accepts. Replace the placeholder key with your own; the value shown is not a working credential. DeepSeek documents this endpoint and model setting in its Claude Code integration instructions.

These export commands apply to the current shell and programs launched from it. If you open a new terminal, set the variables there too, or use a local tool for storing secrets. Do not commit an API key to a repository or put it in a shared project settings file.

Set the variables in Windows PowerShell with this syntax:

$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="YOUR_DEEPSEEK_API_KEY"
$env:ANTHROPIC_MODEL="deepseek-flash[1m]"

cd C:\path\to\project
claude

After Claude Code starts, run /status to inspect the active connection details when they are available. Check DeepSeek’s usage dashboard as well to confirm that requests reached the intended account. The status display can vary by provider.

Check model names and feature support

Choose a model name that the provider lists in its documentation. A provider can accept Anthropic-formatted requests at its API address while serving a different model with different capabilities. For example, DeepSeek documents model names such as deepseek-flash[1m] and deepseek-flash. A model name that starts with Claude can still point to a DeepSeek model. DeepSeek says its endpoint maps Claude-prefixed names to DeepSeek models. Use an explicit DeepSeek model name to see which provider model you selected.

Providers support different parts of Anthropic’s API. DeepSeek’s compatibility documentation says its endpoint ignores some request fields, including mcp_servers and service_tier, and handles some tool-use and thinking settings differently from Anthropic’s API. It documents image support for deepseek-flash, while stating that deepseek-v4-pro does not process images. These are DeepSeek-specific details, not rules for every compatible provider. Check the provider’s Anthropic API compatibility notes for the features your coding work depends on.

A provider’s decision to ignore one API field does not by itself show whether a separate Claude Code feature works from start to finish. For example, DeepSeek’s note that its endpoint ignores the mcp_servers request field does not establish whether every local Model Context Protocol integration works with Claude Code and DeepSeek. Test the specific feature you plan to use.

Use another provider or a gateway

A gateway receives Claude Code’s requests and forwards them to a model provider. It can provide one API address for authentication, usage tracking, budgets, or routing. Anthropic’s gateway documentation also warns that gateways must keep up with changes to Claude Code’s request format and features. Anthropic says it does not support routing Claude Code to non-Claude models through a gateway.

OpenRouter documents how to set up a gateway with its API key and endpoint:

export OPENROUTER_API_KEY="YOUR_OPENROUTER_API_KEY"
export ANTHROPIC_BASE_URL="https://openrouter.ai/api"
export ANTHROPIC_AUTH_TOKEN="$OPENROUTER_API_KEY"
export ANTHROPIC_API_KEY=""

OpenRouter recommends clearing ANTHROPIC_API_KEY to avoid a credential conflict. If Claude Code has a cached Anthropic login, OpenRouter instructs users to run /logout and restart Claude Code before checking /status. Those steps apply to OpenRouter’s documented setup; do not assume another provider needs them. OpenRouter also cautions that Claude Code is guaranteed to work with Anthropic’s first-party provider, so compatibility with a model routed through OpenRouter is not guaranteed. See its Claude Code integration instructions.

For any other provider, confirm its Anthropic-format endpoint, authentication method, accepted model identifiers, supported features, and billing rules in that provider’s own documentation. Avoid copying DeepSeek’s or OpenRouter’s settings without checking that they match the service you chose.

Check privacy, billing, and support limits

Requests go to the endpoint configured in ANTHROPIC_BASE_URL. Before sending private or proprietary code, review the provider’s API-specific terms for data retention, training use, and processing location. A general consumer privacy policy does not necessarily describe how the provider handles API traffic.

Check the provider’s current pricing page and usage dashboard before relying on a cost estimate. Published per-token prices describe model charges, but your coding costs depend on which requests Claude Code sends and which model serves them. DeepSeek’s documentation has given conflicting information about which model serves a model name and how DeepSeek bills it. Check the model and charge shown in your account; the model name alone does not confirm either.

What I'm building

Delegate tasks. Get software.

Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.

Take a look at vroni.com

Email updates

Usually a new article and a few links I found interesting.

No spam. Unsubscribe with one click.

Leave a Reply

Your email address will not be published. Required fields are marked *