Authentication
Request API access and authenticate requests with the x-api-key header.
Get an API key
API key access is rolling out during v1. The browser generator uses explicitly claimed free credits and shows the cost before submission. For server-side API access, contact us with your use case and expected volume.
When we issue a key, store it somewhere safe. Treat it like a password: don't paste it into frontend code, public repos, shared screenshots, or analytics tools.
Use the key
Send it in the x-api-key header on every request:
curl 'https://kling-4.ai/api/ai-video/jobs' \
-H 'x-api-key: YOUR_API_KEY'const res = await fetch('https://kling-4.ai/api/ai-video/jobs', {
headers: { 'x-api-key': process.env.KLING_API_KEY! },
});
const { jobs } = await res.json();A request authenticated with a valid key acts as your approved workspace: jobs it creates are scoped to that key and draw from the quota assigned to it.
Requests without a key still work in the browser context (that's how the free web generator serves guests, via a guest cookie), but for server-side integrations always use an API key — guest identity is tied to cookies and won't survive across machines.
Keep it secret
- Call the API from your server, never from browser code — anyone reading your frontend bundle can lift the key.
- Put the key in an environment variable (
KLING_API_KEY), not in source control. - If you suspect a key is exposed, contact us so we can rotate it.