--- name: kie-ai description: Make video (Veo, Kling), music (Suno) and images (Flux and more) through kie.ai, one key and one credit balance for many models. Use when the user wants a video clip, a song with vocals, or a model only kie.ai carries. Needs KIE_AI_API_KEY. --- # kie.ai Key: `KIE_AI_API_KEY`. Get one at https://kie.ai/api-key Every job is a task: create it, poll it, download the result. ## 1. Create a task Video (Veo 3.1): ```bash curl -s -X POST https://api.kie.ai/api/v1/jobs/createTask \ -H "Authorization: Bearer $KIE_AI_API_KEY" -H "Content-Type: application/json" \ -d '{"model":"veo-3-1","input":{"prompt":"A chef flips a pancake in slow motion","generation_type":"TEXT_2_VIDEO","aspect_ratio":"9:16","resolution":"720p","duration":8,"model":"veo3_fast"}}' ``` A song (Suno): ```bash curl -s -X POST https://api.kie.ai/api/v1/jobs/createTask \ -H "Authorization: Bearer $KIE_AI_API_KEY" -H "Content-Type: application/json" \ -d '{"model":"ai-music-api/generate","input":{"custom_mode":false,"instrumental":false,"model":"V6","prompt":"An upbeat acoustic song about a summer road trip","style":"indie folk"}}' ``` An image (Flux 2): ```bash curl -s -X POST https://api.kie.ai/api/v1/jobs/createTask \ -H "Authorization: Bearer $KIE_AI_API_KEY" -H "Content-Type: application/json" \ -d '{"model":"flux-2/flex-text-to-image","input":{"prompt":"A cozy cabin by a frozen lake at dusk","aspect_ratio":"16:9","resolution":"1K"}}' ``` Each returns `{"code":200,"data":{"taskId":"..."}}`. ## 2. Poll ```bash curl -s "https://api.kie.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" -H "Authorization: Bearer $KIE_AI_API_KEY" ``` `data.state` goes `waiting`, `queuing`, `generating`, then `success` or `fail`. Poll every 10 seconds; video can take several minutes. ## 3. Download On success, `data.resultJson` is a JSON string. Parse it and download every link in `resultUrls`. Files are deleted after 14 days. ## Notes - Errors still come back as HTTP 200. Check the body's `code`: 401 bad key, 402 out of credits, 422 bad input, 429 slow down. - Credits left: `curl -s https://api.kie.ai/api/v1/chat/credit -H "Authorization: Bearer $KIE_AI_API_KEY"`. - Every model and its input fields: https://kie.ai/market (Kling is `kling-3.0/video`).