AnyRouter

Quickstart

Make your first AnyRouter request in under five minutes by pointing any OpenAI-compatible client at one base URL.

AnyRouter is an OpenAI- and Anthropic-compatible LLM gateway on Cloudflare. One API key reaches hundreds of models, with automatic failover, free models, bring-your-own-key at $0 markup, and a shared key Pool. This page gets you from zero to your first response in under five minutes.

Three things stay the same no matter how you call AnyRouter:

SettingValue
Base URLhttps://anyrouter.dev/api/v1
API keyyour sk-ar-v1-… inference key
Model idprovider/model, e.g. z-ai/glm-4.7-flash

Make your first request

Sign in to the dashboard and create a new key — no card required. AnyRouter inference keys are prefixed with sk-ar-v1- so you can tell them apart from upstream provider keys.

A new account starts at $0 balance with no included credits. Before your first paid-model call, either top up or subscribe to Go ($2/mo, includes $4/mo credits) — or donate a provider key to unlock Go for free. See Credits & Billing for all the ways to get started.

export ANYROUTER_API_KEY="sk-ar-v1-your-key"

The most direct call is a plain HTTP request to /api/v1/chat/completions — no SDK required, so it works from any language that can make an HTTP call.

curl https://anyrouter.dev/api/v1/chat/completions \
  -H "Authorization: Bearer $ANYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "z-ai/glm-4.7-flash",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

Keys are scoped per organization. Create a separate key for every environment (dev, staging, prod) so you can rotate them independently.

To stream tokens as they arrive, add "stream": true to the request body — the response becomes a stream of server-sent events.

Call it from your stack

The same request works from any OpenAI-compatible client. Pick whichever fits your project.

AnyRouter is a drop-in replacement for the OpenAI API. Point base_url at AnyRouter, pass your key, and use a provider/model id — no other code changes.

from openai import OpenAI

client = OpenAI(
    base_url="https://anyrouter.dev/api/v1",
    api_key="sk-ar-v1-your-key",
)

response = client.chat.completions.create(
    model="z-ai/glm-4.7-flash",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)

Or launch a coding agent

Install the native CLI (Linux, macOS, Windows — no Node required), sign in once, and spawn Claude Code / Codex / OpenCode / Grok / Pi through the gateway:

curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr auth login
anyr claude --install --ok
anyr usage

Full reference: AnyRouter CLI. For a Herdr fleet loop with Grok Bot, see Grok Bot, Herdr, and Anyr CLI.

Choose a model

Model ids follow the provider/model convention. Browse the full list on the models page or fetch it via the API:

curl https://anyrouter.dev/api/v1/models \
  -H "Authorization: Bearer sk-ar-v1-your-key"

A few popular choices:

Model idProviderNotes
z-ai/glm-4.7-flashZ-AIFast, low-cost — good first request
anthropic/claude-sonnet-4-6Anthropic1M context, strong coding
anthropic/claude-haiku-4-5AnthropicFast and cheap
google/gemini-3.1-proGoogleMultimodal, long context

How AnyRouter routes a request

Every request flows through three stages — key auth, model selection, and upstream dispatch — with automatic fallback if the first provider is unavailable:

flowchart LR
    Client([Your app]) -->|sk-ar-v1-...| A[AnyRouter API]
    A --> B{Route}
    B -->|primary| P[Provider A]
    B -->|fallback| Q[Provider B]
    P -->|response| Client
    Q -->|response| Client