> ## 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.

# Process multiple images

> Use a bounded client queue, one saved request per image, and independent failure recovery.

DreamLayer currently exposes individual executions, not a native batch submission endpoint. A conversation is a sequence of turns, not a batch. Keep each image's request, key, execution ID, and output separate.

## A queue you can resume

Create one request JSON per image using the [runnable examples](/agent-api/examples). For edits, upload each reference once and store its input asset ID in that file. Use the Python queue below with `agent_client.py` in the same directory:

```python theme={null}
from pathlib import Path
import subprocess
import time

for request in sorted(Path("requests").glob("*.json")):
    journal = Path("jobs") / request.name
    journal.parent.mkdir(exist_ok=True)
    command = (["resume", str(journal)] if journal.exists()
               else ["submit", str(request), str(journal)])
    result = subprocess.run(["python3", "agent_client.py", *command], check=False)
    if result.returncode:
        print(f"Needs attention: {journal}")
        # Stop admission: the failed client may still own an active server job.
        # Inspect canonical state before advancing the queue.
        break
    time.sleep(7)  # Also pace submissions; concurrency alone is not rate limiting.
```

The serial queue is deliberately conservative. If you add concurrency, use a semaphore with at most two active executions across your account and one shared request limiter. Keep work queued locally when the account is busy. Bound retry attempts and honor [limits](/agent-api/limits).

## Recover partial failures

| Item state                   | Action                                                                                   |
| ---------------------------- | ---------------------------------------------------------------------------------------- |
| Completed                    | Download that execution's existing asset; do not regenerate it.                          |
| Running or queued            | Resume that execution. Keep it counted against your concurrency budget.                  |
| Request acknowledgement lost | Replay the saved bytes with their original key.                                          |
| Needs input                  | Resolve its question in its conversation before proceeding.                              |
| Failed or cancelled          | Record the failure. A replacement requires a separate decision and new request identity. |

A retryable HTTP error is not proof that a job failed. Keep uncertainty separate from terminal failure. Never rerun an entire group with fresh keys because one item failed.
