Vidu E-commerce Video

Giniúint físeán dírithe ar ríomhthráchtáil le haghaidh taispeántais táirgí

✓ Físeáin táirgí

✓ 8 soicind

✓ Réidh le haghaidh margaíochta

✓ Optamaithe do ríomhthráchtáil

Fíordheimhniú

Chun teacht ar Vidu trí API Doitong, úsáid d'eochair API Doitong. Cuir san áireamh í i mutation GraphQL nó i gceanntásca an API REST.

Tábhachtach: Coinnigh d'eochair API Doitong slán agus ná taispeáin i gcód cliant í riamh. Déan glaonna API ó do fhreastalaí cúil i gcónaí.
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

// REST Header
"X-API-Key": "YOUR_API_KEY"

Treoir Thapa

Cuir tús le Vidu API laistigh de chúpla nóiméad. Lean na céimeanna simplí seo chun do chéad text to video a ghiniúint.

Céim 1: Faigh d'Eochair API

Cláraigh le haghaidh cuntas Doitong agus téigh chuig do phainéal rialaithe chun eochair API a ghiniúint.

Céim 2: Déan do Chéad Iarratas

Úsáid ceann de na samplaí cóid thíos chun do chéad ghlao API a dhéanamh.

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": "vidu",
        "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: 'vidu',
        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": "vidu",
        "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": "vidu",
    "input": {
      "text": "A serene landscape with mountains and a lake at sunset"
    },
    "options": {
      "duration": 5,
      "aspectRatio": "16:9",
      "version": "vidu-1.0",
      "quality": "high"
    }
  }
}

Praghsáil

Úsáideann Vidu API múnla praghsála bunaithe ar chreidmheasanna. Ídítear creidmheasanna bunaithe ar chastacht agus ar fhad an ábhair a ghintear.

Gné Creidmheasanna Cur Síos
Mód Caighdeánach 100-200 Creidmheasanna Físeán 5-10 soicind ar chaighdeán caighdeánach
Mód Pro 300-500 Creidmheasanna Físeán 5-10 soicind ar chaighdeán gairmiúil

Críochphointí API

Tá Vidu API ar fáil trínár gcríochphointe aontaithe GraphQL.

Críochphointe GraphQL

POST https://api.doitong.com/graphql

Críochphointe REST

POST https://api.doitong.com/v1/text_to_video

Paraiméadair

Paraiméadair atá ar fáil d'iarratais Vidu API:

Paraiméadar Cineál Riachtanach Cur Síos
service Teaghrán Yes Aitheantóir seirbhíse: "vidu"
prompt Teaghrán Yes Tuairisc téacs ar cad ba mhaith leat a ghiniúint
duration Slánuimhir No Fad an fhíseáin i soicindí (réamhshocrú: 5)
aspectRatio Teaghrán No Cóimheas gné: "16:9", "9:16", "1:1" (réamhshocrú: "16:9")
version Teaghrán No Model version: "vidu-1.0"
webhookUrl Teaghrán No URL chun fógraí críochnaithe a fháil

Formáid an Fhreagra

Leanann gach freagra API formáid chomhsheasmhach:

Freagra rathúil

{
  "data": {
    "generatevideo": {
      "id": "abc123xyz",
      "status": "processing",
      "url": null,
      "webhookUrl": "https://your-webhook.com/callback",
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Freagra críochnaithe

{
  "data": {
    "generatevideo": {
      "id": "abc123xyz",
      "status": "completed",
      "url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
      "duration": 5,
      "createdAt": "2024-01-01T00:00:00Z"
    }
  }
}

Láimhseáil Earráidí

Úsáideann an API cóid stádais HTTP chaighdeánacha agus seolann sé teachtaireachtaí earráide mionsonraithe ar ais.

Cóid Earráide Choitianta

Cód Stádais Cineál Earráide Cur Síos
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

Formáid an Fhreagra Earráide

{
  "errors": [
    {
      "message": "Insufficient credits for this operation",
      "extensions": {
        "code": "INSUFFICIENT_CREDITS",
        "creditsRequired": 100,
        "creditsAvailable": 50
      }
    }
  ]
}

Webhooks

Faigh fógraí fíor-ama nuair a bhíonn do ghiniúint text to video críochnaithe.

Webhooks a Chumrú

Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.

Lastas Pá Webhook

{
  "id": "abc123xyz",
  "status": "completed",
  "url": "https://cdn.doitong.com/outputs/abc123xyz.mp4",
  "service": "vidu",
  "createdAt": "2024-01-01T00:00:00Z",
  "completedAt": "2024-01-01T00:01:00Z",
  "metadata": {
    "duration": 5,
    "width": 1920,
    "height": 1080
  }
}

Slándáil Webhook

Cuimsíonn gach iarratas webhook ceanntásc sínithe le haghaidh fíoraithe:

X-Doitong-Signature: sha256=abc123...

Teorainneacha Ráta

Chun úsáid chothrom agus cobhsaíocht an chórais a chinntiú, tá na teorainneacha ráta seo a leanas i bhfeidhm:

Plean Iarratais/Nóiméad Jabanna Comhthráthacha Teorainn laethúil
Saor in aisce 10 1 100
Tosaitheoir 30 3 1,000
Pro 60 10 10,000
Fiontar Saincheaptha Saincheaptha Gan teorainn
Ceanntásca Teorainn Ráta: Seiceáil ceanntásca an fhreagra le haghaidh stádas na dteorainneacha reatha:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

Dea-chleachtais

1. Optamaigh do chuid Prasanna

Scríobh prasanna soiléire tuairisciúla chun na torthaí is fearr a fháil:

  • Be specific about visual elements, style, and mood
  • Include details about lighting, camera angles, and composition
  • Avoid contradictory or impossible requests

2. Láimhseáil Próiseáil Asincrónach

Is próiseas asincrónach é an ghiniúint. Cuir vótaíocht chuí nó webhooks i bhfeidhm:

// 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. Téarnamh ó Earráidí

Cuir loighic atriail i bhfeidhm le haischéimniú easpónantúil:

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. Monatóireacht ar Úsáid Creidmheasa

Coinnigh súil ar do chuid creidmheasanna chun briseadh sa tseirbhís a sheachaint:

  • Check credit balance before large batch operations
  • Set up alerts for low credit thresholds
  • Implement credit-aware request queuing

An bhfuil tú réidh le tosú?

Bí i dteannta na mílte forbróirí atá ag úsáid Vidu API chun ábhar iontach a chruthú

Faigh Eochair API Anois Féach ar Phraghsáil