Connect Claude Code
Use Node 20 or newer, an installed Claude Code with first-time setup complete, a workspace API key, and available RunInfra credits.This integration uses RunInfra hosted models. It does not make those models identical to Anthropic models.
Configure manually
Back up your existing settings before editing. Use a model whose page lists tool calling. These examples usedeepseek-v4-flash for the main session, all four model aliases, and subagents.
Environment
Load your workspace key intoRUNINFRA_GATEWAY_KEY through your secret-management workflow, then start Claude Code from that terminal.
- macOS and Linux
- PowerShell
ANTHROPIC_BASE_URL must be the bare host. Claude Code and the Anthropic SDK append /v1.
ANTHROPIC_AUTH_TOKEN sends Bearer authentication and does not trigger the API-key approval prompt. You can set ANTHROPIC_API_KEY instead. It sends x-api-key, which works on the Messages routes, but Claude Code prompts once to approve the custom key.
Settings file
For a persistent configuration, merge thisenv block into ~/.claude/settings.json. On Windows, the file is %USERPROFILE%\.claude\settings.json. If you set CLAUDE_CONFIG_DIR, use that directory instead. Replace rp_... with your workspace key.
.claude/settings.json. A personal project configuration can use .claude/settings.local.json, but its credential values apply only after you trust the project. Complete first-time setup with a credential in the shell or user settings.
A settings-file
env value replaces the same variable in your shell. Managed settings can prevent a local override. Use /status to inspect the base URL, credential source, and loaded settings. Terminal exports do not reach an app you launch separately from the desktop.Choose a model
Connect populates the/model picker from its modelPicker.options rows. Run npx @runinfra/connect claude on again to refresh the model list. The manual examples above add one picker entry with ANTHROPIC_CUSTOM_MODEL_OPTION.
You can also type an exact id, such as /model deepseek-v4-flash. With a custom ANTHROPIC_BASE_URL, Claude Code passes the typed id through unvalidated. A typo can fail on the first request, so choose an id returned by GET /v1/models.
Do not combine Connect’s modelPicker.replaceBuiltInOptions configuration with gateway discovery or the single custom-option setting. That picker mode hides those other entries.
ANTHROPIC_DEFAULT_MODEL is a fallback when no other model selection is set. The Fable, Opus, Sonnet, and Haiku variables pin the aliases; Haiku also covers background calls.
Set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the selected model’s published context_window, not to a value copied from a different model. The 1048576 example is for deepseek-v4-flash. For an unknown id without [1m], Claude Code uses this value for context accounting. A [1m] suffix tells Claude Code to assume a 1M window and is stripped before sending the id; do not add it to a smaller-context model.
Optional controls
You do not need
DISABLE_PROMPT_CACHING. Claude Code may send cache_control, and the Messages API accepts and ignores it. Prefix caching remains automatic on models with cached-input pricing.
What works
- Multi-tool sessions using client tools that Claude Code executes.
- Subagents using the model selected by
CLAUDE_CODE_SUBAGENT_MODEL. - Streaming through the official Anthropic SDK helpers.
- Thinking display when the selected model returns reasoning.
What to expect
Claude Code can print a diagnostic line that it does not recognize the RunInfra model id. The line is harmless when requests continue successfully. Claude Code’s own cost figures (the/cost command and the costUSD field in --output-format json) are estimates based on its built-in price list, not RunInfra prices. Your actual RunInfra usage and charges are on the usage page and in each response’s usage.cost field.
Use Bearer authentication to discover model ids.
Verify
Load the same workspace key intoRUNINFRA_GATEWAY_KEY in your terminal. This request uses credits and reads usage.cache_read_input_tokens. The macOS and Linux example uses jq.
- macOS and Linux
- PowerShell
0 is valid; a successful request does not guarantee a cache hit. This tests the API, not whether Claude Code has reloaded its settings. After restarting Claude Code, use /status to confirm the base URL and credential source.
Revert
If you used Connect:on, which may already contain RunInfra settings. If a managed file changed afterward, Connect refuses to overwrite it. Back up and review those edits before proceeding.
For manual setup, restore your previous settings or remove only the RunInfra values you added to the env block and shell profile: the base URL, credential, model and alias variables, subagent model, custom model option, and context-window override. Restore any model, modelPicker, or apiKeyHelper settings you changed. Use /model default to clear a saved model override, then restart Claude Code from an environment without the RunInfra overrides.
Connect’s logout removes only its saved credentials. It does not restore agent settings or revoke the workspace key. Revoke an unwanted key in the dashboard.
Check usage and credits
See settled usage in the dashboard’s usage page. Read the current workspace balance withGET /v1/credits.
Related
Anthropic Messages
Read the request, tool, thinking, stream, and error contract.
Authentication
Understand Bearer and
x-api-key scope.Models
List the model ids available to your key.