Hedra Character Animation

Animacija likov s popolno sinhronizacijo zvoka. Oživite portrete z naravnimi izrazi in gibi.

✓ Animacija likov

✓ Sinhronizacija zvoka

✓ Portreti

✓ Nadzor izrazov

Avtentikacija

Za dostop do storitve Hedra prek API-ja Doitong uporabite svoj API ključ. Vključite ga v mutacijo GraphQL ali v glave REST API-ja.

Pomembno: Svoj API ključ Doitong skrbno varujte in ga nikoli ne razkrivajte v kodi na strani odjemalca. API klice vedno izvajajte iz svojega zalednega strežnika.
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

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

Hitri začetek

Začnite uporabljati Hedra Lip Sync API v le nekaj minutah. Sledite tem preprostim korakom za ustvarjanje svoje prve avatar.

1. korak: Pridobite API ključ

Registrirajte se za račun Doitong in v nadzorni plošči ustvarite svoj API ključ.

2. korak: Izvedite prvo zahtevo

Uporabite enega od spodnjih primerov kode za svoj prvi klic API.

curl -X POST https://api.doitong.com/graphql \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "query": "mutation Generate($input: GenerateInput!) { generate(input: $input) { id status type provider url metadata creditCost } }",
    "variables": {
      "input": {
        "type": "AVATAR",
        "provider": "hedra",
        "input": {
          "text": "Hello, welcome to our platform!",
          "avatarId": "professional-1"
        },
        "options": {
          "voice": "en-US-neural"
        }
      }
    }
  }'
const response = await fetch('https://api.doitong.com/graphql', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': 'Bearer YOUR_API_KEY'
  },
  body: JSON.stringify({
    query: `
      mutation GenerateAvatar($input: AvatarGenerationInput!) {
        generateAvatar(input: $input) {
          id
          status
          videoUrl
        }
      }
    `,
    variables: {
      input: {
        service: 'hedra',
        text: 'Hello, welcome to our platform!',
        avatarId: 'professional-1',
        voice: 'en-US-neural'
      }
    }
  })
});

const data = await response.json();
console.log('Avatar Video:', data.data.generateAvatar);
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": "AVATAR",
        "provider": "hedra",
        "input": {
            "text": "Hello, welcome to our platform!",
            "avatarId": "professional-1"
        },
        "options": {
            "voice": "en-US-neural"
        }
    }
}

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": "AVATAR",
    "provider": "hedra",
    "input": {
      "text": "Hello, welcome to our platform!",
      "avatarId": "professional-1"
    },
    "options": {
      "voice": "en-US-neural",
      "language": "en",
      "version": "hedra-1.0"
    }
  }
}

Cenik

Hedra Lip Sync API uporablja model cen na podlagi kreditov. Krediti se porabijo glede na kompleksnost in trajanje ustvarjene vsebine.

Funkcija Krediti Opis
Kratek video 50-100 Krediti Do 30 sekund
Dolg video 200-500 Krediti Od 30 sekund do 2 minut

Končne točke API

Hedra Lip Sync API je na voljo prek naše enotne končne točke GraphQL.

Končna točka GraphQL

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

Končna točka REST

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

Parametri

Razpoložljivi parametri za zahteve Hedra Lip Sync API:

Parameter Vrsta Obvezno Opis
service Niz Yes Identifikator storitve: "hedra"
version Niz No Model version: "hedra-1.0"
webhookUrl Niz No URL za prejem obvestil o dokončanju

Format odgovora

Vsi odgovori API-ja sledijo enotnemu formatu:

Odgovor ob uspehu

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

Odgovor ob dokončanju

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

Obravnava napak

API uporablja standardne statusne kode HTTP in vrača podrobna sporočila o napakah.

Pogoste kode napak

Statusna koda Vrsta napake Opis
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

Format odgovora ob napaki

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

Webhooki

Prejemajte obvestila v realnem času, ko je generiranje vaše avatar končano.

Nastavitev webhookov

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

Vsebina webhooka

{
  "id": "abc123xyz",
  "status": "completed",
  "url": "https://cdn.doitong.com/outputs/abc123xyz.mp3",
  "service": "hedra",
  "createdAt": "2024-01-01T00:00:00Z",
  "completedAt": "2024-01-01T00:01:00Z",
  "metadata": {
    "duration": null,
    "width": null,
    "height": null
  }
}

Varnost webhookov

Vse zahteve webhookov vključujejo glavo s podpisom za preverjanje:

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

Omejitve števila zahtev

Za zagotavljanje poštene uporabe in stabilnosti sistema veljajo naslednje omejitve:

Paket Zahtev/minuto Vzporedna opravila Dnevna omejitev
Brezplačno 10 1 100
Starter 30 3 1,000
Pro 60 10 10,000
Enterprise Po meri Po meri Neomejeno
Glave omejitev (Rate Limit): Preverite glave odgovorov za trenutno stanje omejitev:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

Najboljše prakse

1. Optimizirajte svoje pozive

Za najboljše rezultate pišite jasne in opisne pozive:

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

2. Upravljajte asinhrono obdelavo

Generiranje je asinhrono. Implementirajte ustrezno poizvedovanje (polling) ali webhooke:

// 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. Obnovitev po napakah

Implementirajte logiko ponovnega poskusa z eksponentnim zamikom:

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. Spremljajte porabo kreditov

Sledite porabi kreditov, da se izognete prekinitvam storitve:

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

Ste pripravljeni na začetek?

Pridružite se tisočem razvijalcev, ki uporabljajo Hedra Lip Sync API za ustvarjanje neverjetnih vsebin

Pridobite API ključ zdaj Oglejte si cenik