Blog

Use Claude Code with an API key

Claude Code talks to Anthropic directly by default. Set two environment variables and it uses the address and key you give it instead. Everything else works the same.

The RoamAI teamPublished October 16, 2026

What you need

  • Claude Code installed. claude --version prints a version number.
  • An API key, created on the API keys page of the console. The full key is shown once, when you create it.
  • The base URL: https://relay.roamai.cloud:18443

Option 1: environment variables

Set two variables in a terminal, then start claude. This only applies to that terminal. On macOS and Linux:

export ANTHROPIC_BASE_URL=https://relay.roamai.cloud:18443
export ANTHROPIC_AUTH_TOKEN=rak1_YOUR_KEY
claude

To keep it, add the two export lines to ~/.zshrc or ~/.bashrc.

In Windows PowerShell:

$env:ANTHROPIC_BASE_URL = 'https://relay.roamai.cloud:18443'
$env:ANTHROPIC_AUTH_TOKEN = 'rak1_YOUR_KEY'
claude

To keep it for windows you open later, save the variables with setx. Open a new window afterwards; the current one does not pick them up.

setx ANTHROPIC_BASE_URL 'https://relay.roamai.cloud:18443'
setx ANTHROPIC_AUTH_TOKEN 'rak1_YOUR_KEY'

In the Windows Command Prompt (CMD):

set "ANTHROPIC_BASE_URL=https://relay.roamai.cloud:18443"
set "ANTHROPIC_AUTH_TOKEN=rak1_YOUR_KEY"
claude

Option 2: settings.json

Every Claude Code session on the computer picks this up, with no variables to set. The file is ~/.claude/settings.json, or %USERPROFILE%\.claude\settings.json on Windows:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://relay.roamai.cloud:18443",
    "ANTHROPIC_AUTH_TOKEN": "rak1_YOUR_KEY"
  }
}
If the file already has content, merge in the env section instead of replacing the file.

Why ANTHROPIC_AUTH_TOKEN

ANTHROPIC_API_KEY also connects, but interactive claude asks whether to use the key the first time, and if the computer is already signed in to claude.ai it warns about two conflicting sign-ins. ANTHROPIC_AUTH_TOKEN avoids both.

Check that it works

  1. Ask claude anything.
  2. In the console, the API key step under Connect RoamAI turns green, and the request and its cost show up under Usage.

Common errors

  • invalid api key (create one in the RoamAI console): the key is mistyped or has been revoked. Check it in the console, or create a new one.
  • this API key has been suspended…: a request made with the key was flagged by Claude's safeguards. Contact us to have it reviewed.
  • Your RoamAI credit balance has run out…: the prepaid balance is used up. Top up in the console and requests work again.
  • no server online for this workspace: your workspace is not ready yet. The console home page shows the progress; contact us if it takes long.

One key per person for Claude Code

RoamAI is a Claude API for teams: issue a key in the console and put it into Claude Code, Claude Desktop or an SDK. No monthly fee; usage is charged per token.

Get started

← All posts