DeepSeek V4.1 Flash — Read Me
Environment variables onlymacOS · Linux · Windows

A TINY FIELD GUIDE

Set up DeepSeek V4.1 Flash in Claude Code.

V4.1 Flash, in a separate profile. Your existing Claude Code. No extra tools.

PROVIDERHugging Face
CONTEXT1M tokens
COMPACT WINDOW400K tokens
SUBAGENTSV4.1 Flash

This guide uses only environment variables to set up DeepSeek in a separate profile, keeping your regular Claude Code settings and login unchanged.

1Choose your provider.

Let your agent set it up via Hugging Face.

Plain text ↗Paste into your coding agent. Uses the selected provider.

Hugging Face automatically selects the fastest provider, with failover. Use an HF token with Inference Providers permission. Get a key ↗

Environment variableValue
CLAUDE_CONFIG_DIRAbsolute path to a separate folder named claude-deepseek (not a command).
ANTHROPIC_BASE_URLhttps://router.huggingface.co
ANTHROPIC_AUTH_TOKENYour HF token (Make calls to Inference Providers permission).
ANTHROPIC_API_KEYThe same HF token.

Use this exact model ID for the main conversation, aliases, and subagents.

Environment variableValue
ANTHROPIC_MODELdeepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_FABLE_MODELdeepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_OPUS_MODELdeepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_SONNET_MODELdeepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_HAIKU_MODELdeepseek-ai/DeepSeek-V4.1-Flash
CLAUDE_CODE_SUBAGENT_MODELdeepseek-ai/DeepSeek-V4.1-Flash
CLAUDE_CODE_SUBAGENT_MODEL_FORCE1

Values only, not a shell script. Use your OS’s environment settings; Claude Code does not automatically read a .env file.

2Set context & task tracking.

Environment variableValue
CLAUDE_CODE_MAX_CONTEXT_TOKENS1000000
CLAUDE_CODE_AUTO_COMPACT_WINDOW400000
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC1
CLAUDE_CODE_ENABLE_TODO_TOOLS1

Task tracking is explicitly enabled for custom models. The same 1M / 400K settings as our DeepSeek profile. The compaction window is a budget, not a guarantee of the exact trigger token. Use a route supporting at least 1M tokens; these variables do not increase provider capacity.

3Launch Claude Code.

A profile is a folder for Claude Code’s settings, login, and conversations. Here, claude-deepseek is that folder’s name; setting CLAUDE_CONFIG_DIR does not create a command with that name.

Run claude from your project with the custom environment. To return to native Claude, use a fresh terminal without those overrides.

Compatibility & profile details

Both services expose Anthropic-compatible endpoints. Hugging Face / Novita and OpenRouter were tested with Claude Code on 11 September 2026. Claude Code features may behave differently with non-Claude models.

Our original launcher also uses --dangerously-skip-permissions. That optional CLI flag bypasses permission checks; it is not needed for this connection.

Remove inherited OAuth credentials and cloud-provider selectors from the custom launch environment. A separate profile does not isolate project instructions, managed policies, or your filesystem.

Read the agent instructions
Set up a separate DeepSeek V4.1 Flash profile using Hugging Face and these environment variables. Use the existing Claude Code install (2.1.257+); no extra tools or setup script.

CLAUDE_CONFIG_DIR = Absolute path to a separate folder named claude-deepseek (not a command).
ANTHROPIC_BASE_URL = https://router.huggingface.co
ANTHROPIC_AUTH_TOKEN = Your HF token (Make calls to Inference Providers permission).
ANTHROPIC_API_KEY = The same HF token.
ANTHROPIC_MODEL = deepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_FABLE_MODEL = deepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_OPUS_MODEL = deepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_SONNET_MODEL = deepseek-ai/DeepSeek-V4.1-Flash
ANTHROPIC_DEFAULT_HAIKU_MODEL = deepseek-ai/DeepSeek-V4.1-Flash
CLAUDE_CODE_SUBAGENT_MODEL = deepseek-ai/DeepSeek-V4.1-Flash
CLAUDE_CODE_SUBAGENT_MODEL_FORCE = 1
CLAUDE_CODE_MAX_CONTEXT_TOKENS = 1000000
CLAUDE_CODE_AUTO_COMPACT_WINDOW = 400000
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC = 1
CLAUDE_CODE_ENABLE_TODO_TOOLS = 1

Keep changes scoped to this profile, preserving native Claude settings and running sessions. Use a locally supplied key without displaying it. Ask only for missing setup details.

Check for conflicting settings. In this profile’s launch environment only, clear inherited OAuth/cloud-provider overrides and unset DISABLE_AUTO_COMPACT and DISABLE_COMPACT. Report conflicts requiring changes elsewhere.

The profile name claude-deepseek is a folder name, not an automatically created command. List changed files and give the OS-appropriate command to launch the existing claude binary with this profile’s environment. Keep normal permission checks. Leave launching and testing to me; do not start a session or make inference calls.

References:
https://code.claude.com/docs/en/env-vars
https://huggingface.co/docs/inference-providers/en/integrations/claude-code
https://router.huggingface.co/v1/models

Have a better setup?

Share your tips or improvements. Let’s discuss ↗

One profile per endpointChoose at launch.