Video generation
Compatible with OpenAI Videos. Video generation is an asynchronous task: submit, query, download.
| Model | Token group | Supported input |
|---|---|---|
grok-imagine-video-1.5 | grok | Text-to-video, image-to-video, multi-image reference (up to 14), first and last frames |
grok-imagine-video-1.5-lite | grok | Text-to-video, image-to-video |
Authentication
Authorization: Bearer <token>
Submit a task
POST
https://api.codingrouter.ai/v1/videosRequest parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | See the table above |
prompt | string | Yes | Video description |
seconds | integer | No | Duration, 1 to 15, default 1 |
resolution | string | No | 480p (default), 720p, 1080p |
image | file | No | Reference image, form upload; one is image-to-video, several is multi-image reference |
first_frame, last_frame | file | No | First and last frames, must be uploaded together, grok-imagine-video-1.5 only |
- When there are images, upload files with
multipart/form-data. Image URLs or base64 in JSON are rejected. - Multi-image reference and first/last frames do not support
1080p.
Request example
bash
curl https://api.codingrouter.ai/v1/videos \
-H "Authorization: Bearer $CODINGROUTER_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-imagine-video-1.5",
"prompt": "Sunset by the sea, the camera slowly pushes in, waves hit the rocks",
"seconds": 6,
"resolution": "720p"
}'bash
curl https://api.codingrouter.ai/v1/videos \
-H "Authorization: Bearer $CODINGROUTER_KEY" \
-F model=grok-imagine-video-1.5-lite \
-F prompt="Make the person in the picture turn around and smile" \
-F seconds=6 \
-F image=@first.pngbash
curl https://api.codingrouter.ai/v1/videos \
-H "Authorization: Bearer $CODINGROUTER_KEY" \
-F model=grok-imagine-video-1.5 \
-F prompt="Transition smoothly from day to night" \
-F seconds=8 \
-F first_frame=@day.png \
-F last_frame=@night.pngResponse
json
{
"id": "task_3FnXIsT7uKTvi5r8LFiEDarfYKd1rcGu",
"object": "video",
"model": "grok-imagine-video-1.5-lite",
"status": "queued",
"progress": 0,
"created_at": 1794806577
}Query a task
GET
https://api.codingrouter.ai/v1/videos/{id}bash
curl https://api.codingrouter.ai/v1/videos/task_3FnXIsT7uKTvi5r8LFiEDarfYKd1rcGu \
-H "Authorization: Bearer $CODINGROUTER_KEY"json
{
"id": "task_3FnXIsT7uKTvi5r8LFiEDarfYKd1rcGu",
"object": "video",
"model": "grok-imagine-video-1.5-lite",
"status": "completed",
"progress": 100,
"seconds": 1,
"resolution": "480p",
"created_at": 1794806577,
"completed_at": 1794806621,
"content_url": "/v1/videos/task_3FnXIsT7uKTvi5r8LFiEDarfYKd1rcGu/content"
}status goes queued → in_progress → completed, or failed on failure. Query every 5 to 10 seconds. It usually completes in 20 seconds to 1 minute.
Download the video
GET
https://api.codingrouter.ai/v1/videos/{id}/contentbash
curl -L https://api.codingrouter.ai/v1/videos/task_3FnXIsT7uKTvi5r8LFiEDarfYKd1rcGu/content \
-H "Authorization: Bearer $CODINGROUTER_KEY" \
-o out.mp4Returns a video/mp4 file.
Full example (Python)
python
import time
import httpx
BASE = "https://api.codingrouter.ai"
headers = {"Authorization": "Bearer sk-your-token"}
with httpx.Client(base_url=BASE, headers=headers, timeout=120) as client:
task = client.post("/v1/videos", json={
"model": "grok-imagine-video-1.5-lite",
"prompt": "Sunset by the sea, the camera slowly pushes in",
"seconds": 6,
"resolution": "480p",
}).json()
while True:
time.sleep(8)
task = client.get(f"/v1/videos/{task['id']}").json()
if task["status"] in ("completed", "failed"):
break
if task["status"] == "completed":
video = client.get(f"/v1/videos/{task['id']}/content", follow_redirects=True)
open("out.mp4", "wb").write(video.content)Billing
Billed by the number of seconds generated and the resolution. See the model square for unit prices. Requests that fail parameter validation (400) are not charged.
