ANTHROPIC_BASE_URL to the AIOHub gateway root; Claude Code appends /v1/messages itself.
Prerequisites
- Claude Code installed with Node.js 18+
- An AIOHub
sk-API key - A group assigned to the API key that can access Claude-compatible models
- A positive account balance
Temporary setup
Set the variables in the shell where you start Claude Code:Do not add
/v1 to ANTHROPIC_BASE_URL. Set ANTHROPIC_AUTH_TOKEN to the full sk- API key value, without a manual Bearer prefix; Claude Code sends it with Authorization Bearer authentication.Persistent setup
Add the variables to your shell profile:- macOS / Linux (zsh)
- macOS / Linux (bash)
- Windows PowerShell
~/.claude/settings.json. Project-local private settings can live at .claude/settings.local.json; do not commit real API keys.
Optional: 1-hour prompt caching
Claude API prompt caching uses a 5-minute TTL by default. If you often resume long Claude Code sessions, work with large repository context, or reuse the same long prompt prefix after more than 5 minutes, addENABLE_PROMPT_CACHING_1H to the env block in ~/.claude/settings.json to request a 1-hour TTL:
Use the 1-hour TTL for sessions that repeatedly reuse long context. In Anthropic pricing, 1-hour cache writes are charged at 2x the base input token price, while cache reads are cheaper; if you typically resume within 5 minutes, the default cache is enough.
Optional: disable attribution header
Claude Code prepends a dynamic attribution header (containing the client version and prompt fingerprint) to the system prompt on every request. When routing through a gateway, this changing prefix invalidates the KV cache and slows down inference. SetCLAUDE_CODE_ATTRIBUTION_HEADER to "0" in ~/.claude/settings.json to omit this dynamic block and improve prompt cache hit rates:
This only affects caching on the gateway side. Anthropic’s own prompt caching is unaffected. If you connect directly to the Anthropic API without a gateway, you do not need this setting.
Command alias
You can create a shell alias when you want a separate command for AIOHub-backed Claude Code:mycc to start Claude Code with the AIOHub environment.
Verify
Start Claude Code and send a short prompt. You can first confirm that the command is available:- macOS / Linux
- Windows PowerShell
Session commands
Inside a Claude Code session, these commands help locate client state:| Command | Use |
|---|---|
/status | View current session status |
/context | Inspect context token usage |
/clear | Clear the current conversation and start fresh |
/model | View or change the selected model |
Protocol notes
Claude Code sends Anthropic Messages requests, normallyPOST /v1/messages. The Base URL must therefore be https://api.aiohub.org, not https://api.aiohub.org/v1. When testing manually with curl, include the full path and the Anthropic version header:
Troubleshooting
Claude Code keeps asking you to log in
Claude Code keeps asking you to log in
Check that the shell you launched Claude Code from has
ANTHROPIC_AUTH_TOKEN. If ANTHROPIC_API_KEY is also set, Claude Code may use API-key mode; AIOHub setup should use ANTHROPIC_AUTH_TOKEN.If you store configuration in settings.json, you can add apiKeyHelper:404 or API Connect Error
404 or API Connect Error
Confirm
ANTHROPIC_BASE_URL does not include /v1. If it is https://api.aiohub.org/v1, Claude Code can end up calling /v1/v1/messages.The request returns 400
The request returns 400
Clear the current conversation with
/clear, then retry with a fresh prompt. Also confirm that the selected model exists in the group assigned to your API key. If the error is related to Claude Code experimental features, start Claude Code with CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 and retry.Context is too large or the session becomes slow
Context is too large or the session becomes slow
Use
/context to inspect context usage. If needed, clear the conversation, start a new session, or reduce long history before automatic compaction.Insufficient balance
Insufficient balance
Open wallet management to view balance and add funds.