OneKeyLLM

Setup Claude Code

Configure Claude Code with OneKeyLLM as an Anthropic Messages API base URL.

Claude Code can talk to an API base URL that implements the Anthropic Messages surface. OneKeyLLM exposes the expected endpoints:

  • POST /v1/messages
  • POST /v1/messages/count_tokens
  • GET /v1/models

1. Export the base URL

export ANTHROPIC_BASE_URL="https://api.tokapi.ai"

2. Export the OneKeyLLM key

export ANTHROPIC_AUTH_TOKEN="sk-lazytech-..."

Claude Code sends this value as Authorization: Bearer ....

3. Enable model discovery

export CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1

Discovery queries /v1/models at startup. If the model you want does not appear in the picker, launch Claude Code with the model explicitly:

ANTHROPIC_MODEL="claude-sonnet-4-6" claude

4. Run Claude Code

claude

Direct HTTP test

curl https://api.tokapi.ai/v1/messages \
  -H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 128,
    "messages": [{ "role": "user", "content": "Reply with ok" }]
  }'

Source: Claude Code base URL configuration.