DocsCoding agents
Claude Code
Point Claude Code at Osarai's Anthropic-compatible endpoint and run it on your own GPU.
Claude Code is Anthropic's coding agent for the terminal. It speaks the Anthropic Messages API, which Osarai serves at https://osarai.xyz/v1/messages, so it connects like any LLM gateway: with a base URL and a key.

Install
Terminal
npm install -g @anthropic-ai/claude-codeTerminal
curl -fsSL https://claude.ai/install.sh | bashConfigure
Terminal
export ANTHROPIC_BASE_URL="https://osarai.xyz"
export ANTHROPIC_AUTH_TOKEN="$OSARAI_API_KEY"
export ANTHROPIC_MODEL="qwen3.8-27b"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="qwen3.8-27b"
export CLAUDE_CODE_SUBAGENT_MODEL="qwen3.8-27b"
export CLAUDE_CODE_MAX_CONTEXT_TOKENS=131072PowerShell
$env:ANTHROPIC_BASE_URL = "https://osarai.xyz"
$env:ANTHROPIC_AUTH_TOKEN = $env:OSARAI_API_KEY
$env:ANTHROPIC_MODEL = "qwen3.8-27b"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL = "qwen3.8-27b"
$env:CLAUDE_CODE_SUBAGENT_MODEL = "qwen3.8-27b"
$env:CLAUDE_CODE_MAX_CONTEXT_TOKENS = "131072"~/.claude/settings.json
{
"env": {
"ANTHROPIC_BASE_URL": "https://osarai.xyz",
"ANTHROPIC_AUTH_TOKEN": "qck_your_key_here",
"ANTHROPIC_MODEL": "qwen3.8-27b",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "qwen3.8-27b",
"CLAUDE_CODE_SUBAGENT_MODEL": "qwen3.8-27b",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "131072"
}
}| Variable | Why |
|---|---|
ANTHROPIC_BASE_URL | Sends requests to Osarai. Use the site address, without /v1 |
ANTHROPIC_AUTH_TOKEN | Your key, sent as Authorization: Bearer (ANTHROPIC_API_KEY works too, sent as x-api-key) |
ANTHROPIC_MODEL | The model for the session: your instance's model id |
ANTHROPIC_DEFAULT_HAIKU_MODEL | Background tasks such as session titles also go to your model |
CLAUDE_CODE_SUBAGENT_MODEL | Subagents use your model too |
CLAUDE_CODE_MAX_CONTEXT_TOKENS | The real context window, so Claude Code compacts in time (it assumes 200K for models it does not know) |
Keep the key out of a project's .claude/settings.json, which is usually committed.
Check the connection
Terminal
curl "$ANTHROPIC_BASE_URL/v1/messages" \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model": "qwen3.8-27b", "max_tokens": 64, "messages": [{"role": "user", "content": "Hi"}]}'A JSON answer starting with {"id":"msg_ means the URL and key work. Then start Claude Code in your project and run /status: the Anthropic base URL line shows Osarai.
Terminal
cd your-project
claudeWhat works
| Feature | Status |
|---|---|
| Chat, streaming | Works |
| Tool use (read, edit, bash, search) | Works with models that call tools (qwen3.8-27b) |
| Thinking | Works; shown as thinking blocks |
| Images in prompts | Works on models with image input |
Token counting (/context) | Works through /v1/messages/count_tokens |
/model picker | Set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 to list your instance's models |
| Web search, fast mode, Claude-only betas | Not available |
Troubleshooting
| Symptom | Fix |
|---|---|
| Claude Code asks you to log in | Set ANTHROPIC_AUTH_TOKEN in the shell or ~/.claude/settings.json before starting it |
401 | Wrong variable: with ANTHROPIC_API_KEY approve the key once in /config, or use ANTHROPIC_AUTH_TOKEN |
Claude Code doesn't recognize the model | Expected for open models; set CLAUDE_CODE_MAX_CONTEXT_TOKENS to silence the context warning |
400 naming an unknown field | Set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 |
529 overloaded or 503 | The instance is starting or stopped; check the instance page |