Hedra Character Animation

Animazione di personaggi con sincronizzazione audio perfetta. Dai vita ai ritratti con espressioni e movimenti naturali.

✓ Animazione personaggi

✓ Sincronizzazione audio

✓ Ritratti

✓ Controllo espressioni

Autenticazione

Per accedere a Hedra tramite l'API di Doitong, usa la tua chiave API Doitong. Includila nella mutation GraphQL o negli header della REST API.

Importante: Mantieni la tua chiave API Doitong al sicuro e non esporla mai nel codice client-side. Effettua sempre le chiamate API dal tuo server backend.
// GraphQL Header
{
  "Authorization": "Bearer YOUR_API_KEY"
}

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

Guida rapida

Inizia a usare Hedra Lip Sync API in pochi minuti. Segui questi semplici passaggi per generare il tuo primo avatar.

Passaggio 1: Ottieni la tua chiave API

Registrati per un account Doitong e vai alla tua dashboard per generare una chiave API.

Passaggio 2: Effettua la tua prima richiesta

Usa uno degli esempi di codice qui sotto per effettuare la tua prima chiamata 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"
    }
  }
}

Prezzi

Hedra Lip Sync API utilizza un modello di prezzo basato su crediti. I crediti vengono consumati in base alla complessità e alla durata del contenuto generato.

Funzionalità Crediti Descrizione
Video breve 50-100 Crediti Fino a 30 secondi
Video lungo 200-500 Crediti Da 30 secondi a 2 minuti

Endpoint API

Hedra Lip Sync API è disponibile tramite il nostro endpoint GraphQL unificato.

Endpoint GraphQL

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

Endpoint REST

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

Parametri

Parametri disponibili per le richieste Hedra Lip Sync API:

Parametro Tipo Obbligatorio Descrizione
service Stringa Yes Identificatore del servizio: "hedra"
version Stringa No Model version: "hedra-1.0"
webhookUrl Stringa No URL per ricevere le notifiche di completamento

Formato della risposta

Tutte le risposte API seguono un formato coerente:

Risposta di successo

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

Risposta completata

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

Gestione degli errori

L'API utilizza codici di stato HTTP standard e restituisce messaggi di errore dettagliati.

Codici di errore comuni

Codice di stato Tipo di errore Descrizione
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

Formato risposta di errore

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

Webhook

Ricevi notifiche in tempo reale quando la generazione di avatar è completata.

Configurazione dei Webhook

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

Payload del Webhook

{
  "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
  }
}

Sicurezza dei Webhook

Tutte le richieste webhook includono un header di firma per la verifica:

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

Limiti di frequenza

Per garantire un utilizzo equo e la stabilità del sistema, si applicano i seguenti limiti di frequenza:

Piano Richieste/Minuto Processi simultanei Limite giornaliero
Gratis 10 1 100
Starter 30 3 1,000
Pro 60 10 10,000
Enterprise Personalizzato Personalizzato Illimitato
Header dei limiti di frequenza: Controlla gli header della risposta per lo stato attuale dei limiti:
  • X-RateLimit-Limit: Maximum requests per window
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Window reset timestamp

Best practice

1. Ottimizza i tuoi prompt

Scrivi prompt chiari e descrittivi per ottenere i migliori risultati:

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

2. Gestisci l'elaborazione asincrona

La generazione è asincrona. Implementa un sistema di polling o i webhook:

// 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. Recupero dagli errori

Implementa una logica di retry con backoff esponenziale:

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. Monitora l'uso dei crediti

Tieni traccia del consumo di crediti per evitare interruzioni:

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

Pronto per iniziare?

Unisciti a migliaia di sviluppatori che usano Hedra Lip Sync API per creare contenuti incredibili

Ottieni chiave API Vedi i prezzi