> ## Documentation Index
> Fetch the complete documentation index at: https://docs.one-api.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Generate an image with one request, then fetch the result.

You need an API key. Keys are issued on request through the [contact page](https://one-api.ai/contact).

**1. Set your key**

```bash theme={null}
export ONE_API_TOKEN="your-api-key"
```

**2. Generate an image and wait for it**

`?wait=30` holds the call open for up to 30 seconds, so the answer already contains the result.

```bash cURL theme={null}
curl -sS 'https://one-api.ai/v1/images/generations?wait=30' \
  -H "Authorization: Bearer $ONE_API_TOKEN" \
  -d '{"model":"z-image-turbo","prompt":"a red fox asleep in fresh snow"}'
```

```bash CLI theme={null}
oneapi image "a red fox asleep in fresh snow" -o fox.jpg
```

```python Python theme={null}
import os, requests

response = requests.post(
    "https://one-api.ai/v1/images/generations",
    params={"wait": 30},
    headers={"Authorization": f"Bearer {os.environ['ONE_API_TOKEN']}"},
    json={"model": "z-image-turbo", "prompt": "a red fox asleep in fresh snow"},
)
task = response.json()["data"][0]
print(task["status"], task.get("result"))
```

```javascript JavaScript theme={null}
const response = await fetch("https://one-api.ai/v1/images/generations?wait=30", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.ONE_API_TOKEN}` },
  body: JSON.stringify({ model: "z-image-turbo", prompt: "a red fox asleep in fresh snow" }),
});
const task = (await response.json()).data[0];
console.log(task.status, task.result);
```

**3. Read the result**

```json theme={null}
{
  "code": 200,
  "data": [
    {
      "task_id": "task_0a17552fb8dbea3a74bc42048e5212e1",
      "id": "task_0a17552fb8dbea3a74bc42048e5212e1",
      "status": "completed",
      "type": "image",
      "model": "z-image-turbo",
      "cost": 0.005473684,
      "credits_cost": 5.473684,
      "created": 1795787453,
      "completed": 1795787475,
      "actual_time": 22,
      "result": { "images": [{ "url": ["https://…"] }] }
    }
  ]
}
```

Download the file at `result.images[0].url[0]`. The link is temporary, so save the file rather than storing the link.

If `status` is still `pending` or `processing` when the wait ends, keep the `task_id` and call `GET /v1/tasks/{id}?wait=60` until it finishes. See [Tasks and waiting](https://docs.one-api.ai/guides/tasks.md).

## Next

* [Generate a video](https://docs.one-api.ai/guides/videos.md)
* [Use the command line](https://docs.one-api.ai/cli.md)
* Every route and field is in the **API reference** tab


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.