# Kling Avatar API Documentation > LLM-optimized documentation for Kling Avatar. Copy into your AI assistant for integration help. ## Overview **Model ID:** `kling-avatar` **Type:** Video Generation **Credit Cost:** 2 credits per second Kling Avatar V2 — turn a portrait plus an audio file into a talking avatar with audio-driven lip sync. Works on realistic humans, stylized characters, cartoons, and animals. ## Endpoint ``` POST https://pixeldojo.ai/api/v1/models/kling-avatar/run ``` ## Authentication All requests require an API key in the Authorization header: ``` Authorization: Bearer YOUR_API_KEY ``` Get your API key: https://pixeldojo.ai/api-platform/api-keys ## Input Parameters | Parameter | Type | Required | Default | Description | |-----------|------|----------|---------|-------------| | `image` | url | Yes | - | URL of the avatar reference image (.jpg/.jpeg/.png, ≤10MB, ≥300px, aspect ratio 1:2.5 to 2.5:1). | | `audio` | url | Yes | - | URL of the audio file that drives the avatar (.mp3/.wav/.m4a/.aac, ≤5MB). Determines output duration, and the charge: billed per second of this audio, measured server-side before the charge. A file that cannot be downloaded or measured, is not mp3/wav/m4a/aac, or is above 48 kHz or more than 2 channels, is refused with a 400 and not charged. | | `prompt` | string | No | - | Optional text prompt to refine actions, emotions, and camera movement. Complements the audio. | | `mode` | enum | No | std | Generation mode. "std" is the fast/standard tier at 2 credits per second of audio; "pro" yields sharper facial detail and smoother motion at 3.5 credits per second. (Options: std, pro) | ## Capabilities - Image to Video - Audio Generation ## Quick Start ### 1. Submit a Job ```bash curl -X POST "https://pixeldojo.ai/api/v1/models/kling-avatar/run" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "image": "https://...", "audio": "https://example.com/voice.mp3", "prompt": "a beauty blogger talking", "mode": "std" }' ``` **Response:** ```json { "jobId": "job_abc123...", "status": "pending", "statusUrl": "https://pixeldojo.ai/api/v1/jobs/job_abc123", "creditCost": 10, "creditsRemaining": 95 } ``` ### 2. Poll for Results ```bash curl "https://pixeldojo.ai/api/v1/jobs/job_abc123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` **Completed Response:** ```json { "jobId": "job_abc123...", "status": "completed", "output": { "video": "https://temp.pixeldojo.ai/..." }, "creditCost": 10 } ``` ## Python Example ```python import requests import time API_KEY = "YOUR_API_KEY" # Submit job response = requests.post( "https://pixeldojo.ai/api/v1/models/kling-avatar/run", headers={ "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" }, json={ "image": "https://...", "audio": "https://example.com/voice.mp3", "prompt": "a beauty blogger talking", "mode": "std" } ) job = response.json() job_id = job["jobId"] # Poll for completion while True: status_response = requests.get( f"https://pixeldojo.ai/api/v1/jobs/{'{job_id}'}", headers={"Authorization": f"Bearer {API_KEY}"} ) status = status_response.json() if status["status"] == "completed": print("Output:", status["output"]) break elif status["status"] == "failed": print("Error:", status.get("error")) break time.sleep(2) ``` ## JavaScript Example ```javascript const API_KEY = 'YOUR_API_KEY'; // Submit job const submitResponse = await fetch('https://pixeldojo.ai/api/v1/models/kling-avatar/run', { method: 'POST', headers: { 'Authorization': `Bearer ${API_KEY}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ "image": "https://...", "audio": "https://example.com/voice.mp3", "prompt": "a beauty blogger talking", "mode": "std" }) }); const job = await submitResponse.json(); // Poll for completion const pollForResult = async (jobId) => { while (true) { const statusResponse = await fetch(`https://pixeldojo.ai/api/v1/jobs/${jobId}`, { headers: { 'Authorization': `Bearer ${API_KEY}` } }); const status = await statusResponse.json(); if (status.status === 'completed') return status.output; if (status.status === 'failed') throw new Error(status.error); await new Promise(r => setTimeout(r, 2000)); } }; const output = await pollForResult(job.jobId); console.log('Output:', output); ``` ## Error Codes | Code | Status | Description | |------|--------|-------------| | `unauthorized` | 401 | Invalid or missing API key | | `insufficient_credits` | 402 | Not enough credits | | `invalid_request` | 400 | Invalid parameters | | `model_not_found` | 404 | Model ID not found | | `internal_error` | 500 | Server error | ## Links - **Full Documentation:** https://pixeldojo.ai/api-platform/kling-avatar - **API Keys:** https://pixeldojo.ai/api-platform/api-keys - **Buy Credits:** https://pixeldojo.ai/api-platform/buy-credits - **All Models:** https://pixeldojo.ai/api/v1/models - **OpenAPI Spec:** https://pixeldojo.ai/api/openapi