Hedra animacija likova
Animacija likova sa savršenom sinkronizacijom zvuka. Oživite portrete s prirodnim izrazima i pokretima.
✓ Animacija likova
✓ Sinkronizacija zvuka
✓ Portreti
✓ Kontrola izraza
Autentifikacija
Za pristup usluzi Hedra putem Doitong API-ja, koristite svoj Doitong API ključ. Uključite ga u GraphQL mutaciju ili zaglavlja REST API-ja.
// GraphQL Header
{
"Authorization": "Bearer YOUR_API_KEY"
}
// REST Header
"X-API-Key": "YOUR_API_KEY"
Brzi početak
Započnite s radom u usluzi Hedra Lip Sync API u samo nekoliko minuta. Slijedite ove jednostavne korake za generiranje svog prvog avatar.
1. korak: Preuzmite svoj API ključ
Registrirajte se za Doitong račun i idite na svoju nadzornu ploču kako biste generirali API ključ.
2. korak: Pošaljite svoj prvi zahtjev
Upotrijebite jedan od primjera koda u nastavku za svoj prvi API poziv.
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"
}
}
}
Cijene
Hedra Lip Sync API koristi model naplate temeljen na kreditima. Krediti se troše ovisno o složenosti i trajanju generiranog sadržaja.
| Značajka | Krediti | Opis |
|---|---|---|
| Kratki video | 50-100 Krediti | Do 30 sekundi |
| Dugi video | 200-500 Krediti | 30 sekundi do 2 minute |
API krajnje točke
Hedra Lip Sync API je dostupan putem naše objedinjene GraphQL krajnje točke.
GraphQL krajnja točka
POST https://api.doitong.com/graphql
REST krajnja točka
POST https://api.doitong.com/v1/avatar
Parametri
Dostupni parametri za Hedra Lip Sync API zahtjeve:
| Parametar | Vrsta | Obavezno | Opis |
|---|---|---|---|
service |
String | Yes | Identifikator usluge: "hedra" |
version |
String | No | Model version: "hedra-1.0" |
webhookUrl |
String | No | URL za primanje obavijesti o završetku |
Format odgovora
Svi API odgovori slijede dosljedan format:
Uspješan odgovor
{
"data": {
"avatar": {
"id": "abc123xyz",
"status": "processing",
"url": null,
"webhookUrl": "https://your-webhook.com/callback",
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Završen odgovor
{
"data": {
"avatar": {
"id": "abc123xyz",
"status": "completed",
"url": "https://cdn.doitong.com/outputs/abc123xyz.mp3",
"duration": null,
"createdAt": "2024-01-01T00:00:00Z"
}
}
}
Obrada pogrešaka
API koristi standardne HTTP statusne kodove i vraća detaljne poruke o pogreškama.
Uobičajeni kodovi pogrešaka
| Statusni kod | Vrsta pogreške | 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 o pogrešci
{
"errors": [
{
"message": "Insufficient credits for this operation",
"extensions": {
"code": "INSUFFICIENT_CREDITS",
"creditsRequired": 100,
"creditsAvailable": 50
}
}
]
}
Webhooks
Primajte obavijesti u stvarnom vremenu kada generiranje vašeg avatar završi.
Postavljanje webhookova
Include a <code>webhookUrl</code> parameter in your request to receive a POST notification when processing is complete.
Webhook podaci (payload)
{
"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
}
}
Sigurnost webhookova
Svi zahtjevi webhooka uključuju zaglavlje s potpisom radi provjere:
X-Doitong-Signature: sha256=abc123...
Ograničenja učestalosti (Rate Limits)
Kako bi se osiguralo pošteno korištenje i stabilnost sustava, primjenjuju se sljedeća ograničenja:
| Plan | Zahtjeva/minuti | Istovremeni zadaci | Dnevno ograničenje |
|---|---|---|---|
| Besplatno | 10 | 1 | 100 |
| Starter | 30 | 3 | 1,000 |
| Pro | 60 | 10 | 10,000 |
| Enterprise | Prilagođeno | Prilagođeno | Neograničeno |
X-RateLimit-Limit: Maximum requests per windowX-RateLimit-Remaining: Requests remainingX-RateLimit-Reset: Window reset timestamp
Najbolje prakse
1. Optimizirajte svoje upite
Pišite jasne i opisne upite za najbolje rezultate:
- Be specific about visual elements, style, and mood
- Include details about lighting, camera angles, and composition
- Avoid contradictory or impossible requests
2. Upravljajte asinkronom obradom
Generiranje je asinkrono. Implementirajte ispravno prozivanje (polling) ili 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. Oporavak od pogrešaka
Implementirajte logiku ponovnog pokušaja s eksponencijalnim odmakom:
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. Pratite potrošnju kredita
Pratite potrošnju kredita kako biste izbjegli prekide u radu:
- Check credit balance before large batch operations
- Set up alerts for low credit thresholds
- Implement credit-aware request queuing
Spremni za početak?
Pridružite se tisućama programera koji koriste Hedra Lip Sync API za stvaranje nevjerojatnog sadržaja