Skip to content

Quickstart

Make your first request, and read what it cost.

3 min read

What you need

Two things: an account with some credit on it, and an API keyA long password your software uses to prove a request is yours. Anyone who has it can spend your credit, so treat it like a card number.Shown once, at creation. We keep only a hash, which means we genuinely cannot recover it for you — a lost key has to be replaced.. Both take about a minute from signup. A key is shown to you exactly once, at the moment it is created — we store a SHA-256 hash of it and nothing else, so there is no screen that can show it to you again.

You do not have to write code
The playground runs the same gateway this page describes — same routing, same limits, same billing — with your session instead of a key. If you only want to compare a few models, start there.

The call

The base URL is https://api.multigrid.ai/v1. Everything is JSON over HTTPS and the key travels as a bearer token.

bash
curl https://api.multigrid.ai/v1/chat/completions \
  -H "Authorization: Bearer $MULTIGRID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-5-nano",
    "messages": [{"role": "user", "content": "Explain what a gateway does, in two sentences."}]
  }'

That is the whole integration. The request body is OpenAI’s, so any client already written against /chat/completions works once you change two strings — see SDKs and clients.

What comes back

An ordinary OpenAI completion, with one extra object bolted on: multigrid, which says what actually happened to your request.

200 OK
{
  "id": "req_…",
  "object": "chat.completion",
  "created": 1785000000,
  "model": "openai/gpt-5-nano",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "A gateway sits …" },
      "finish_reason": "stop",
      "logprobs": null
    }
  ],
  "usage": {
    "prompt_tokens": 21,
    "completion_tokens": 48,
    "total_tokens": 69,
    "prompt_tokens_details": { "cached_tokens": 0 }
  },
  "multigrid": {
    "model": "openai/gpt-5-nano",
    "provider": "openai",
    "attempts": 1,
    "cost_usd": 0.0000202,
    "cost_micros": 20,
    "byok": false,
    "request_id": "req_…"
  }
}

cost_micros is the number that gets billed — an integer count of millionths of a dollar. cost_usd is the same figure as a decimal, for humans. The same facts also ride on the response headers, which is usually easier to log:

Response headerDescription
X-Multigrid-Request-IdThe id of this request. Everything else is looked up by it.
X-Multigrid-ModelThe model that actually answered, which is not always the one you asked for.
X-Multigrid-ProviderThe provider that served it.
X-Multigrid-AttemptsHow many upstream calls it took. More than one means something failed and we recovered.
X-Multigrid-Cost-UsdCost to six decimal places. Absent on a stream, where the total is not known until the last token.

Choosing a model

Model ids look like openai/gpt-5-nano or anthropic/claude-sonnet-5 — vendor, then model. The full list, with prices, is public and needs no key:

bash
curl https://api.multigrid.ai/v1/models

If you would rather not choose, pass multigrid/auto and we pick the cheapest model that can actually handle the request. The response tells you which one it picked and why.

Next steps

Something here disagrees with what the API actually did? That is a bug in this page, and worth reporting.

Report it