RunarsRunars Docs
Integrations

Claude Code

Use Runars as the backend for Anthropic's Claude Code CLI

Claude Code is Anthropic's agentic coding CLI. It speaks the Anthropic Messages API, so it works with Runars out of the box—just point it at Runars and set your API key.

Prerequisites

  • A Runars API key (Dashboard → API Keys), starting with sk-runars-
  • Claude Code installed (npm install -g @anthropic-ai/claude-code or the desktop installer)
  • Credit balance on your organization

Setup

Claude Code reads its base URL and key from environment variables. Set both:

export ANTHROPIC_BASE_URL="https://api.runars.ca"
export ANTHROPIC_API_KEY="sk-runars-..."

Add these to your shell profile (~/.zshrc, ~/.bashrc) so they persist across sessions, then restart Claude Code.

Verify it works

claude
> What is 2+2?

A successful response means Runars is serving the request. The first request may take a second longer while the serverless model warms up.

Using a specific model

Claude Code sends a model id in each request. Runars routes by model id against its catalog. The default model id Claude Code uses (claude-*) may not exist in the Runars catalog—in that case set the model explicitly:

claude --model glm-5.2

Or pick whichever model id your Runars organization exposes via GET /v1/models.

Alternative: set all models upfront

Instead of passing --model each time, you can pin every model slot Claude Code uses at launch. This is handy when initializing the integration on a fresh machine—one export block and every role (main model, background tasks, subagents) is set:

export ANTHROPIC_BASE_URL="https://api.runars.ca"
export ANTHROPIC_API_KEY="sk-runars-..."
export ANTHROPIC_AUTH_TOKEN="sk-runars-..."
export ANTHROPIC_DEFAULT_OPUS_MODEL="kimi-k3"
export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-5.3-flash"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="glm-5.3-flash"
claude

Claude Code maps its internal opus/sonnet/haiku tiers to the Runars model ids you set, so requests like plan mode or background summarization—all of which request different tiers—resolve to models that actually exist in the Runars catalog. As with the basic setup, add these to your shell profile to persist across sessions.

Troubleshooting

"401 Unauthorized": The key is missing, wrong, or revoked. API-key revocation is cache-invalidated within a few seconds on Runars; if you just revoked a key, wait ~5s and the old key stops working.

"404 model_not_found": The requested model id isn't in the catalog. Run curl https://api.runars.ca/v1/models -H "Authorization: Bearer sk-runars-..." to see the valid ids, then pass one with --model.

Claude Code ignores my env vars: Confirm both variables are exported in the shell session where you launch claude. Some IDEs don't inherit your shell profile—set them in the IDE's terminal configuration instead.

What's next

On this page