Quickstart

Create a key, send a request, read the usage and cost back.

View as Markdown

1. Create an API key

Sign in to the dashboard, open API keys and create a key. Keys look like sk-er-v1-… and are shown once. Optionally set a USD spend limit and a per-minute rate limit.

2. Send a request

Any OpenAI SDK works by changing the base URL, and the official ElevenRouter SDKs add typed access to everything else. Build your first request here — pick a model, toggle streaming or a route receipt, and copy the snippet in the language you use:

curl https://elevenrouter.com/api/v1/chat/completions \
  -H "Authorization: Bearer $ELEVENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "z-ai/glm-5.3-flash",
  "messages": [
    {
      "role": "user",
      "content": "Explain what an AI gateway does in two sentences."
    }
  ]
}'
Replace $ELEVENROUTER_API_KEY with a key from the dashboard. Nothing you type here is sent anywhere.

Or the shortest possible version with curl:

curl https://elevenrouter.com/api/v1/chat/completions \
  -H "Authorization: Bearer $ELEVENROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "openai/gpt-5.6-luna", "messages": [{"role": "user", "content": "Hello!"}]}'

3. Read usage and cost

Pass "usage": {"include": true} to receive the exact cost of the request inside the usage object (also on the final streaming chunk), or call GET /generation?id=… with the response id afterwards.

{
  "id": "gen-Qm3bHk9ZP2xT7Y1L",
  "model": "anthropic/claude-sonnet-5",
  "provider": "Anthropic",
  "choices": [{ "index": 0, "message": { "role": "assistant", "content": "..." }, "finish_reason": "stop" }],
  "usage": {
    "prompt_tokens": 21, "completion_tokens": 38, "total_tokens": 59,
    "cost": 0.000422
  }
}

4. Pick models

Model identifiers are canonical slugs like anthropic/claude-opus-4.6 or deepseek/deepseek-v4-flash. Upstream-style aliases (claude-opus-4-6, gpt-5.6-sol) are accepted too, as are ~vendor/family-latest aliases and @preset/slug references. List everything with GET https://elevenrouter.com/api/v1/models.

5. Go to production

Give every environment its own workspace and keys, set a budget with alerts, add a fallback model, and enable a route receipt while you integrate — the best practices page is a ten-minute checklist. Coding agents can read the docs as Markdown from llms.txt or operate the account through the MCP server.