Skip to content

Claude Code

Connect Claude Code to HeyEly using the Anthropic Messages API and your HeyEly key.

Claude Code connects over the Anthropic Messages API. Point its base URL to https://heyely.si (omit /v1) and supply your HeyEly API key as the auth token.

Set up

  1. Generate a key in Developers and export it as HEYELY_API_KEY.
  2. Add the HeyEly base URL, auth token, and gateway model discovery flag to your shell profile.
export ANTHROPIC_BASE_URL="https://heyely.si"
export ANTHROPIC_AUTH_TOKEN="$HEYELY_API_KEY"
export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY="1"
  1. Launch claude. If you previously signed in to an Anthropic account, run /logout once so cached credentials do not override your HeyEly token.

Prefer not to modify your shell profile? You can place these values inside the env object of your user-level config at ~/.claude/settings.json (or %USERPROFILE%\.claude\settings.json on Windows). Because JSON settings do not expand shell variables, paste the literal key string there.

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://heyely.si",
    "ANTHROPIC_AUTH_TOKEN": "sk-df-...",
    "CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY": "1"
  }
}

Keep the key out of your projects. Store credentials in your personal user settings file only, never inside a repository's .claude/settings.json. Note that Claude Code ignores these variables when placed in a project .env file.

Verify

  1. Confirm your key and endpoint with a quick smoke test. A JSON response beginning with {"id":"msg_ confirms everything is wired up.
curl https://heyely.si/v1/messages \
  -H "Authorization: Bearer $HEYELY_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "max_tokens": 1,
    "messages": [{ "role": "user", "content": "." }]
  }'
  1. Launch claude, send a brief test prompt, and run /status. You should see https://heyely.si listed as the Anthropic base URL alongside your auth token. If /status still displays a claude.ai login method, Claude Code has not loaded the token yet.
  2. Want to inspect gateway model discovery directly? Start with claude --debug and check the discovery entries in the debug log.
  3. Visit Credit and usage. Your test call appears at the top of Spend, and clicking the row shows Claude Code under From.

Pick a model

By default, Claude Code maps shorthand classes like Opus, Sonnet, and Haiku to Anthropic's unprefixed model names. Override each class with a full HeyEly catalog ID so every request hits the right model.

VariableSets
ANTHROPIC_MODELDefault model for the current session
ANTHROPIC_DEFAULT_SONNET_MODELCatalog ID mapped to Sonnet, such as anthropic/claude-sonnet-5.5
ANTHROPIC_DEFAULT_HAIKU_MODELCatalog ID mapped to Haiku, such as anthropic/claude-haiku-4.5
ANTHROPIC_DEFAULT_OPUS_MODELCatalog ID mapped to Opus
CLAUDE_CODE_SUBAGENT_MODELDefault catalog ID used for subagents
  • An explicit model inside a subagent definition or call takes precedence over CLAUDE_CODE_SUBAGENT_MODEL. On Claude Code 2.1.257 or newer, add CLAUDE_CODE_SUBAGENT_MODEL_FORCE=1 to lock every subagent to one ID.
  • With gateway discovery turned on, /model displays catalog IDs matching claude or anthropic. You can still target any other catalog model by passing its full ID to /model <id> or claude --model <id>.
  • For unfamiliar model IDs, Claude Code defaults to a 200K context window. Add [1m] to the end of the ID, such as anthropic/claude-sonnet-5.5[1m], to unlock 1M context. HeyEly removes [1m] before catalog lookup, so the upstream provider receives the clean catalog ID.
  • Claude Code is tuned around Claude models. Non-Claude catalog models still reply, though tool calling and reasoning output can vary.
  • Managing a team deployment? On v2.1.285 or later, set allowedProviders to ["customEndpoint"] inside Claude Code's managed settings and include ANTHROPIC_BASE_URL set to https://heyely.si in the same file's env block. Sessions pointed to any other host will be refused.

Use it in other Claude clients

Both the Claude Agent SDK and the Claude Code GitHub Action honor these exact environment variables. In the VS Code extension, configure them through claudeCode.environmentVariables in VS Code settings rather than settings.json. The standalone Claude desktop app does not read ANTHROPIC_BASE_URL.

Connect the MCP server

Add HeyEly's MCP server so Claude Code can check your credit balance, run models inside a spend cap you pick, and create, rotate, or revoke scoped API keys after a single sign-in.

Troubleshooting

Anthropic Messages errors return a type and message rather than an error code, so the table below matches on HTTP status, error type, and opening text.

You seeCauseFix
Claude Code prompts for loginCached claude.ai credentials took priority, or env vars are missingRun /logout and verify the exports in the shell launching claude
Warning about two credential sourcesBoth a saved login and gateway token are activeRun /logout, or remove one credential source
401 authentication_errorANTHROPIC_AUTH_TOKEN is blank or mistypedRe-export ANTHROPIC_AUTH_TOKEN from your saved key or mint a fresh one, keeping it out of logs and screenshots
ANTHROPIC_API_KEY is ignoredClaude Code requires a one-time confirmation for ANTHROPIC_API_KEY and never prompts againSwitch to ANTHROPIC_AUTH_TOKEN
404 not_found_error, "The model ... does not exist"A model class variable uses a short alias instead of a catalog IDProvide the full catalog ID, such as anthropic/claude-sonnet-5.5
402 billing_error, "This account has no credit left"Your balance is emptyAdd credit
402 billing_error, "This account has only free credit"Free credit cannot be spent on Claude modelsAdd credit, or switch to an eligible open-weight text model
402 billing_error, "This API key has reached its credit limit"Spend hit this key's configured capIncrease the key limit in Developers or switch keys
Non-Claude model missing from pickerGateway discovery filters to claude and anthropic IDsPass the full ID manually via /model
Empty model pickerDiscovery is disabled, or /v1/models timed out past 3 seconds or redirectedExport CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1
400 citing anthropic-beta or unknown fieldsThe target model rejects an experimental beta headerExport CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1
Env vars appear ignoredVariables were placed in a project .env fileMove them to your shell profile or ~/.claude/settings.json