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
- Generate a key in Developers and export it as
HEYELY_API_KEY. - 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"
- Launch
claude. If you previously signed in to an Anthropic account, run/logoutonce 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%\ 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
- 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": "." }]
}'
- Launch
claude, send a brief test prompt, and run/status. You should seehttps://heyely.silisted as the Anthropic base URL alongside your auth token. If/statusstill displays a claude.ai login method, Claude Code has not loaded the token yet. - Want to inspect gateway model discovery directly? Start with
claude --debugand check the discovery entries in the debug log. - 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.
| Variable | Sets |
|---|---|
ANTHROPIC_MODEL | Default model for the current session |
ANTHROPIC_ | Catalog ID mapped to Sonnet, such as anthropic/ |
ANTHROPIC_ | Catalog ID mapped to Haiku, such as anthropic/ |
ANTHROPIC_ | Catalog ID mapped to Opus |
CLAUDE_ | Default catalog ID used for subagents |
- An explicit model inside a subagent definition or call takes precedence over
CLAUDE_. On Claude Code 2.1.257 or newer, addCODE_ SUBAGENT_ MODEL CLAUDE_to lock every subagent to one ID.CODE_ SUBAGENT_ MODEL_ FORCE=1 - With gateway discovery turned on,
/modeldisplays catalog IDs matchingclaudeoranthropic. You can still target any other catalog model by passing its full ID to/model <id>orclaude --model <id>. - For unfamiliar model IDs, Claude Code defaults to a 200K context window. Add
[1m]to the end of the ID, such asanthropic/, to unlock 1M context. HeyEly removesclaude-sonnet-5. 5[1m] [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
allowedProvidersto["customEndpoint"]inside Claude Code's managed settings and includeANTHROPIC_BASE_URLset tohttps://heyely.siin the same file'senvblock. 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. 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 see | Cause | Fix |
|---|---|---|
| Claude Code prompts for login | Cached claude.ai credentials took priority, or env vars are missing | Run /logout and verify the exports in the shell launching claude |
| Warning about two credential sources | Both a saved login and gateway token are active | Run /logout, or remove one credential source |
401 authentication_error | ANTHROPIC_AUTH_TOKEN is blank or mistyped | Re-export ANTHROPIC_AUTH_TOKEN from your saved key or mint a fresh one, keeping it out of logs and screenshots |
ANTHROPIC_API_KEY is ignored | Claude Code requires a one-time confirmation for ANTHROPIC_API_KEY and never prompts again | Switch 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 ID | Provide the full catalog ID, such as anthropic/ |
402 billing_error, "This account has no credit left" | Your balance is empty | Add credit |
402 billing_error, "This account has only free credit" | Free credit cannot be spent on Claude models | Add 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 cap | Increase the key limit in Developers or switch keys |
| Non-Claude model missing from picker | Gateway discovery filters to claude and anthropic IDs | Pass the full ID manually via /model |
| Empty model picker | Discovery is disabled, or /v1/models timed out past 3 seconds or redirected | Export CLAUDE_ |
400 citing anthropic-beta or unknown fields | The target model rejects an experimental beta header | Export CLAUDE_ |
| Env vars appear ignored | Variables were placed in a project .env file | Move them to your shell profile or ~/.claude/settings.json |