API 參考
Veo 3.1 AI 影片生成完整 API 文件
概述
Veo 3.1 API 允許您透過程式化方式從文字描述或圖片生成 AI 影片。我們的 RESTful API 設計簡潔、功能強大,易於整合到您的應用程式中。
基礎 URL
https://veo3o1.com/api認證
所有 API 請求都需要使用 API 金鑰進行認證。在 Authorization 請求標頭中包含您的 API 金鑰:
Authorization: Bearer YOUR_API_KEY您可以在帳戶儀表板中產生 API 金鑰。
生成影片
從文字或圖片建立新的 AI 影片。
端點
POST /generate-video請求主體
{
"generationType": "text_to_video" | "image_to_video",
"prompt": "Your video description",
"aspectRatio": "auto" | "16:9" | "9:16",
"imageUrl": "https://...", // Required if generationType is "image_to_video"
"imageKey": "r2-key" // Optional, for uploaded images
}參數
| 參數 | 類型 | 必填 | 描述 |
|---|---|---|---|
generationType | string | 是 | 生成類型:text_to_video 或 image_to_video |
prompt | string | 是 | 您想要生成的影片描述 |
aspectRatio | string | 否 | 影片寬高比。預設:auto |
imageUrl | string | 條件必填 | 當 generationType 為 image_to_video 時必填 |
imageKey | string | 否 | 已上傳圖片的儲存金鑰 |
回應
{
"code": 0,
"msg": "Success",
"data": {
"uuid": "video-uuid-123",
"status": "pending",
"generationType": "text_to_video",
"prompt": "Your video description",
"aspectRatio": "16:9",
"createdAt": "2025-10-16T10:00:00Z"
}
}範例
curl -X POST https://veo3o1.com/api/generate-video \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"generationType": "text_to_video",
"prompt": "A beautiful sunset over the ocean with waves gently lapping the shore",
"aspectRatio": "16:9"
}'取得影片狀態
檢查影片生成請求的狀態。
端點
GET /video-status/{uuid}參數
| 參數 | 類型 | 必填 | 描述 |
|---|---|---|---|
uuid | string | 是 | 生成請求回傳的影片 UUID |
回應
{
"code": 0,
"msg": "Success",
"data": {
"uuid": "video-uuid-123",
"status": "completed" | "pending" | "processing" | "failed",
"videoUrl": "https://...", // Available when status is "completed"
"progress": 85, // Processing progress (0-100)
"estimatedTime": 120 // Estimated seconds remaining
}
}狀態值
pending:影片已排隊等待處理processing:影片正在生成中completed:影片已就緒,可供下載failed:生成失敗(請查看錯誤訊息)
上傳圖片
上傳圖片用於圖片轉影片生成。
端點
POST /upload-video-image請求
使用 multipart/form-data 上傳圖片檔案。
curl -X POST https://veo3o1.com/api/upload-video-image \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@/path/to/image.jpg"回應
{
"code": 0,
"msg": "Upload successful",
"data": {
"imageUrl": "https://...",
"imageKey": "r2-key-123"
}
}支援的格式
- JPEG/JPG
- PNG
- WebP
- 最大檔案大小:50MB
錯誤代碼
| 代碼 | 描述 |
|---|---|
| 0 | 成功 |
| 1000 | 參數無效 |
| 1001 | 積分不足 |
| 1002 | 認證失敗 |
| 1003 | 超出速率限制 |
| 5000 | 伺服器錯誤 |
錯誤回應範例
{
"code": 1001,
"msg": "Insufficient credits",
"data": {
"required": 2,
"current": 0
}
}最佳實踐
- 合理輪詢:每 5-10 秒檢查一次影片狀態,不要持續輪詢
- 處理錯誤:實作帶指數退避的重試邏輯
- 快取結果:儲存已生成的影片以避免重複生成
- 使用 Webhooks:比輪詢更高效的完成通知方式
- 驗證輸入:在呼叫 API 前檢查提示詞長度和圖片格式
支援
需要 API 幫助?
- 📧 電子郵件:aiprocessingrobot@gmail.com
- 💬 聯繫支援