Short answer: For the Kling 4.0 API topic, the practical developer tools Kling documents today are its official MCP server at https://kling.ai/mcp and the kling command-line tool, both described in the official MCP and CLI guide. On the model side, the official Kling 4.0 user guide lists 3–30 seconds per generation, up to 15 references, up to 10 keyframes, prompts up to 8,000 tokens, two-channel stereo audio, multilingual prompting, and 720p or 1080p output. For creative planning, start with the Kling 4 overview, then explore text-to-video and image-to-video.
Last verified: 2026-10-21
What does "Kling 4.0 API" mean for developers?
Most developers searching for the Kling 4.0 API want one thing: a programmatic way to send prompts and assets to Kling and get video back without clicking through a web interface. Kling's official documentation covers two developer-friendly routes for that kind of automation. The first is the Model Context Protocol (MCP) server, which lets an AI agent or MCP-compatible client talk to Kling directly. The second is the Kling CLI, which brings the same workflow to the terminal and to shell scripts.
This guide focuses on those two routes and on the Kling 4.0 specifications Kling has officially published. Knowing both lets you design prompts, prepare assets, and structure an automated pipeline that fits the model's documented limits. For background on the model launch itself, read our Kling 4.0 release date guide.
How do I connect to Kling through MCP?
The official MCP and CLI guide gives https://kling.ai/mcp as the MCP connection URL. You add that URL to an MCP-compatible client, such as an AI coding assistant or agent framework, then sign in with your Kling account when prompted.
Step 1: Add the MCP server
Open your client's MCP settings and register a new remote server using the official URL. A typical configuration entry looks like this:
{
"mcpServers": {
"kling": {
"url": "https://kling.ai/mcp"
}
}
}
The exact file name and format depend on your client, so follow its own MCP documentation for where this entry belongs.
Step 2: Call who_am_i first
The official guide instructs users to call the who_am_i tool first. It returns account information along with the models and parameter specifications tied to your account. Treat this response as the source of truth for your session: it tells your agent which models it can pick and which parameter values it should send.
Step 3: Let the agent generate
Once discovery is done, describe the video you want in plain language. The agent maps your request to the parameters returned by who_am_i. Keep the returned capability details with your prompt notes, so every result can be reproduced later by a teammate.
How do I use the Kling CLI?
The same official guide documents the kling command-line tool for terminal workflows. Three commands cover the basics:
kling login
kling who_am_i
kling --help
kling loginsigns the CLI in to your Kling account.kling who_am_ishows your account and the models and parameters it exposes, mirroring the MCP discovery tool.kling --helplists supported commands and options, so you always work from the installed version's real syntax.
The CLI suits batch jobs, CI experiments, and scripts that loop over a folder of prompts. Record the CLI version, the discovered models, input assets, and output settings for each run. That habit makes it easy to tell a command configuration issue apart from a prompt issue.
Which Kling 4.0 specs are officially published?
The official Kling 4.0 user guide lists the following model specifications. Use them to plan prompts and asset sets before you automate anything.
| Spec | Official value | What it means for your workflow |
|---|---|---|
| Duration | 3–30 seconds per generation | Plan scenes as single clips up to 30 seconds |
| Resolution | 720p and 1080p | Choose 720p for drafts, 1080p for final delivery |
| References | Up to 15 combined assets | Bundle characters, products, and style images in one request |
| Keyframes | Up to 10 | Pin key moments to steer motion across the clip |
| Prompt length | Up to 8,000 tokens | Write detailed shot lists instead of one-line prompts |
| Audio | Two-channel stereo | Generate sound with the picture for ready-to-review clips |
| Language | Multilingual prompting | Write prompts and dialogue in your audience's language |
| Aspect ratios | 21:9, 16:9, 1:1, 9:16, Auto | Match cinema, landscape, square, or vertical formats |
Two of these specs matter most for automated pipelines. The 8,000-token prompt limit means an agent can pass a full shot list, character descriptions, and camera notes in one request. The 15-reference limit means a product team can keep brand assets consistent across a whole batch. For keyframe technique, see our Kling 4 keyframes guide, and for the faster variant, the Kling 4.0 Flash overview.
Which route should I choose: MCP or CLI?
| Route | Setup | Best for |
|---|---|---|
| Web interface | Sign in on kling.ai | Hands-on prompt prototyping |
| MCP | Add https://kling.ai/mcp to an MCP client, call who_am_i |
Agent-driven creative workflows |
| CLI | kling login, then kling who_am_i |
Scripts, batch jobs, terminal experiments |
Many teams use more than one. Creatives prototype in the web interface, an agent refines prompts through MCP, and an engineer moves the winning recipe into a CLI script. Because MCP and CLI share the same discovery step, the parameters stay consistent across both.
A practical developer workflow for Kling 4.0
- Define the creative task. Write the audience, subject, motion, camera direction, and ending. Use observable acceptance criteria rather than "make it look better."
- Run discovery. Call
who_am_ithrough MCP or the CLI and save the response with your project notes. - Prepare inputs within the specs. Keep duration between 3 and 30 seconds, references at 15 or fewer, keyframes at 10 or fewer, and prompts under 8,000 tokens.
- Prototype at 720p. Iterate quickly, then render approved prompts at 1080p.
- Log every run. Store the prompt revision, settings, assets, and result together so any clip can be reproduced.
- Script the winners. Move proven prompts into CLI scripts or agent instructions for repeatable batches.
Keep account credentials on your own machine or server and out of shared examples or public repositories. For plan and credit details, see our Kling AI plans and credits guide.
Frequently asked questions
How do I use Kling from code or an AI agent?
Kling's official guide documents an MCP server at https://kling.ai/mcp and a kling CLI. Add the MCP URL to an MCP-compatible client, or sign in with kling login in the terminal.
What does who_am_i do?
It returns your account information plus the models and parameter specifications tied to your account. The official guide recommends calling it first in any MCP or CLI session.
How long can a Kling 4.0 video be?
The official user guide lists 3–30 seconds per generation. See our Kling 4.0 video length guide for planning longer sequences.
What resolutions does Kling 4.0 support?
The official user guide lists 720p and 1080p, with aspect ratios of 21:9, 16:9, 1:1, 9:16, and Auto.
How many references and keyframes can I use?
Up to 15 combined reference assets, subject to individual type limits, and up to 10 keyframes per generation.
Does Kling 4.0 generate audio and support other languages?
Yes. The official user guide lists two-channel stereo audio and multilingual prompting, with prompts up to 8,000 tokens.
Sources
Try Kling AI Today
Turn your creative brief into a first clip. Explore text-to-video for prompt-led ideas or image-to-video to animate an existing visual. Try Kling AI for free with free credits on sign-up, enough for one video.
