Skip to main content

1. Get an API key

Create an API key in the Dashboard. Use it as a bearer token:
For local scripts, store it in an environment variable:

2. Choose an endpoint

GET /models is public and does not require an API key. Generation and chat endpoints require the Bearer header configured above.

3. Create a task

This example creates a video task:
The response includes a task_id:
If the POST request times out or its result is uncertain, do not blindly retry it. A retry can create another generation task and billing order.

4. Poll the task

Use the task_id with the matching query endpoint:
Stop polling when status is Success, Failed, or Cancelled. When video generation succeeds, file_url contains the generated video URL. For image tasks, output_images contains generated image URLs. These output URLs are dynamically signed; download or copy assets you need instead of storing the URL as a permanent identifier.

5. Check usage and cost

The create response includes pricing information when available. Use the Pricing page for current model rates, and open the model page in the API Reference for request parameters.

Next

Use Models to pick the best model family, or open the API Reference for exact request schemas.