BETA

Docs
Instructions

How to connect Claude Code to Apily

Claude Code talks to model providers over the Anthropic Messages protocol by default. Apily serves that protocol natively at https://apily.pro, so point Claude Code at it with ANTHROPIC_BASE_URL/ANTHROPIC_API_KEY — no openai_compatible shim required. (That OpenAI-compatible path still works too, if you'd rather use it — see the alternative below.)

Tool
Claude Code Anthropic Messages
Base URL
https://apily.pro
Key
apily_your-api-key
Env vars
ANTHROPIC_BASE_URL / ANTHROPIC_API_KEY

Requirements

  • macOS, Linux or Windows with a terminal.
  • Node.js 18+ (or the standalone installer from Anthropic).
  • An Apily API key — created in your account at apily.pro.
  • Outbound HTTPS access to apily.pro.

Install Claude Code

terminal
npm install -g @anthropic-ai/claude-code
claude --version

Get an API key

  1. Sign in at apily.pro (Telegram, Google or email) and open your account.
  2. Open API in the sidebar and press Generate. The examples below use the placeholder apily_your-api-key — paste your real key in its place.
  3. Copy the key whole, including the apily_ prefix. Never publish a real key in repositories or screenshots.

Configuration

Set ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY before launching Claude Code — in your shell profile, or inline for one session:

terminal
export ANTHROPIC_BASE_URL="https://apily.pro"
export ANTHROPIC_API_KEY="apily_your-api-key"
claude

Or persist the same two values under env in ~/.claude/settings.json:

~/.claude/settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://apily.pro",
    "ANTHROPIC_API_KEY": "apily_your-api-key",
    "ANTHROPIC_MODEL": "claude-sonnet-5"
  }
}
  1. Set the two environment variables (shell export or settings.json), replacing the key with your own.
  2. If you were previously signed in with an Anthropic subscription, run claude and then /logout once — a saved login can override the configured base URL.
  3. Restart the terminal session and launch claude in a project folder. Ask it anything — requests now go through Apily.

Your first request

Before starting the agent, confirm the key and model both work with a single curl call:

terminal
curl https://apily.pro/v1/messages \
  -H "x-api-key: apily_your-api-key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-opus-5","max_tokens":64,"messages":[{"role":"user","content":"ping"}]}'

A JSON response with a "content" field means the key is valid, the model is allowed and the upstream is reachable. Then send any message inside claude.

Switching models

Change the model with /model inside a session, or the --model flag. The base URL and key stay the same. Check the current catalog on the Models page in your account, or with GET /v1/models — for example:

  • claude-opus-5 · claude-sonnet-5 · gpt-5.6-sol
  • deepseek-v4-flash-0731 · gemini-3.5-flash · grok-4.7

Common errors and how to fix them

SymptomCauseFix
401 Invalid API keyKey copied with stray spaces, truncated, or revoked.Copy the key whole from the API page in your Apily account, the apily_ prefix included.
401 Missing API keyNo auth header was sent.Apily accepts Authorization: Bearer … and x-api-key: ….
403 Email not verifiedYour Apily account's email address isn't verified yet.Verify your email from the banner in the Apily app, then retry.
402 Insufficient balanceYour token balance can't cover the request's estimated cost.Top up your balance on the Billing page in your Apily account.
404 Not foundANTHROPIC_BASE_URL is missing, or points somewhere other than https://apily.pro.Base URL: https://apily.pro/v1 — every request must land on a path Apily serves (/chat/completions, /responses, /models, …).
503 Model temporarily unavailableThe model exists, but no upstream provider is reachable right now.Retry in a moment — it usually recovers within a minute. Switch models if it keeps happening.

FAQ