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

# DreamLayer Agent API

> Generate images, sprites, and quoted videos, with authenticated delivery and recoverable jobs.

# DreamLayer Agent API

## What this lets you do

Use the Agent API for images, sprites, and quoted videos, with execution recovery, API credit billing, and owned asset delivery. Published image and sprite CLI/MCP clients use this same API and key.

For an executable first request, start with the [Quickstart](/quickstart). This page explains the contract your integration should build around.

The [sprite-sheet beta](/agent-api/sprite-sheet) is available to all authenticated
accounts under normal credit and quota checks. Submit a reference image and a
custom animation instruction or preset to receive a ZIP. The published CLI and
MCP beta clients also support this operation. Check capabilities before selecting an operation.

For [Video](/agent-api/video), check `/v1/video/capabilities`, create a quote, then accept its price at `/v1/execute`. Sound is on by default. Video always acknowledges acceptance with JSON and has its own [states, synchronous admission errors, and event behavior](/agent-api/video-jobs). The image lifecycle below does not replace those rules.

## Image and sprite execution lifecycle

A request creates one durable execution. DreamLayer may ask a clarifying question before it starts a job. Once work begins, the execution moves through queued and running states until it completes, fails, or is cancelled.

The event stream is a convenient live view, but it is not the source of truth. Save the `execution_id`, and read canonical state or resume the stream after a disconnect. See [Jobs and event streams](/agent-api/jobs-and-events).

## Image and sprite events

The closed public event set is `started`, `thinking`, `progress`, `job`, `question`, `asset`, and `done`. Only `done` is terminal. Display text can change, so branch on event names and documented status fields instead of matching message text.

## Idempotency and recovery

Give every logical request one stable `Idempotency-Key`. If the connection fails, inspect the saved execution or resume its events before submitting again. Reuse the same key only for the same request; a new key can create new work. See [Idempotency and retries](/agent-api/idempotency-and-retries).

## Billing

Image operations reserve one user credit before work begins and settle it after
successful delivery. Sprite sheets instead reserve the approved frame-count quote,
rounded upward to four decimal credits, and settle on complete ZIP delivery. Failure
or timeout restores the hold. Sprite requests have no customer cancellation.

Video reserves its accepted quote and settles once on owned MP4 delivery. Only queued videos can be cancelled. See [Video pricing and restoration](/agent-api/video-settings).

Read `GET /v1/balance?pricing=current` before starting work when your integration needs a current credit snapshot. The endpoint is API-key authenticated, owner-scoped, uncacheable, and makes no image request. See [Check balance](/agent-api/balance).

## Assets

Input assets are owner-scoped and must finish server-side normalization before use. A completed execution emits an `asset` event with an owned `download_url`; follow redirects and authenticate the download. See [Assets](/agent-api/assets).

## Common errors

* `422`: the Authorization header is missing or the request is invalid.
* `401`: the bearer credentials are invalid or revoked.
* `429`: a request or event-stream limit rejected the HTTP request.
* For images and sprites, nonretryable credit or quota admission failures appear after acceptance in the execution's `error` object. Retryable admission failures keep the execution queued. Video instead can reject acceptance immediately with `402` or `429`. Follow the operation-specific [error handling](/agent-api/errors).
* `503`: managed execution is disabled.

## Troubleshooting

Do not create a new idempotency key after an uncertain response. Read canonical state first, and keep prompts, API keys, image data, and download URLs out of public logs.

## Operation guides

* [Run text-to-image](/agent-api/text-to-image)
* [Upload one reference image](/agent-api/image-to-image)
* [Create a sprite sheet](/agent-api/sprite-sheet)
* [Create a video](/agent-api/video)
* [Manage conversations](/agent-api/conversations)
* [Create and revoke API keys](/agent-api/api-keys)
* [Check the authenticated balance](/agent-api/balance)
* [Handle errors](/agent-api/errors)

## Choose an integration path

| You want to | Start here |
| - | - |
| Make a first image | [Quickstart](/quickstart) |
| Make a first video | [Text-to-video](/agent-api/text-to-video) |
| Connect an AI client | [MCP tool reference](/mcp/tools) |
| Automate local files | [CLI automation and recovery](/cli/automation) |
| Build an application | [Runnable Python and JavaScript examples](/agent-api/examples) |
| Process a set of images | [Bounded queue and partial recovery](/agent-api/multiple-images) |
| Check requests and responses | [OpenAPI 3.1 specification](/openapi/managed.yaml) |

Before paid work, read [authentication](/agent-api/api-keys), [limits](/agent-api/limits), and [balance](/agent-api/balance). Keep execution IDs and idempotency keys so [stream recovery](/agent-api/jobs-and-events) does not create duplicate work.

The current integration contract uses SSE and canonical state reads. It does not document a webhook delivery contract or a native batch submission endpoint. Use the documented mechanisms rather than assuming either is available.


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