Google Veo3 Ultra
Google 最新的影片生成模型,具備驚人的寫實度與物理準確性。
✓ 超寫實影片效果
✓ 物理規律準確
✓ 高解析度
✓ 快速生成
身分驗證
若要透過 Doitong API 存取 Google Veo3,請使用您的 Doitong API 金鑰。請將其包含在 GraphQL mutation 或 REST API 標頭(Headers)中。
重要事項: 請妥善保管您的 Doitong API 金鑰,切勿將其洩露在用戶端程式碼中。請務必從您的後端伺服器發起 API 呼叫。
// GraphQL Header
{
"Authorization": "Bearer YOUR_API_KEY"
}
// REST Header
"X-API-Key": "YOUR_API_KEY"
快速上手
只需幾分鐘即可開始使用 Veo-3 API。按照以下簡單步驟生成您的第一個 text to video。
第一步:取得 API 金鑰
註冊 Doitong 帳號並前往控制台生成 API 金鑰。
第二步:發起首次請求
參考下方的程式碼範例來發起您的第一次 API 呼叫。
curl -X POST https://api.doitong.com/graphql \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: unique-request-id-123" \
-d '{
"query": "mutation Generate($input: GenerateInput!) { generate(input: $input) { id status type provider url metadata creditCost } }",
"variables": {
"input": {
"type": "VIDEO",
"provider": "veo3",
"input": {
"text": "A serene landscape with mountains and a lake at sunset"
},
"options": {
"duration": 5,
"aspectRatio": "16:9"
}
}
}
}'
const response = await fetch('https://api.doitong.com/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YOUR_API_KEY',
'Idempotency-Key': 'unique-request-id-123'
},
body: JSON.stringify({
query: `
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
}
}
`,
variables: {
input: {
type: 'VIDEO',
provider: 'veo3',
input: {
text: 'A serene landscape with mountains and a lake at sunset'
},
options: {
duration: 5,
aspectRatio: '16:9'
}
}
}
})
});
const data = await response.json();
console.log('Result:', data.data.generate);
import requests
import json
url = "https://api.doitong.com/graphql"
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer YOUR_API_KEY"
}
query = """
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
}
}
"""
variables = {
"input": {
"type": "VIDEO",
"provider": "veo3",
"input": {
"text": "A serene landscape with mountains and a lake at sunset"
},
"options": {
"duration": 5,
"aspectRatio": "16:9"
}
}
}
response = requests.post(url, json={
"query": query,
"variables": variables
}, headers=headers)
data = response.json()
print("Result:", data["data"]["generate"])
mutation Generate($input: GenerateInput!) {
generate(input: $input) {
id
status
type
provider
url
metadata
creditCost
createdAt
}
}
# Variables
{
"input": {
"type": "VIDEO",
"provider": "veo3",
"input": {
"text": "A serene landscape with mountains and a lake at sunset"
},
"options": {
"duration": 5,
"aspectRatio": "16:9",
"version": "veo-3",
"quality": "high"
}
}
}
價格方案
Veo-3 API 採用點數計費模式。點數消耗將根據生成內容的複雜程度與時長而定。
| 功能 | 點數 | 描述 |
|---|---|---|
| 標準模式 | 100-200 點數 | 5-10 秒標準畫質影片 |
| 專業模式 | 300-500 點數 | 5-10 秒專業畫質影片 |
API 端點
Veo-3 API 可透過我們的統一 GraphQL 端點進行存取。
GraphQL 端點
POST https://api.doitong.com/graphql
REST 端點
POST https://api.doitong.com/v1/text_to_video
參數說明
Veo-3 API 請求的可用參數:
| 參數 | 類型 | 必填 | 描述 |
|---|---|---|---|
service |
字串 (String) | Yes | 服務識別碼: "veo3" |
prompt |
字串 (String) | Yes | 要生成的內容文字描述 |
duration |
整數 (Integer) | No | 影片時長(秒),預設值:5 |
aspectRatio |
字串 (String) | No | 長寬比:"16:9", "9:16", "1:1",預設值:"16:9" |
version |
字串 (String) | No | Model version: "veo-3" |
webhookUrl |
字串 (String) | No | 接收完成通知的 URL |
回應格式
所有 API 回應均遵循統一格式:
成功回應
{
"data": {
"generatevideo": {
"id": "abc123xyz",
"status": "processing",
"url": null,
"webhookUrl": "https://your-webhook.com/callback",
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
完成回應
{
"data": {
"generatevideo": {
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
"duration": 5,
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
錯誤處理
API 使用標準 HTTP 狀態碼,並回傳詳細的錯誤訊息。
常見錯誤代碼
| 狀態碼 | 錯誤類型 | 描述 |
|---|---|---|
| 400 | Bad Request | Invalid parameters or malformed request |
| 401 | Unauthorized | Missing or invalid API key |
| 402 | Payment Required | Insufficient credits |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error, please retry |
錯誤回應格式
{
"errors": [
{
"message": "Insufficient credits for this operation",
"extensions": {
"code": "INSUFFICIENT_CREDITS",
"creditsRequired": 100,
"creditsAvailable": 50
}
}
]
}
Webhooks
在您的 text to video 生成完成時接收即時通知。
設定 Webhooks
Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.
Webhook 資料載體 (Payload)
{
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
"service": "veo3",
"createdAt": "2024-01-01T00:00:00Z",
"completedAt": "2024-01-01T00:01:00Z",
"metadata": {
"duration": 5,
"width": 1920,
"height": 1080
}
}
Webhook 安全性
所有 Webhook 請求均包含用於驗證的簽名標頭:
X-Doitong-Signature: sha256=abc123...
速率限制
為確保公平使用與系統穩定,適用以下速率限制:
| 方案 | 每分鐘請求數 (RPM) | 同時執行任務數 | 每日上限 |
|---|---|---|---|
| 免費版 | 10 | 1 | 100 |
| 入門版 | 30 | 3 | 1,000 |
| 專業版 | 60 | 10 | 10,000 |
| 企業版 | 客製化 | 客製化 | 無限制 |
速率限制標頭: 檢查回應標頭以獲取目前的限制狀態:
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Window reset timestamp
最佳實踐
1. 優化您的提示詞
撰寫清晰且具描述性的提示詞以獲得最佳效果:
- Be specific about visual elements, style, and mood
- Include details about lighting, camera angles, and composition
- Avoid contradictory or impossible requests
2. 處理非同步程序
生成過程是非同步的。請實作適當的輪詢(Polling)或 Webhooks:
// Polling example
async function pollStatus(jobId) {
let status = 'processing';
while (status === 'processing') {
await sleep(2000); // Wait 2 seconds
const result = await checkJobStatus(jobId);
status = result.status;
}
return result;
}
3. 錯誤恢復
實作具備指數退避(Exponential Backoff)機制的重試邏輯:
async function retryWithBackoff(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
await sleep(Math.pow(2, i) * 1000);
}
}
}
4. 監控點數使用量
追蹤您的點數消耗情況以避免服務中斷:
- Check credit balance before large batch operations
- Set up alerts for low credit thresholds
- Implement credit-aware request queuing
準備好開始了嗎?
加入數千名開發者的行列,使用 Veo-3 API 創作精彩內容