GET /v1/video/generations/{task_id}
curl 'https://88api.ai/v1/video/generations/{task_id}' \
-H "Authorization: Bearer sk-xxxx"
{
"error": null,
"format": "mp4",
"metadata": {
"duration": 5,
"fps": 30,
"height": 512,
"seed": 20231234,
"width": 512
},
"status": "succeeded",
"task_id": "abcd1234efgh",
"url": "https://example.com/video.mp4"
}
GET /v1/videos/{video_id}
curl 'https://88api.ai/v1/videos/video_123' \
-H "Authorization: Bearer sk-xxxx"
{
"id": "video_123",
"object": "video",
"model": "sora-2",
"created_at": 1640995200,
"status": "succeeded",
"progress": 100,
"expires_at": 1641081600,
"size": "1920x1080",
"seconds": "5",
"quality": "standard",
"url": "https://example.com/video.mp4"
}
GET /v1/videos/{video_id}/content
curl 'https://88api.ai/v1/videos/video_123/content' \
-H "Authorization: Bearer sk-xxxx" \
-o "video.mp4"
{
"code": null,
"message": "string",
"param": "string",
"type": "string"
}
{
"code": null,
"message": "string",
"param": "string",
"type": "string"
}
{
"code": null,
"message": "string",
"param": "string",
"type": "string"
}
{
"code": null,
"message": "Task not found",
"param": "task_id",
"type": "invalid_request_error"
}
{
"code": null,
"message": "string",
"param": "string",
"type": "string"
}
async function pollVideoStatus(taskId, maxAttempts = 30) {
const baseUrl = 'https://88api.ai';
const headers = {
Authorization: 'Bearer sk-xxxx',
'Content-Type': 'application/json',
};
for (let attempt = 0; attempt < maxAttempts; attempt++) {
try {
const response = await fetch(
`${baseUrl}/v1/video/generations/${taskId}`,
{
headers,
}
);
const result = await response.json();
if (result.status === 'succeeded') {
return result;
} else if (result.status === 'failed') {
throw new Error(
`Video generation failed: ${result.error?.message || 'Unknown error'}`
);
}
// 等待后重试
const delay = attempt < 6 ? 5000 : attempt < 12 ? 10000 : 30000;
await new Promise((resolve) => setTimeout(resolve, delay));
} catch (error) {
console.error(`Attempt ${attempt + 1} failed:`, error);
if (attempt === maxAttempts - 1) {
throw error;
}
}
}
throw new Error('Max polling attempts reached');
}