Start here / Tasks
Tasks and polling
Video requests always return a task id; do not send "async": true. Image requests return a task id only with "async": true; otherwise the request waits and returns data[] directly. Chat is synchronous or streamed, not polled.
| Capability | Create | Poll | Completed result |
|---|---|---|---|
| Image | POST /v1/images/generations or /edits with "async": true | GET /v1/tasks/{id} | data[].url |
| Video | POST /v1/videos | GET /v1/videos/{id} | Signed video_url |
Lifecycle
The normal transition is queued → in_progress → completed or failed.
- Stop polling on
completedorfailed. On failure, inspect the task response and check Dashboard → Task Logs for the billing outcome before deciding whether to resubmit. - Completed image tasks return
data[].url, even when you requestedresponse_format: b64_json. Use signed result URLs as returned and download them within 24 hours.
Generate and download a video
Use the model manual for supported parameters. The example submits a Kling 4.0 Flash task. Set TASK_ID to the returned id and repeat the status request until it reaches a terminal state.
bashcopy from the code panel
curl --fail-with-body https://api.apiko.app/v1/videos \
-H "Authorization: Bearer $APIKO_API_KEY" \
-H 'Content-Type: application/json' \
-d '{"model":"kling-4.0-flash","prompt":"Ocean waves at sunset","duration":3,"resolution":"720p"}'
curl --fail-with-body "https://api.apiko.app/v1/videos/$TASK_ID" \
-H "Authorization: Bearer $APIKO_API_KEY"Once the video is completed, download the signed video_url directly without your API key, or call GET /v1/videos/{id}/content with your Bearer key on the gateway and follow the redirect.
bashcopy from the code panel
curl --fail-with-body --location "https://api.apiko.app/v1/videos/$TASK_ID/content" \
-H "Authorization: Bearer $APIKO_API_KEY" --output result.mp4