Skip to content

About

Kling 4 API and Kling 4.0 API SDK and examples, with Kling 4 Flash API and Kling 4.0 Flash API availability tracking for MuAPI.

Topics

Resources

Stars

57 stars

Watchers

2 watching

Forks

Latest commit

 

History

26 Commits

Folders and files

Repository files navigation

Kling 4 API & Kling 4.0 Flash API

Python SDK and practical video-generation examples for MuAPI

▶ Watch: How to Access Kling 4.0 API - Best Alternative to Seedance 2

Powered by MuAPI License: MIT Python 3.9+ Text-to-video Image-to-video

Quick start · Python SDK · Prompt guide · API routes · FAQ

Use a small Python client to submit text-to-video or image-to-video jobs through MuAPI's Kling 4 API, then poll for the result. This repository includes setup instructions, Python and cURL examples, and original prompt recipes for product shots, social clips, and cinematic scenes. It covers the Kling 4 API and tracks availability for the Kling 4.0 API, Kling 4 Flash API, and Kling 4.0 Flash API search intents. See the status below before integrating: Flash access in the Kling app does not by itself mean a public API endpoint is available.

Availability: Kling 4 API access is live on MuAPI today. MuAPI serves Kling 4 requests through its existing, production Kling video pipeline while Kuaishou completes its own staged Kling 4.0 rollout (see Kling 4.0 announcement status below), and will transparently move these same routes onto Kuaishou's native Kling 4.0 models as direct access opens up. Check the live MuAPI Kling 4 page and API reference for current parameters and response formats.

Contents

Kling 4.0 announcement status

Kuaishou announced Kling 4.0 on September 28, 2026. Per that announcement, claimed capabilities include:

  • Single-pass clips up to 30 seconds, double Kling 3.0's 15-second Director Mode cap
  • A much higher reference ceiling — up to 50 text/image/video reference files, versus roughly a dozen previously
  • Up to 10 keyframes for guiding continuity across connected shots
  • Directed camera moves (push-in, orbit, tracking shots)
  • Native audio rendered together with the picture instead of added afterward

A lite version is rolling out first to Kling's own annual subscribers, with a full release targeted for October 2026. These are Kuaishou's own claims from that announcement. MuAPI's Kling 4 API is available now and currently runs on MuAPI's existing Kling video pipeline (the routes documented below); MuAPI will move these endpoints onto Kuaishou's native Kling 4.0 models and publish updated limits and pricing as direct access opens up beyond Kuaishou's own lite/annual-subscriber rollout.

Kling 4.0 Flash API status

As of September 29, 2026, this repository does not document a callable Kling 4.0 Flash API endpoint, and MuAPI's live Kling routes listed below do not identify themselves as Flash routes. Kling 4.0 Flash availability in the Kling app or for selected subscribers should not be treated as confirmation of public API access. Do not use the standard or Pro routes in this SDK expecting Flash-specific model behavior.

For current API availability, model identifiers, parameters, and pricing, check the MuAPI Kling 4 page and the live API reference. This status section will need updating when a documented Flash endpoint becomes available.

The terms Kling 4 API and Kling 4.0 API are often used for the broader Kling 4 generation API, while Kling 4 Flash API and Kling 4.0 Flash API refer to Flash-specific access. This SDK documents the currently listed MuAPI Standard and Pro routes; it does not claim those routes invoke Flash.

What is included

  • A lightweight KlingAPI Python client for submitting jobs and polling results.
  • Text-to-video and image-to-video examples in Python.
  • A cURL example for submitting a generation request.
  • A separate prompt recipe guide with structured examples and iteration tips.
  • Direct calls to the MuAPI API, with the API key sent in the x-api-key header.

Quick start

Requirements

  • Python 3.9 or newer
  • A MuAPI account and API key
  • For image-to-video, an image URL that the generation service can access

Install

git clone https://github.com/Anil-matcha/Kling-4.0-Flash-API.git
cd Kling-4.0-Flash-API
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env

Add your key to .env:

MUAPI_API_KEY=your_muapi_api_key

The client loads this value at startup. You can also pass api_key directly when constructing KlingAPI.

Text-to-video

Describe the scene and the main movement in the prompt. Optional fields such as duration and aspect_ratio are passed through to the selected provider route; confirm accepted values in the live API documentation.

from kling_api import KlingAPI

api = KlingAPI()
job = api.text_to_video(
    "A red fox crosses a snowy forest clearing at dawn. "
    "The camera tracks slowly from left to right and settles as the fox looks back.",
    tier="pro",
    aspect_ratio="16:9",
    duration=5,
)

result = api.wait_for_completion(job["request_id"])
print(result)

Choose tier="standard" or tier="pro". The initial response contains a request_id used to check the result.

Image-to-video

Use image-to-video when a supplied image should establish the opening composition, product, or subject. Tell the model what should move and what should remain stable.

job = api.image_to_video(
    prompt=(
        "Preserve the flowers, vase shape, and window framing. Add a gentle breeze "
        "that moves the petals while the camera makes a slow push toward the vase."
    ),
    image_url="https://example.com/garden.jpg",
    tier="pro",
    aspect_ratio="16:9",
    duration=5,
)

result = api.wait_for_completion(job["request_id"])
print(result)

The image URL must be publicly accessible to the generation service. Private localhost URLs and files behind a login will not be fetchable by the provider.

Prompt recipes

A useful prompt is a compact directing note. Include the subject, setting, one primary action, a camera move, and the details that must stay consistent. For image-to-video, assign the input image a clear role and avoid requesting changes to details it should preserve.

Product reveal

Create a 7-second product shot of one amber glass bottle on a stone counter.
Keep its label, cap, and proportions unchanged. Morning light falls from the left.
The camera makes a slow quarter-circle move as condensation runs down the glass.
Finish with the bottle facing camera and the label in focus. No extra products or text.

Vertical social clip

Create an 8-second vertical home-gardening clip. A person in a plain green apron
turns one basil pot toward the window and points to a new leaf. Use a steady,
handheld phone-camera feel and natural daylight. Keep the same hands, apron, pot,
and plant. End with a clear close view of the leaf; no captions or brand marks.

Cinematic beat

At a quiet station at night, one traveler in a rust-colored coat waits beside an
empty track. Begin wide, with wet platform tiles reflecting cool blue light. A
distant train light appears; the traveler turns toward it. Track slowly from
behind and settle over the traveler's shoulder. Keep the same person and coat;
avoid other people and abrupt cuts.

These examples are original to this repository. The prompt categories and production-planning approach were informed by flaqai/awesome-kling-4-0; its prompt text and media are not reproduced here.

Explore more examples in the Kling video prompt recipe guide, including image-to-video usage and an iteration checklist.

cURL workflow

The repository includes a ready-to-run request example:

export MUAPI_API_KEY="your_muapi_api_key"
bash examples/curl.sh

The submission response includes a request_id. Poll it with:

curl "https://api.muapi.ai/api/v1/predictions/REQUEST_ID/result" \
  --header "x-api-key: ${MUAPI_API_KEY}"

Supported routes

Workflow MuAPI endpoint
Kling 4 Pro text-to-video POST /kling-v3.0-pro-text-to-video
Kling 4 Pro image-to-video POST /kling-v3.0-pro-image-to-video
Kling 4 Standard text-to-video POST /kling-v3.0-standard-text-to-video
Kling 4 Standard image-to-video POST /kling-v3.0-standard-image-to-video
Check a generation result GET /predictions/{request_id}/result

Base URL: https://api.muapi.ai/api/v1. These are MuAPI's live Kling 4 routes today, served through MuAPI's existing Kling video pipeline (the route names still reference the underlying v3.0 model versioning — see Kling 4.0 announcement status). The client route names and forwarded options are visible in kling_api.py. Routes and accepted fields may change as MuAPI moves onto Kuaishou's native Kling 4.0 models; consult the MuAPI API reference before production use.

Troubleshooting

Symptom Check
Set MUAPI_API_KEY error Add MUAPI_API_KEY to .env, or pass api_key to KlingAPI(...).
HTTP 401 or 403 Confirm the key is active and has access to the selected route.
HTTP 400 Review required fields, parameter names, duration, and aspect-ratio values for the selected route.
Image request fails Confirm the image URL is public, loads without cookies, and points directly to an image.
Polling times out Check the provider task status and request ID; increase timeout if the job is still processing.
Route not found Compare the endpoint in kling_api.py with the current MuAPI API reference.

FAQ

Is Kling 4 available on MuAPI?

Yes. Kling 4 API access is live on MuAPI today, served through MuAPI's existing Kling video pipeline (see Kling 4.0 announcement status). MuAPI will move these same endpoints onto Kuaishou's native Kling 4.0 models as direct access opens up beyond Kuaishou's own staged rollout.

Is there a Kling 4.0 Flash API endpoint?

This repository does not currently provide a verified Kling 4.0 Flash API endpoint. The available MuAPI routes are the standard and Pro workflows in Supported routes; confirm the live API reference for any newer Flash model ID or route before building an integration.

Does the Kling 4 API support Kling 4 Flash?

The current Kling 4 API routes in this repository do not identify a Flash model. That applies to searches for both “Kling 4 Flash API” and “Kling 4.0 Flash API”: check MuAPI's live API reference for an explicitly documented Flash route before sending production requests.

What does tier accept?

The Python wrapper accepts standard or pro and maps those values to the corresponding text-to-video or image-to-video route.

Which optional parameters can I pass?

The client forwards additional keyword arguments to MuAPI. Accepted fields depend on the chosen route, so use the live API reference rather than assuming every parameter works for every model.

Where can I find more prompt ideas?

Start with the prompt recipe guide. For a larger community collection, see flaqai/awesome-kling-4-0; this SDK repository contains independently written examples rather than copied recipes.

Can I use generated videos commercially?

The SDK license covers this repository's code. Rights and usage terms for generated outputs, input images, people, brands, and the generation service are separate; review the relevant provider terms before publishing or commercial use.

Related projects

License

This project is released under the MIT License.

About

Kling 4 API and Kling 4.0 API SDK and examples, with Kling 4 Flash API and Kling 4.0 Flash API availability tracking for MuAPI.

Topics

Resources

Stars

57 stars

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages