Skip to content

Claude Code with DeepSeek or GLM: a tested setup guide

Point Claude Code at an abliterated DeepSeek or GLM model with ANTHROPIC_BASE_URL. The settings we ran on 26 November 2026, what worked, and two problems we hit.

Published 7 min read

Claude Code can run on a model other than Claude if you point it at an Anthropic-compatible API. We set it up against CommentLLM's abliterated DeepSeek V4.1 Flash and GLM 5.3 models on 26 November 2026, gave it a real bug to fix, and recorded what happened. It worked. It also hit two problems you should know about before you start, and each one has a fix below.

The short version: set ANTHROPIC_BASE_URL to https://api.commentllm.com, ANTHROPIC_AUTH_TOKEN to your key and ANTHROPIC_MODEL to a model ID. Leave auto mode, and set the context window for the model you use.

Anthropic's documentation says it does not support routing Claude Code to non-Claude models through a gateway. Everything here is what we observed with Claude Code 2.1.332. A future version may behave differently.

What you need

  • Claude Code. We used version 2.1.332.
  • A CommentLLM API key. Create one under Keys in the console after you sign up and add credit.
  • About five minutes.

We ran every step inside a Docker container with nothing in it but a small test project, which we recommend for a first try with any coding agent on an abliterated model.

Step 1: point Claude Code at CommentLLM

Claude Code reads its endpoint and model from environment variables. Put everything except the key in ~/.claude/settings.json, so it applies to every project:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.commentllm.com",
    "ANTHROPIC_MODEL": "deepseek-v4.1-flash-abliterated",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash-abliterated",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1048576",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
  }
}

Then put the key in your shell, not in a file you might commit:

export ANTHROPIC_AUTH_TOKEN="cllm_..."

What each setting does:

Setting Value Why
ANTHROPIC_BASE_URL https://api.commentllm.com Claude Code adds /v1/messages itself, so leave /v1 off
ANTHROPIC_AUTH_TOKEN Your cllm_ key Sent as Authorization: Bearer. With it set, Claude Code skips the login screen
ANTHROPIC_MODEL A model ID The model for the session
ANTHROPIC_DEFAULT_HAIKU_MODEL A model ID The model Claude Code uses for small background tasks
CLAUDE_CODE_MAX_CONTEXT_TOKENS The model's context window Claude Code does not know these models and otherwise assumes 1M tokens
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC 1 Turns off telemetry, error reporting and update checks

The ~/.claude/settings.json file we used, with the base URL, the two model IDs and the context window

We used deepseek-v4.1-flash-abliterated for the session and glm-5.3-flash-abliterated for background tasks. Every model has a 1,048,576-token context window. The model pages list all the IDs with their limits and rates.

Step 2: start Claude Code

Run claude in your project. On a first run it asks for a colour theme and shows its security notes, then asks whether you trust the folder. It did not ask us to log in.

Claude Code 2.1.332 starting on deepseek-v4.1-flash-abliterated through api.commentllm.com, with API Usage Billing in the header

The header shows the model and "API Usage Billing". Without CLAUDE_CODE_MAX_CONTEXT_TOKENS, Claude Code warns that the model "isn't recognized" and that it assumes a 1M-token context. With the setting from step 1 in place, we saw no warning.

Step 3: switch off auto mode

Claude Code now starts in auto mode, which lets it approve its own tool calls after a safety check. That check runs on Anthropic's servers. When your requests go to another API, as here, the check does not run. On our first command, Claude Code stopped and said so:

Claude Code explaining that auto mode's safety check runs on the server and does not get through api.commentllm.com

If you stay in auto mode, Claude Code asks you to approve each action that needs the check. We did that for the bug fix below. Press Shift+Tab to pick another mode instead:

  • Manual mode asks before every file edit and every command that changes something. Use it on any code you care about.
  • Accept edits edits files and runs file commands such as rm and mv in the project without asking, and asks before other commands. We used it for the GLM session.

Every new session starts in auto mode again. To start in another mode, add this to ~/.claude/settings.json next to the env block:

"permissions": { "defaultMode": "acceptEdits" }

Step 4: give it a task

Our test project had a log-triage script with a bug: it counted failed SSH logins by username instead of by source address, so both tests failed. We asked:

The test suite fails. Run the tests, find the bug in auth_triage.py and fix it. Then run the tests again.

On DeepSeek V4.1 Flash Abliterated, still in auto mode and with us approving each command, Claude Code read the files, ran the tests, found the wrong capture group, changed one line and ran the tests again. The model's own working time was 47 seconds.

Claude Code on DeepSeek V4.1 Flash Abliterated fixing a one-line bug in auth_triage.py and reporting that both tests pass

We then started a new session on GLM 5.3 Abliterated with claude --model glm-5.3-abliterated and asked for a Sigma rule that flags five or more failed SSH logins from one address in ten minutes. It wrote the rule and explained it in 20 seconds.

Claude Code on GLM 5.3 Abliterated writing a Sigma rule for SSH brute force and explaining it

The rule's condition used Sigma's older aggregation syntax, which current Sigma tools replace with correlation rules, so it needed a rewrite before use. The model said itself that support for that line varies by tool. Review what any model writes before you deploy it.

Step 5: switch models with /model

To move a session to the other model, type /model with the model ID:

/model glm-5.3-flash-abliterated

Claude Code's /model command switching the session to GLM 5.3 Flash Abliterated, which then reads auth_triage.py and answers

The switch took effect at once, and GLM 5.3 Flash read the file and answered in 4 seconds in the same session. Claude Code also saved it as the default, but noted that ANTHROPIC_MODEL in settings.json still decides the model for new sessions. To start on another model instead, change ANTHROPIC_MODEL or run:

claude --model glm-5.3-flash-abliterated

CLAUDE_CODE_MAX_CONTEXT_TOKENS does not change when you switch. Every CommentLLM model has the same 1,048,576-token window, so one value covers them all.

Claude Code checks a model by asking for a one-token answer, and a reasoning model cannot answer in one token. CommentLLM returns an empty answer cut off at the limit, as Anthropic's API does, so the switch works on reasoning models too.

Which model to use with Claude Code

Model ID In our test Choose it for
deepseek-v4.1-flash-abliterated Fixed the bug in 47 seconds of model time Most coding work
deepseek-v4.1-flash-abliterated-fast Not run in Claude Code. About five times the standard model's speed on the API The same work when speed matters
glm-5.3-abliterated Wrote the Sigma rule in 20 seconds Harder reasoning
glm-5.3-flash-abliterated Answered a question about the code in 4 seconds Quick answers and background tasks

All four have a 1,048,576-token context window and write up to 32,768 tokens in one answer. The pricing page lists current rates. All of our testing for this guide, across Claude Code, Codex CLI and opencode, cost less than $0.10.

What does not work

  • Auto mode, as described in step 3.
  • Images. The models accept text only, so a message with a pasted image fails with an error.
  • Structured output. Claude Code's JSON-schema requests are not enforced, so the model answers in free text.

Tool calling, streaming and file edits all worked. Claude Code still sends some Claude-specific request fields to an unrecognized model. Setting CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 removes most of them if you see errors about unsupported fields.

Is this allowed?

Claude Code reads these environment variables, but Anthropic does not support running it on non-Claude models. On CommentLLM, every organization accepts the Acceptable Use Policy, which allows security work you are authorized to do. Abliterated models refuse far fewer requests than standard ones, which is why security teams use them, and also why you should run an agent on one in a sandbox or a project you can afford to lose.

Setting up a different agent? See Codex CLI with a custom provider or opencode with a custom provider. Or compare all three, and the models, on uncensored coding AI.

Questions

Can Claude Code use DeepSeek?

Yes, through an Anthropic-compatible API. Set ANTHROPIC_BASE_URL to the API, ANTHROPIC_AUTH_TOKEN to your key and ANTHROPIC_MODEL to the model ID. We ran Claude Code 2.1.332 on DeepSeek V4.1 Flash Abliterated this way on 26 November 2026, and it fixed a bug and ran tests. Anthropic does not support non-Claude models, so a later version may behave differently.

What should ANTHROPIC_BASE_URL be for CommentLLM?

Set it to https://api.commentllm.com, without /v1. Claude Code adds /v1/messages to the base URL itself.

Should I use ANTHROPIC_AUTH_TOKEN or ANTHROPIC_API_KEY?

Either works with CommentLLM. ANTHROPIC_AUTH_TOKEN is sent as a Bearer token and skips the login screen. ANTHROPIC_API_KEY is sent as x-api-key, and Claude Code asks you to approve it once in interactive mode.

Why does Claude Code say the model isn't recognized?

Claude Code only knows the context windows of Anthropic's models. For any other model it assumes 1M tokens and shows a warning. Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's real context window, which is 1048576 for every CommentLLM model.

Can I switch models in Claude Code with /model?

Yes. Type /model followed by the model ID, for example /model glm-5.3-flash-abliterated. The current session switches at once. New sessions still start on the model in ANTHROPIC_MODEL while it is set.

Why does auto mode not work with a custom API?

Auto mode's safety check runs on Anthropic's servers, and requests sent to another API do not reach it. Claude Code then asks you to approve each action. Use manual mode or accept-edits mode instead.

Does Claude Code tool calling work with abliterated models?

Yes. CommentLLM's models call tools on the Anthropic Messages endpoint, with streaming. In our test Claude Code read files, edited code and ran commands on DeepSeek V4.1 Flash Abliterated, and read and wrote files on the GLM models.

Start building today.

Create an account, tell us what you work on, and send your first request.