For the complete documentation index, see llms.txt. This page is also available as Markdown.

Claude Code Integration with The Grid | Anthropic API Setup

Use Claude Code with The Grid through the Anthropic Messages API. Set environment variables, map model aliases, and run Claude Code normally.

Claude Code can talk to The Grid directly through The Grid's beta Anthropic Messages endpoint. No local proxy, no LiteLLM bridge, no format translation. Point Claude Code at the base URL, supply your key through a small helper script, map Claude Code's family aliases (Sonnet, Haiku, Opus) to Grid instruments, and run claude normally.

Prerequisites

  • Claude Code installed (npm install -g @anthropic-ai/claude-code or the native installer).

  • A Grid account at app.thegrid.ai.

  • Credits in your account. The Grid is prepaid.

  • A Grid consumption API key from Settings → API Keys → Create Consumption Key.

The Anthropic Messages endpoint on The Grid is in beta. The main flow works; the most visible gap is that count_tokens is not yet exposed, so Claude Code's pre-flight size checks, /cost, /context, and auto-compaction can be less accurate on long sessions.

The Code instruments (code-standard, code-prime, code-max) are in preview. They work today and are the right default for Claude Code, but their qualifying specs can change. See the current instruments list for current status.

Setup

1. Create ~/.claude/settings.json

Pick instrument IDs from the current instruments list. A reasonable default mapping is Sonnet → Code Prime, Haiku → Code Standard, Opus → Code Max.

{
  "apiKeyHelper": "~/.claude/thegrid_key.sh",
  "env": {
    "ANTHROPIC_BASE_URL": "https://messages-beta.api.thegrid.ai",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "code-prime",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "code-standard",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "code-max",
    "CLAUDE_CODE_SUBAGENT_MODEL": "code-standard"
  }
}

settings.json persists across terminal sessions and is shared with the VS Code extension. Set ANTHROPIC_BASE_URL to the host root, not the full /v1/messages path. apiKeyHelper points at the script you create in the next step, so your key never sits inline in settings.json.

2. Create the API key helper script

Create ~/.claude/thegrid_key.sh and have it print your Grid consumption API key:

3. Make the helper script executable

Claude Code runs this script and uses its stdout as the API key. If you prefer plain shell exports instead of apiKeyHelper, you can set ANTHROPIC_API_KEY along with the same variables in ~/.zshrc or ~/.bashrc.

4. (Optional) Pin specific Anthropic versions with modelOverrides

If your team needs deterministic mapping at the version level instead of family aliases, use modelOverrides:

Keys must be full Anthropic model IDs. Short aliases like sonnet are silently ignored.

5. Start Claude Code

Verification

Run a simple prompt: "Summarize this repository in two sentences." A normal response confirms Claude Code is connected. /status inspects current settings.

Troubleshooting

/model picker doesn't show Grid instruments. Expected. Claude Code's picker uses Anthropic-facing names. Tier mapping happens through the env vars.

VS Code extension keeps prompting to log into Anthropic. Set claudeCode.disableLoginPrompt to true in your VS Code settings. This is Anthropic's documented approach for third-party providers.

Last updated

Was this helpful?