Coding agentsDec 1, 2026Ghost research

How to run uncensored models in Claude Code

Claude Code can talk to any server that speaks the Anthropic Messages API. Point it at Ghost and it runs uncensored open models like GLM 5.3, DeepSeek V4.1 and Ghost X2, with your own Claude login left untouched.

  • Claude Code honors ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN, so any Anthropic-compatible server can stand in for Anthropic's.1
  • Ghost serves the Anthropic Messages format at https://api.thesapientdirective.com, so Claude Code works with no proxy and no fork.2
  • Pick a model with tool calling and a long context. Ghost X2, GLM 5.3 Uncensored and DeepSeek V4.1 Flash Uncensored all handle Claude Code's tools.
  • We ran this end to end against production on November 30, 2026, along with Codex, OpenCode, Hermes Agent, OpenClaw, Cline, Kilo Code, Aider, SillyTavern and Open WebUI.

Claude Code reads where to send its requests from a handful of environment variables. Set them to Ghost and the same terminal agent you already know runs on an open model with its refusals removed. Nothing about your Anthropic account changes, and you can switch back by closing the terminal.

Why people want this

Claude Code is one of the best agent loops for working in a real codebase. The model behind it still refuses some requests that are routine for security engineers, penetration testers and researchers: explaining how an exploit works for a CTF, analyzing a malware sample you were handed, or testing your own login page against injection. An abliterated model keeps the loop and drops the refusal, so the agent finishes the job instead of stopping to explain why it will not.

Set it up in two minutes

You need a Ghost API key. Make one on the API page or let the Connect page make it and copy the whole command for you.

On Mac or Linux, run this in any terminal, then start Claude Code:

export ANTHROPIC_BASE_URL=https://api.thesapientdirective.com
export ANTHROPIC_AUTH_TOKEN=YOUR_GHOST_KEY
export ANTHROPIC_MODEL=ghost-x2
export ANTHROPIC_SMALL_FAST_MODEL=ghost-x2
export ANTHROPIC_DEFAULT_OPUS_MODEL=ghost-x2
export ANTHROPIC_DEFAULT_SONNET_MODEL=ghost-x2
export ANTHROPIC_DEFAULT_HAIKU_MODEL=ghost-x2
claude

On Windows PowerShell, the same thing:

$env:ANTHROPIC_BASE_URL="https://api.thesapientdirective.com"
$env:ANTHROPIC_AUTH_TOKEN="YOUR_GHOST_KEY"
$env:ANTHROPIC_MODEL="ghost-x2"
$env:ANTHROPIC_SMALL_FAST_MODEL="ghost-x2"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="ghost-x2"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="ghost-x2"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="ghost-x2"
claude

The variables only live in that terminal window. Your normal claude in any other window still uses your Anthropic plan.

Which model to pick

Claude Code sends its whole conversation, its tool list and the files it read on every step, so two things matter most: reliable tool calls and a long context window.

ModelAPI idContextInput per 1MOutput per 1MGood for
Ghost X2ghost-x2256K$0.20$0.80Everyday coding, the cheapest strong option
GLM 5.3 Uncensoredglm-5-3-uncensored1M$3$5Hard problems and very large codebases
DeepSeek V4.1 Flash Uncensoreddeepseek-v4-1-flash-uncensored256K$0.60$2.25Reasoning-heavy debugging
Kimi K3.1 Pro Uncensoredkimi-k3-1-pro-uncensored256K$7.50$22.50Frontier-scale reasoning
CyberHeabsycyberheabsy256K$2.25$6.75Security testing on your own systems

Swap the id into every ANTHROPIC_*_MODEL line. The full list with live prices is on the Models page.

What it costs

On the API you pay per token, and credits never expire. A typical Claude Code step sends a few thousand tokens and gets a few hundred back, so on Ghost X2 a long session usually costs cents, not dollars. If you would rather pay a flat price, the Pro plan at $20 a month covers Connect use too, measured against the plan's usage allowance.3

If something goes wrong

  • 401 Unauthorized: the key is wrong or was deleted. Make a new one and paste it again.
  • Claude Code still shows Anthropic models: the variables were set in a different window. Run the export lines and claude in the same terminal.
  • "Claude Code doesn't recognize the model": this notice is expected. Claude Code does not know Ghost's model ids, so it assumes a 1M token window and keeps working. Most Ghost models have 256K, so compact earlier on long sessions, or set the window as Anthropic describes in its model configuration guide.
  • Context errors on long sessions: use /compact, or switch to GLM 5.3 Uncensored, which has a 1M token window.

What Ghost still blocks

Ghost removes reflexive refusals, not every rule. Six categories are prohibited on every model: sexual content (including between adults), anything sexual involving minors, violent harm, illegal harm such as hard-drug synthesis or malware built to attack systems, self-harm instructions, and hate. Ghost still discusses these subjects when the question is informational, and defensive security work on systems you own or are authorized to test is in scope. The Content Policy has the details.

FAQ

Does this break my Claude subscription?

No. The variables only apply to the terminal you set them in. Close it, or open a new one, and Claude Code uses your Anthropic account again.

Can I use Codex the same way?

Yes. Codex takes a custom provider in ~/.codex/config.toml; the Codex guide has the four lines.

Is an uncensored model worse at coding?

Abliteration removes the refusal direction from a model and leaves the rest of its weights alone, so coding ability is largely unchanged. Pick by size and context: bigger models write better code.

Sources

  1. Claude Code: LLM gateway and environment variable settings, Anthropic docs
  2. Ghost API docs: Claude Code
  3. Ghost plans, pricing and limits

Authors

Ghost research. Written by the Ghost team at The Sapient Directive. Ghost prices and model details are checked against the live Models page; if they ever differ, that page is right.

Keep reading