# OpenGrid documentation

One API for video, image and audio models. You name a model; OpenGrid runs it on the lowest-priced healthy provider and moves the job if that provider fails.

- [Quickstart](https://opengrid.one/docs/quickstart): A key, one request and a finished file.
- [Create a generation](https://opengrid.one/docs/generations): Every field of the request and the reply.
- [Use your agent](https://opengrid.one/docs/agents): The MCP server and the skill file for Claude Code, Codex and Cursor.

## Your first request

The base URL is `https://api.opengrid.one/v1`. Requests and replies are JSON. A generation is a job: start it and wait on the same request for the result, or read it later by id.

curl:

```sh
curl "https://api.opengrid.one/v1/generations?wait=60" \
  -H "Authorization: Bearer $OPENGRID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "nano-banana-pro",
  "variant": "2k",
  "quantity": 1,
  "input": {
    "prompt": "A paper boat drifting down a rain gutter, golden hour",
    "aspect_ratio": "16:9"
  }
}'
```

Python:

```python
import os, uuid, requests

api = "https://api.opengrid.one/v1"
headers = {"Authorization": f"Bearer {os.environ['OPENGRID_API_KEY']}"}

# Start the job and wait for it. You are charged only if it succeeds.
job = requests.post(
    f"{api}/generations?wait=60",
    headers={**headers, "Idempotency-Key": str(uuid.uuid4())},
    json={
        "model": "nano-banana-pro",
        "variant": "2k",
        "quantity": 1,
        "input": {
            "prompt": "A paper boat drifting down a rain gutter, golden hour",
            "aspect_ratio": "16:9"
        }
    },
).json()

# A long video can outlast one request: keep waiting on the same job.
while job["status"] in ("queued", "running"):
    job = requests.get(f"{api}/generations/{job['id']}?wait=60", headers=headers).json()

print(job["status"], job["outputs"], job["charged_usd"])
```

JavaScript:

```js
const api = "https://api.opengrid.one/v1";
const headers = {
  Authorization: `Bearer ${process.env.OPENGRID_API_KEY}`,
  "Content-Type": "application/json",
};

// Start the job and wait for it. You are charged only if it succeeds.
let job = await fetch(`${api}/generations?wait=60`, {
  method: "POST",
  headers: { ...headers, "Idempotency-Key": crypto.randomUUID() },
  body: JSON.stringify({
    "model": "nano-banana-pro",
    "variant": "2k",
    "quantity": 1,
    "input": {
      "prompt": "A paper boat drifting down a rain gutter, golden hour",
      "aspect_ratio": "16:9"
    }
  }),
}).then((r) => r.json());

// A long video can outlast one request: keep waiting on the same job.
while (job.status === "queued" || job.status === "running") {
  job = await fetch(`${api}/generations/${job.id}?wait=60`, { headers }).then((r) => r.json());
}

console.log(job.status, job.outputs?.[0]?.url, job.charged_usd);
```

## Set up your agent

Paste this into Claude Code, Codex, Cursor or any agent that can run commands. It reads the skill file, checks your key and is ready to generate.

Paste this into your agent:

```text
Set yourself up to use OpenGrid for any image, video, voice-over or music I ask for. Read https://opengrid.one/SKILL.md and follow its setup steps. My API key is in the OPENGRID_API_KEY environment variable; if it is not set, ask me for it and never print it. Tell me the price and wait for my yes before anything that spends credits.
```

To connect over MCP instead, see [MCP server](https://opengrid.one/docs/mcp).

## Endpoints at a glance

| Endpoint | Key | What it does |
|---|---|---|
| `GET /v1/models` | No | Every model that can run now, with variants and prices. |
| `GET /v1/models/{id}` | No | One model, with its quantity range and input fields. |
| `GET /v1/status` | No | Success rate and typical time per model, last 24 hours. |
| `POST /v1/estimate` | Yes | The price of a request. Charges nothing. |
| `POST /v1/generations` | Yes | Start a generation. `?wait=60` holds the request until it finishes. |
| `GET /v1/generations/{id}` | Yes | One generation. `?wait=60` holds the request until it finishes. |
| `GET /v1/generations` | Yes | Recent generations, newest first. |
| `GET /v1/balance` | Yes | Balance, account tier and limits. |
| `GET /v1/usage` | Yes | Generations and spend per day. |

## For machines

- [llms.txt](https://opengrid.one/llms.txt): every page of these docs with a one-line description.
- [llms-full.txt](https://opengrid.one/llms-full.txt): all of the docs in one Markdown file.
- [SKILL.md](https://opengrid.one/SKILL.md): the skill file an agent installs.
- Every docs page has a Markdown copy: add `.md` to its address, or use **Copy page** at the top.

Source: https://opengrid.one/docs
