How It Works
Every call to POST /api/v1/run/{model_id} returns immediately with a task_id:
{
"task_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "waiting"
}
The actual generation happens in the background. You retrieve the result by either polling or using a callback URL.
Task Lifecycle
waiting → generating → success
→ fail
| Status | Meaning |
|---|
waiting | Task queued, not yet started |
generating | Model is actively generating |
success | Generation complete — result_urls is populated |
fail | Generation failed — check error_message |
Option 1 — Polling
Call GET /api/v1/run/tasks/{task_id} repeatedly until status is success or fail.
curl https://routerbase.kuaibaike.com/api/v1/run/tasks/f47ac10b-58cc-4372-a567-0e02b2c3d479 \
-H "Authorization: Bearer sk-t0-xxxxxxxxxxxx"
Recommended polling interval: 3 seconds for video/image, 1 second for chat models.
Option 2 — Callback URL
Pass a callback_url in your request body. RouterBase will POST the completed task result to that URL.
{
"prompt": "A sunset over the ocean",
"callback_url": "https://yourapp.com/webhooks/routerbase",
"video_params": { "aspect_ratio": "16:9" }
}
The callback payload matches the same structure as the poll response:
{
"task_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"status": "success",
"result_urls": ["https://routerbase.kuaibaike.com/results/video.mp4"],
"error_message": null,
"created_at": "2025-01-15T10:30:00Z"
}
Callbacks eliminate the need for polling and reduce latency for long-running tasks like video generation (typically 1–3 minutes).
Typical Generation Times
| Modality | Typical Time |
|---|
| Chat / LLM | 2–30 seconds |
| Image generation | 10–60 seconds |
| Video generation | 1–5 minutes |
Times vary by model and provider load.