Quickstart
Make your first request, and read what it cost.
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.
The call
The base URL is https://api.multigrid.ai/v1. Everything is JSON over HTTPS and the key travels as a bearer token.
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.
{
"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 header | Description |
|---|---|
| X-Multigrid-Request-Id | The id of this request. Everything else is looked up by it. |
| X-Multigrid-Model | The model that actually answered, which is not always the one you asked for. |
| X-Multigrid-Provider | The provider that served it. |
| X-Multigrid-Attempts | How many upstream calls it took. More than one means something failed and we recovered. |
| X-Multigrid-Cost-Usd | Cost 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:
curl https://api.multigrid.ai/v1/modelsIf 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
- Set a spending limit before you put a key anywhere it might leak.
- Add a fallback model so one provider having a bad hour is not your outage.
- Send an Idempotency-Key on anything your client might retry.
Something here disagrees with what the API actually did? That is a bug in this page, and worth reporting.
Report it