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

# Development guide

> Async flow, error codes, and best practices

## Async flow

<Steps>
  <Step title="Submit">
    Call `POST /v1/images` or `POST /v1/videos` and read `data.task_id`.
  </Step>

  <Step title="Poll">
    Call the matching `GET .../{task_id}` until `status` is terminal.
  </Step>

  <Step title="Fetch result">
    On success, use `data.result.image_url` or `data.result.video_url`. On failure, read `data.error_message`.
  </Step>
</Steps>

Poll every 2–5 seconds and set a sensible timeout.

## Response shape

Successful calls return `code: 20000` with payload in `data`. Create and query share the same `data` schema.

### Common codes

| Code | Meaning | What to do |
| - | - | - |
| 20000 | Success | — |
| 20002 | Invalid params | Check `model`, duration, aspect ratio |
| 20001 | Auth failed | Rotate or recreate the API key |
| -1 | Server error | Retry later |

## Best practices

1. **Persist media promptly**: result URLs are kept about **3 days**.
2. **Check the catalog**: confirm live `model` IDs via the [model catalog](/en/api-reference/common/model-catalog).
3. **Reconcile with `cost`**: `data.cost` is the charged amount (credits).
4. **Protect keys**: never commit API keys to public repos.


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