> ## 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 and video 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.
* `https://api.zerogen.com/v1/openapi.json` is the OpenAPI document: every endpoint, its parameters and responses, and the scope it needs.
* Start with the quickstart, SDKs, authentication, models, test keys, errors and idempotency pages.

In TypeScript or JavaScript, use the official library, `@zerogen/sdk` (`npm install @zerogen/sdk`). It sends idempotency keys, retries what's retryable, waits for generations and pages through lists, and its types follow the OpenAPI document. Its README is at `https://github.com/zerogeneration/zerogen-typescript`. 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 library). Its `requestSchema` is the JSON Schema the request body must match, including the model's input roles and parameters.
* With the library, create a generation with `zerogen.generations.createAndWait`, and check the result's `status`. Over HTTP, create it with `POST /v1/generations` and an `Idempotency-Key` header with a new UUID for each generation, reused when you retry. Send `Prefer: wait=60`, then read `GET /v1/generations/{id}` with the same `Prefer` header until `status` is `succeeded`, `partial`, `failed` or `cancelled`.
* Branch on the error's `code` (`ZeroGenError.code` in the library). Over HTTP, retry only when `error.retryable` is true, and wait for `Retry-After` on a 429; the library does this for you.
* Money fields end in `MicroUsd` 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 generation 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, for tools that load all context at once. |
| One page as Markdown | Add `.md` to any page URL | For example, `https://docs.zerogen.com/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.