klingapis.comQuickstart for Kling pipelines
Quickstart for Kling pipelines
Get your uncensored text API key and start generating scripts, prompts, and captions for your Kling video pipeline in minutes.
Base URL & Authentication
Use https://api.klingapis.com/v1 as your base URL. It works with any OpenAI-compatible SDK. Send your API key in the Authorization header as a Bearer token. You get one key per account, visible immediately after signup. Regenerate it anytime to revoke the old one.
Model ID: Always send "uncensored" in your requests. It is an open-weight model tuned for lawful adult use without content refusals.
First Request
Send a POST request to /v1/chat/completions to generate text. The API accepts standard OpenAI payload formats. It returns text output suitable for scripts, captions, or prompt generation.
Context Window: The model supports up to 64,000 tokens (input + output). Keep your prompts concise to maximize output length.
Hard Limit: Requests containing sexual content involving minors are always blocked.
curl https://api.klingapis.com/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "uncensored",
"messages": [{"role": "user", "content": "Write a blunt product review of a cheap VPN."}]
}'
Python SDK
Use the official openai Python library. Configure the base URL and API key in your client initialization. This ensures compatibility with existing Kling pipeline scripts.
The API supports tool calling, allowing you to structure outputs for downstream processing. Use this for extracting data from transcripts or formatting script sections.
from openai import OpenAI
client = OpenAI(base_url="https://api.klingapis.com/v1", api_key="YOUR_KEY")
resp = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Summarise this thread without softening it."}],
)
print(resp.choices[0].message.content)
Node SDK
Initialize the OpenAI Node SDK with the same base URL. This integrates directly into your Node.js workflows for real-time captioning or prompt enhancement.
The uncensored model handles controversial or adult topics without standard refusals, making it ideal for diverse creative pipelines. Ensure your payload stays under 8 MB.
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.klingapis.com/v1", apiKey: process.env.API_KEY });
const resp = await client.chat.completions.create({
model: "uncensored",
messages: [{ role: "user", content: "Draft a villain monologue for my game." }],
});
console.log(resp.choices[0].message.content);
Streaming Responses (SSE)
Enable streaming by setting stream: true in your request. The API returns Server-Sent Events (SSE) for real-time token delivery. This reduces perceived latency for long scripts or detailed captions.
Handle SSE events in your client to update the UI or log output incrementally. This is critical for user-facing applications where waiting for full completion is unacceptable.
stream = client.chat.completions.create(
model="uncensored",
messages=[{"role": "user", "content": "Tell the story in second person."}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="", flush=True)
Rate Limits & Limits
Rate Limit: 300 requests per minute per key. Exceeding this returns a 429 error.
Errors: 401 indicates an invalid or expired key. 402 means your prepaid credit is exhausted.
Body Limit: Requests must be under 8 MB. Pay-as-you-go credits never expire. Top-up from $10, with bonuses at $50 (+5%) and $100 (+10%).
API facts in one table
Use this table to decide whether the API fits your project before you buy credit.
| Spec | Value |
|---|---|
| Protocol | OpenAI Chat Completions schema; official openai SDKs work unchanged |
| Methods | POST /v1/chat/completions · GET /v1/models |
| Base URL | https://api.klingapis.com/v1 |
| Model ID | uncensored |
| Authentication | Authorization: Bearer YOUR_KEY |
| Function calling | Yes — tools, tool_choice; replies carry tool_calls, also when streaming; send results back as role: tool |
| Streaming | Yes — server-sent events; the last chunk carries token usage |
| Max output | up to 16,000 tokens per request (default 2,048) |
| JSON mode | response_format: {"type": "json_object"} |
| Sampling parameters | temperature, top_p, stop, seed, presence_penalty, frequency_penalty |
| Context window | 64,000 tokens, input and output combined |
| Request size | up to 8 MB per request |
| Parallel requests | 8 requests at the same time per key |
| Rate limit | 300 requests per minute per key |
| Response headers | X-Request-Id, X-Balance-USD, X-RateLimit-Limit-Requests, X-RateLimit-Limit-Concurrency |
| Bonus credit | +5% from $50, +10% from $100 |
| Token prices | input $0.25 / 1M tokens, output $1.00 / 1M tokens |
| How you pay | pay as you go from prepaid credit; nothing is charged for failed or refused requests |
| Top-up | crypto: USDT on TRON or USDC on Base, $10–$500, any whole sum |
| Credit expiry | no monthly fee; paid credit does not expire |
| Trial credit | $0.50 for 7 days, no card |
| Key management | one active key per account; a new key replaces the old one |
| Sign-in | Google or e-mail and password |
| Content | adult content allowed; sexual content involving minors is refused |
Error reference
The type field is stable, the message is for humans. Errors cost nothing.
| HTTP | Type | What to do |
|---|---|---|
400 | bad_request | invalid JSON, empty messages, bad parameter, or prompt + max_tokens over the window — fix and resend |
401 | missing_key · invalid_key · key_revoked | no key, wrong key, or a key replaced by a newer one |
402 | no_credit | balance is empty — top up, requests resume at once |
403 | content_blocked | sexual content involving minors — refused, not billed |
404 | not_found | unknown endpoint |
413 | request_too_large | request body larger than 8 MB |
429 | rate_limited · concurrency | over 300/min or 8 parallel — back off and retry |
503 | upstream_busy | model busy — retry in a few seconds |
Questions and answers
Does this API generate video or images?
No. This is a text-only API. It generates text for scripts, prompts, and captions that you can use in your Kling video or image pipeline. It does not handle media generation itself.
Is the uncensored model GPT or Claude?
No. It is an open-weight model run on our own GPU servers. It is not GPT, Claude, Gemini, Grok, or DeepSeek. It is tuned specifically for fewer content refusals.
How do I pay for the API?
Use prepaid credits. Top up from $10 by crypto (USDT or USDC). Credits never expire. There is no monthly fee or subscription. You pay per token used.
Your key is one form away
Create an account, copy the key, change the base URL. That is the whole setup.