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

# Build with AI agents

> Give your coding agent the ZeroGen API docs and the rules it needs to integrate correctly.

Copy the following prompt into your coding agent, such as Claude Code, Codex,
or Cursor, to start a ZeroGen integration. It points the agent at these docs
and gives it the rules that are easiest to get wrong.

Start a ZeroGen API integration in your codebase.

You're integrating the ZeroGen API into this codebase. ZeroGen generates images, video and speech with many models through one REST API at `https://api.zerogen.com/v1`.

Read the docs before you write code, and fetch any page you need rather than guessing:

* `https://docs.zerogen.com/llms.txt` lists every docs page as Markdown. Pages under `https://docs.zerogen.com/developers/` and `https://docs.zerogen.com/api-reference/` cover the API; the others describe ZeroGen's app.
* `https://api.zerogen.com/v1/openapi.json` is the OpenAPI document: every endpoint, its parameters and responses, and the scope it needs.
* Start with these pages: `https://docs.zerogen.com/developers/quickstart.md`, `https://docs.zerogen.com/developers/sdks.md`, `https://docs.zerogen.com/developers/authentication.md`, `https://docs.zerogen.com/developers/models.md`, `https://docs.zerogen.com/developers/test-keys.md`, `https://docs.zerogen.com/developers/errors.md` and `https://docs.zerogen.com/developers/idempotency.md`.

Use an official library where one exists: `@zerogen/sdk` in TypeScript or JavaScript (`npm install @zerogen/sdk`), and `zerogen` in Python (`pip install zerogen`). They send idempotency keys, retry what's retryable, wait for runs and page through lists, and their types follow the OpenAPI document. Their READMEs are at `https://github.com/zerogeneration/zerogen-typescript` and `https://github.com/zerogeneration/zerogen-python`. In Python, request bodies are dicts with the API's own field names, such as `projectId`, and responses are pydantic models with snake\_case attributes, such as `project_id`; use `AsyncZeroGen` in async code. In other languages, call the REST API directly.

Follow these rules:

* Call the API from server code only. Read the key from the `ZEROGEN_API_KEY` environment variable and send it as `Authorization: Bearer <key>`. The API refuses browser requests.
* Develop with a test key, which starts with `zg_test_`. It runs every request on placeholder media at no charge.
* Before you build a request for a model, read `GET /v1/models/{vendor}/{model}/{operation}` (`zerogen.models.get(id)` in the libraries). Its `requestSchema` is the JSON Schema the request body must match, including the model's input roles and parameters.
* With a library, create a run with `zerogen.runs.createAndWait` (`create_and_wait` in Python), and check the result's `status`. Over HTTP, create it with `POST /v1/runs` and an `Idempotency-Key` header with a new UUID for each run, reused when you retry. Send `Prefer: wait=60`, then read `GET /v1/runs/{id}` with the same `Prefer` header until `status` is `succeeded`, `partial`, `failed` or `cancelled`.
* To fetch an output's file, read `GET /v1/assets/{assetId}/download` with the output's `asset.id`, which needs the `library:read` scope, and GET the returned `url` without the `Authorization` header. The `url` expires at `expiresAt`, so read a new one for each download rather than storing it, and keep it out of logs.
* To show assets or outputs without downloading the originals, use each asset's `preview`: `image96Url`, `image512Url`, and `videoUrl` for a video. Load them without the `Authorization` header. They expire at `preview.expiresAt`, so read the list or asset again for new ones. `preview` is `null` until the images are made, so show a placeholder.
* Branch on the error's `code` (`ZeroGenError.code` in the libraries). Over HTTP, retry only when `error.retryable` is true, and wait for `Retry-After` on a 429; the libraries do this for you.
* Money fields end in `MicroUsd` (`_micro_usd` on the Python library's responses) and are integer micro-USD. Keep them as integers.

Start by calling `GET /v1/me` to confirm the key's mode and scopes. Then build the smallest flow that creates one run and reads its result, and tell me how to run it.

## What the prompt points at

These docs publish machine-readable versions of every page:

| Resource | URL | Use |
| - | - | - |
| Page index | `https://docs.zerogen.com/llms.txt` | Every page, with a link to its Markdown version and to the OpenAPI document. |
| Full text | `https://docs.zerogen.com/llms-full.txt` | Every page in one file, app guides included, for tools that load all context at once. |
| One page as Markdown | Add `.md` to any page URL | For example, `https://docs.zerogen.com/developers/quickstart.md`. |
| Docs search server | `https://docs.zerogen.com/mcp` | An MCP server that searches and reads these docs. |

Each page's menu can also copy the page as Markdown, open it in Claude or
ChatGPT, or add the docs search server to Cursor or VS Code.

## Why the prompt reads model schemas

The API reference describes the request shape that every model shares, but
each model accepts its own inputs, output settings and parameters. Those live
in the model's `requestSchema`, which reflects your organization, so an agent
that reads it builds valid requests instead of guessing parameters from another
model.


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