Integrating with Claude Code
Last Updated: 2026-05-13 Supported Model:
intern-s2-previewAPI Endpoint:https://chat.intern-ai.org.cn/v1/messages
Our Claude-like API is compatible with the Claude Code client, so with intern-s2-preview you can use Intern directly inside Claude Code. There are three ways to wire it up — pick whichever feels best:
- Method 1 · Environment variables: one-shot, doesn't touch any existing config.
- Method 2 · settings.json: persistent, written into Claude Code's own config.
- Method 3 · Shell alias: lives alongside the official Claude, switch on demand.
Getting Ready
Make sure Claude Code is installed (recommended >= 1.0.0):
npm install -g @anthropic-ai/claude-code
Then grab an API token from the Intern console: API Tokens. Every method below needs it.
Under the hood, you only need to tell Claude Code two things: where to send the request and who's asking. These map to
ANTHROPIC_BASE_URLandANTHROPIC_AUTH_TOKEN. All three methods just write them in different places.
Method 1: Environment Variables (fastest, try it first)
Set them in the current shell — nothing else changes. Close the terminal and everything is back to normal. Great for "let me just see if it works".
Linux / macOS
Open your terminal and paste these four lines (swap in your token):
export ANTHROPIC_BASE_URL="https://chat.intern-ai.org.cn"
export ANTHROPIC_AUTH_TOKEN="your-api-token"
export ANTHROPIC_MODEL="intern-s2-preview"
export ANTHROPIC_SMALL_FAST_MODEL="intern-s2-preview"
Then launch Claude Code:
claude
Inside Claude Code, run /status. If you see our Base URL and intern-s2-preview as the model, you're good 🎉
Windows PowerShell
$env:ANTHROPIC_BASE_URL = "https://chat.intern-ai.org.cn"
$env:ANTHROPIC_AUTH_TOKEN = "your-api-token"
$env:ANTHROPIC_MODEL = "intern-s2-preview"
$env:ANTHROPIC_SMALL_FAST_MODEL = "intern-s2-preview"
claude
To make it survive restarts, set them at the user level:
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://chat.intern-ai.org.cn", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "your-api-token", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "intern-s2-preview", "User")
[Environment]::SetEnvironmentVariable("ANTHROPIC_SMALL_FAST_MODEL", "intern-s2-preview", "User")
Windows CMD
set ANTHROPIC_BASE_URL=https://chat.intern-ai.org.cn
set ANTHROPIC_AUTH_TOKEN=your-api-token
set ANTHROPIC_MODEL=intern-s2-preview
set ANTHROPIC_SMALL_FAST_MODEL=intern-s2-preview
claude
Making it Permanent on Linux / macOS
The export lines above only live as long as the terminal does. To have them load every time, add them to your shell startup file.
Step 1 — figure out which shell you're using:
echo $SHELL
- Output mentions
zsh→ edit~/.zshrc(macOS default) - Output mentions
bash→ edit~/.bashrc(most Linux distros)
The example below uses zsh; for bash, just swap .zshrc for .bashrc.
Step 2 — open the file with any editor:
# Pick one
nano ~/.zshrc # Beginner friendly, shortcuts shown at the bottom
vim ~/.zshrc # If you're a vim person
code ~/.zshrc # If you have VS Code installed
If the file doesn't exist yet: touch ~/.zshrc first.
Step 3 — append the config at the end of the file:
# Intern Claude Code
export ANTHROPIC_BASE_URL="https://chat.intern-ai.org.cn"
export ANTHROPIC_AUTH_TOKEN="your-api-token"
export ANTHROPIC_MODEL="intern-s2-preview"
export ANTHROPIC_SMALL_FAST_MODEL="intern-s2-preview"
Save and quit (nano: Ctrl+O, Enter, then Ctrl+X; vim: :wq, Enter).
Step 4 — load the changes right now:
source ~/.zshrc
This is equivalent to opening a fresh terminal — the shell re-reads the config. Any new terminal will pick these up automatically.
Method 2: Edit Claude Code's settings.json
⚠️ Heads up: this method overwrites Claude Code's global config — your existing Anthropic key will stop working. If you're actively using the official Claude, prefer Method 1 or Method 3.
Config file location:
- Linux / macOS:
~/.claude/settings.json - Windows:
%USERPROFILE%\.claude\settings.json
Open it and merge in the env block below (if the file is empty, paste the whole thing as-is):
{
"env": {
"ANTHROPIC_BASE_URL": "https://chat.intern-ai.org.cn",
"ANTHROPIC_AUTH_TOKEN": "your-api-token",
"ANTHROPIC_MODEL": "intern-s2-preview",
"ANTHROPIC_SMALL_FAST_MODEL": "intern-s2-preview"
}
}
Restart Claude Code to apply.
Want to go back to the official Claude? Delete the keys above, or revert settings.json to whatever it used to be. Tip: cp settings.json settings.json.bak before you edit — that's the easy way back.
If you only want this in one project, drop the same config into
.claude/settings.jsoninside the project root. Other projects stay unaffected.
Method 3: Shell alias (coexist with official Claude)
If you want to keep using the official Claude and switch to Intern on demand, this is the cleanest setup: a new command claude-intern, while the original claude stays untouched.
Linux / macOS
Step 1 — open your shell config (same as Method 1 Step 2; zsh users edit ~/.zshrc, bash users edit ~/.bashrc):
nano ~/.zshrc
Step 2 — append the alias:
alias claude-intern='ANTHROPIC_BASE_URL="https://chat.intern-ai.org.cn" \
ANTHROPIC_AUTH_TOKEN="your-api-token" \
ANTHROPIC_MODEL="intern-s2-preview" \
ANTHROPIC_SMALL_FAST_MODEL="intern-s2-preview" \
claude'
Step 3 — reload:
source ~/.zshrc
Now you have two commands:
claude # Uses your existing config (e.g. official Claude)
claude-intern # Routes to Intern intern-s2-preview
Arguments work transparently — claude-intern --help behaves the same as claude --help.
Windows PowerShell
PowerShell aliases can't carry environment variables, so use a function instead — same effect.
Open the profile:
notepad $PROFILE
If it doesn't exist:
New-Item -ItemType File -Path $PROFILE -Force
notepad $PROFILE
Append:
function claude-intern {
$env:ANTHROPIC_BASE_URL = "https://chat.intern-ai.org.cn"
$env:ANTHROPIC_AUTH_TOKEN = "your-api-token"
$env:ANTHROPIC_MODEL = "intern-s2-preview"
$env:ANTHROPIC_SMALL_FAST_MODEL = "intern-s2-preview"
claude @args
}
Save, run . $PROFILE to reload, and claude-intern is ready.
Verify
Inside Claude Code, ask anything:
> What model are you? Introduce yourself in one sentence.
Or hit the API directly with curl:
curl -X POST https://chat.intern-ai.org.cn/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: your-api-token" \
-d '{
"model": "intern-s2-preview",
"max_tokens": 128,
"messages": [{"role": "user", "content": "ping"}]
}'
A response containing "type": "message" means you're connected.
What Do the Two Model Variables Do?
Easy to be confused about, so here's the breakdown:
| Variable | Role | What it affects |
|---|---|---|
ANTHROPIC_MODEL | Primary model (everyday chat) | Every normal conversation, coding, reasoning, and tool call you have with Claude Code goes through this model |
ANTHROPIC_SMALL_FAST_MODEL | Small fast model (background tasks) | Conversation title generation, /compact summarization, status-line updates, lightweight classification — anything that needs a quick reply |
Claude Code automatically picks the right one for each task — you don't switch manually.
Why we set both to intern-s2-preview? Currently that's the only model we expose. If you set only ANTHROPIC_MODEL, background tasks fall back to the default claude-haiku-*, which doesn't exist on our endpoint — you'll see errors.
A small gotcha about /model: when you use a custom BASE_URL, Claude Code's /model command does not query our model list. It only shows/toggles whatever you set via env vars. To check what's actually live, /status is more reliable — it prints Base URL, Model, and Small Fast Model directly.
FAQ
Q1: claude errors with 401 Unauthorized / Invalid API Key.
Double-check ANTHROPIC_AUTH_TOKEN. Common pitfalls: leading/trailing spaces or quotes, an accidental Bearer prefix, expired token.
Q2: /status still shows api.anthropic.com.
The variables didn't reach the Claude Code process. Open a fresh terminal, or confirm your ~/.bashrc / ~/.zshrc / $PROFILE was saved and sourced.
Q3: Replies are often empty, or tool calls feel unreliable.
For tool-heavy clients like Claude Code, intern-s2-preview must keep thinking_mode enabled (it is by default). Don't disable it via extraBody in your settings.
Q4: What's the max context?
intern-s2-preview supports 256K context. Per-request max_tokens should stay ≤ 8K. For big projects, /compact inside Claude Code helps a lot.
Q5: I'm being rate-limited (-20053 / HTTP 429).
Default is 30 req/min. Claude Code's multi-agent, tool-heavy flows can blow through that quickly. Request a higher quota at the Rate Limiting Policy page.
Q6: How do I go back to the official Claude?
- Method 1: close the terminal, or run
unset ANTHROPIC_BASE_URL ANTHROPIC_AUTH_TOKEN ANTHROPIC_MODEL ANTHROPIC_SMALL_FAST_MODEL. - Method 2: edit
~/.claude/settings.jsonand remove the keys. - Method 3: just use
claude— the alias never pollutes the default command.
Q7: Does it work with the VS Code / JetBrains plugin?
Yes. The plugins read the same ~/.claude/settings.json, so Method 2 just works. Environment-variable setups only apply to IDE processes launched from that same shell.