How to Use DeepSeek (or Any Model) in Claude Code
Run Claude Code on DeepSeek, OpenRouter, Ollama or any OpenAI-compatible model through a local gateway. One-click setup, the exact settings.json changes, protocol conversion and routing explained.
Claude Code is one of the best terminal coding agents available, but out of the box it talks to one API: Anthropic Messages. If you want to try DeepSeek, a model on OpenRouter, or a local model in Ollama inside the same workflow, you need something that speaks Anthropic Messages to Claude Code and the right protocol to everything else.
This tutorial shows how to do that with AutoJev, a free, open-source desktop app that runs one local gateway at http://127.0.0.1:9527 for your AI agents. You will:
- Add DeepSeek (or any provider) once.
- Connect Claude Code with one click.
- Understand exactly what changes in
~/.claude/settings.json. - Learn what protocol conversion can and cannot do.
- Use routes so Claude Code can switch between models without editing config again.
Why Claude Code needs a translator
Claude Code sends requests in the Anthropic Messages format to whatever ANTHROPIC_BASE_URL points at. DeepSeek's main API, OpenRouter, Ollama and most model hosts expose the OpenAI Chat Completions format instead. The two formats differ in how they represent system prompts, tool definitions, tool calls, tool results, streaming events and usage.
You could point ANTHROPIC_BASE_URL at a provider that offers an Anthropic-compatible endpoint, but then you are tied to that one provider, and switching means editing settings by hand each time.
AutoJev sits in between. Claude Code talks Messages to 127.0.0.1:9527. AutoJev picks a model, converts the request to whatever that model's upstream speaks, calls the provider directly from your machine, and converts the response — including streaming and tool calls — back into Messages.
Claude Code ──Messages──▶ AutoJev (127.0.0.1:9527) ──Chat Completions──▶ DeepSeek
│
└──────────────Chat Completions──▶ OpenRouter / OllamaStep 1: Install AutoJev
Download AutoJev from the download page. It runs on macOS (Apple Silicon and Intel), Windows x64 and Linux x64. There is no AutoJev account and no paid plan; you bring your own provider keys.
When you open the app, the local gateway starts on port 9527.
Step 2: Add DeepSeek as a provider
Open Providers and choose the DeepSeek preset. The base URL is filled in for you:
https://api.deepseek.comPaste your DeepSeek API key and click the provider test. Keys are stored locally in ~/.autojev/autojev.db. Note that they are currently stored unencrypted, so treat that file like any other credential store.
Not using DeepSeek? The same steps work with the OpenAI, OpenRouter and Ollama presets, or with OpenAI Compatible and Anthropic Compatible for any other endpoint — for example Kimi (Moonshot), GLM (Zhipu), Qwen (DashScope), SiliconFlow, vLLM or LM Studio. If you already keep providers in CC Switch or Termany, import them instead of retyping.
Step 3: Add a model
Open Models and add a model for the DeepSeek provider:
- API type:
chat_completions— this describes the upstream, not Claude Code. Do not set it tomessagesjust because Claude Code speaks Messages; AutoJev converts on the way in. - Model ID: the exact ID from DeepSeek's API documentation, for example
deepseek-chat. - Prices: input, output and cache prices per 1M tokens. These drive the estimated cost in Usage and cost-based routing.
The model is now available to agents as deepseek/deepseek-chat (provider ID, slash, model ID).
Optionally run a speed test. AutoJev sends three short streaming requests and records first-content latency and output tokens per second, so you know what to expect before you start a long session.
Step 4: Connect Claude Code in one click
Open Agents. AutoJev detects Claude Code and shows its configuration path, ~/.claude/settings.json. Select the model (or several models and routes) and click Connect.
Before the first change, AutoJev backs up your original file. Then it writes these fields:
{
"model": "deepseek/deepseek-chat",
"modelPicker": {
"replaceBuiltInOptions": true,
"options": [
{
"model": "deepseek/deepseek-chat",
"label": "DeepSeek Chat",
"description": "AutoJev · deepseek/deepseek-chat",
"behavesAs": "claude-sonnet-4-6"
}
]
},
"env": {
"ANTHROPIC_BASE_URL": "http://127.0.0.1:9527",
"ANTHROPIC_AUTH_TOKEN": "autojev-local-claude",
"ANTHROPIC_MODEL": "deepseek/deepseek-chat",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek/deepseek-chat",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek/deepseek-chat",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek/deepseek-chat",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "deepseek/deepseek-chat"
}
}What each part does:
ANTHROPIC_BASE_URLsends every Claude Code request to the local gateway. There is no/v1suffix because Anthropic clients add/v1/messagesthemselves.ANTHROPIC_AUTH_TOKENis a placeholder. The local gateway does not check it; it labels the requests as coming from Claude Code in Logs. Your real DeepSeek key never appears in Claude Code's settings.ANTHROPIC_MODELand theANTHROPIC_DEFAULT_*_MODELvariables point all of Claude Code's model slots at your selection, so background tasks that would normally use a smaller model also go through AutoJev.modelPickerreplaces the built-in options with the models and routes you selected, so you can switch between them from Claude Code's model menu.behavesAsonly affects client-side compatibility in Claude Code; it does not rewrite which upstream model is called.
Other keys in your settings.json — themes, permissions, hooks — are left alone.
Restart Claude Code if it was already running, then try it:
claude "Explain what this repository does in three sentences"Open Logs in AutoJev. You should see the request with agent Claude Code, model deepseek-chat, provider DeepSeek, token counts, first-byte and total time, and an estimated cost.
Step 5: Disconnect cleanly
When you want Claude Code back on its original setup, click Disconnect. AutoJev restores the backed-up configuration while keeping later edits you made that do not conflict with the fields it wrote.
You can also use Stop and restore configurations to restore every connected agent and shut the gateway down, or Quit AutoJev (restore agents) from the tray. On the next launch, AutoJev reconnects agents according to your saved preferences; agents you disconnected manually stay disconnected.
What protocol conversion handles — and what it does not
AutoJev converts in all six directions among Anthropic Messages, OpenAI Chat Completions and OpenAI Responses. For Claude Code on a Chat Completions model, that covers:
- System instructions and text conversation history.
- Images, both URLs and base64.
- Function tool definitions, tool choice, tool calls and tool results with stable call IDs — the core of how Claude Code edits files and runs commands.
- Streaming text and streaming tool arguments.
- Token usage and protocol-shaped errors.
Be aware of the limits:
- Conversion cannot add capabilities. If a model does not support tools or images, routing Claude Code to it will not change that. Pick models that handle tool calling well for agent work.
- Thinking blocks are dropped. Provider-specific thinking content, encrypted reasoning and signatures are not portable between protocols. If a model's reasoning output matters to your workflow, use a model whose native protocol matches.
- Some features have no equivalent. Hosted tools, audio and file content are rejected when converting rather than silently ignored.
Full details are on the protocol conversion page.
Go further: route instead of hard-coding a model
Pointing Claude Code at a single model works, but the real benefit of a gateway is that the model can change without touching settings.json again. Create a route in AutoJev and connect Claude Code to that route instead. Routes appear to agents as autojev/<route-id>.
Some useful patterns:
| Route | Strategy | Example use |
|---|---|---|
autojev/cheap | Intelligent selection, Lower cost | Picks the cheapest candidate that meets the capability requirements, decided locally |
autojev/fast | Intelligent selection, Lower latency | Picks from recent speed-test measurements, decided locally without calling Jev |
autojev/quality | Intelligent selection, Higher quality | Asks the OpenRouter Jev decision model to choose |
autojev/mixed | Load balancing | Spreads new sessions across DeepSeek and an OpenRouter model by weight |
A few details matter for agent sessions:
- Session affinity. Requests in the same session keep their selected model while it stays eligible, so Claude Code does not switch models mid-task.
- Failover. If DeepSeek returns a connection error, 401, 402, 403, 408, 429 or 5xx before any output starts, AutoJev tries the next candidate. Defaults are up to 4 attempts and a 30-second cooldown, and
Retry-Afteris respected. A response that has already started streaming is never replayed, which avoids duplicated tool actions. - Privacy of decisions. For quality and balanced routes, only routing metadata — derived task features and candidate model metadata — is sent to Jev, never your conversation. If Jev is unavailable or its confidence is below 0.5, AutoJev falls back to weighted load balancing.
Read more in smart routing and failover and load balancing.
Using other clients with the same setup
The same gateway serves every agent. Codex, Gemini CLI, OpenCode, Hermes and others can be connected from the same Agents page, and any client that accepts a base URL and key can use the Connection parameters dialog. For an Anthropic-protocol client the parameters look like this:
ANTHROPIC_BASE_URL=http://127.0.0.1:9527
ANTHROPIC_API_KEY=autojev-local-my-tool
ANTHROPIC_MODEL=autojev/cheapThe suffix after autojev-local- labels that client's requests in Logs.
Troubleshooting
Claude Code still uses Anthropic. Restart Claude Code; it reads settings.json at startup. Check that Agents shows Claude Code as connected.
Requests fail with gateway_paused. The gateway is paused. Resume it in AutoJev.
Tool calls behave oddly on a small model. The protocol is converted faithfully, but the model still has to be good at tool use. Try a stronger model or a route with failover to one.
I want to see exactly what was sent. Use the debug console in Conversation or cURL mode, switch the API type to Messages, and inspect the raw JSON response.
Summary
With AutoJev, Claude Code keeps speaking Anthropic Messages while your requests go to DeepSeek, OpenRouter, Ollama or any OpenAI-compatible model. One click writes a small, reversible set of fields to ~/.claude/settings.json, protocol conversion handles tools and streaming, and routes let you change models without touching configuration again.
Next steps: