Kling AI API tutorial

How to authenticate, which endpoint to call, and the mistakes that cost people an afternoon.

Kling’s developer API is a task-based media API rather than a chat-completions endpoint. The official documentation describes API-key authentication with an Authorization: Bearer header and asynchronous jobs that you query by task ID (or receive via callback). No OpenAI-compatible chat endpoint is documented, so plan for a create-then-poll integration.

1. Create an account and an API key

2. Point your client at the right endpoint

API key authentication with an Authorization: Bearer <key> header; task-based (asynchronous) endpoints rather than a chat-completions API

3. A minimal working request

# Step 1: create a generation task (API key goes in the Authorization header)
# The official docs reviewed do not publish one global base URL;
# use the host shown in your Kling console / API reference.
curl -X POST "<BASE_URL>/image-to-video/kling-3.0" \
  -H "Authorization: Bearer $KLING_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image":"<image-url>","prompt":"slow dolly-in","duration":"5"}'

# Step 2: poll the task until status is succeeded
# (documented: query /tasks by task_id, external_task_id, or cursor)
curl "<BASE_URL>/tasks/<task_id>" -H "Authorization: Bearer $KLING_API_KEY"

4. Watch out for these

5. Controlling cost

6. Next steps

Facts on this page were checked against the official pages linked above on 2026-09-19. Prices and model IDs change frequently: confirm them on the vendor’s own pricing page before you rely on them.