> ## Documentation Index
> Fetch the complete documentation index at: https://docs.budgetpixel.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate video with Kling 4.0

> Kuaishou Kling 4.0, with generated sound (dialogue, music and sound effects described in the prompt). One model for text-to-video; keyframes (a first frame and an optional last frame); reference images of characters, products, places or styles; reference videos to take motion, camera work or style from; and editing a video (supply a `video` and describe the change: the output keeps its length and shape). Frames and reference images combine. Name inputs in the prompt by position: @image_1, @image_2, ... (first frame, last frame, then reference images) and @video_1, ... (the video to edit, then reference videos). 720p or 1080p at 24 fps, 3-30 seconds. Billed per second of output: 207 credits at 720p, 310 at 1080p (`resolution_pricing` in GET /v1/models). With any input video the rate is 124 at 720p and 186 at 1080p, for the output plus the longer of the input videos and the output: editing a 5-second clip bills 10 seconds. POST /v1/cost quotes any request exactly.

**Asynchronous.** Returns a job `id` (the video is not in this response). Poll [`GET /v1/videos/{id}`](/api-reference/videos/get-video-job-status) until `status` is `succeeded` — the video URL is in that response's `video_url`.

Examples, sample output and pricing: [Kling 4.0](https://budgetpixel.com/models/kling-4.0)

> **[Kling 4.0 on BudgetPixel](https://budgetpixel.com/models/kling-4.0)**
>
> Examples, prompts and pricing.


## OpenAPI

````yaml /openapi.yaml post /videos/kling-4.0
openapi: 3.1.0
info:
  contact:
    email: support@budgetpixel.com
    name: BudgetPixel Support
  description: >
    The BudgetPixel developer API for programmatic image, video, music and

    sound-effect generation.


    Generation is **asynchronous**: you create a job, then poll its status until
    it

    reaches a terminal state (`succeeded` / `failed`). You are charged in
    credits

    only on success — never for failures, timeouts, or content blocked before

    generation.


    **Authentication.** All requests require an API key sent as a bearer token:

        Authorization: Bearer bpx_live_xxx

    Create and manage keys from your BudgetPixel account dashboard. The
    developer

    API is available on **every paid plan**. On the **Free** plan, API keys can
    call

    the free library searches only: `GET /v1/stock/images`,

    `GET /v1/stock/sound-effects` and `GET /v1/stock/music`.


    **Pricing.** API usage is metered in credits at each model's published price

    (see `GET /v1/models`), and your plan's model discounts and active
    promotions

    apply to API charges exactly as they do on the web — `POST /v1/cost` quotes

    your discounted price. Pro and Ultra plans include a daily free-models

    allowance (a shared pool of free generations per day across qualified image

    models such as FLUX 2 Klein and Qwen-Image) that covers API

    requests too — the standard price applies once the day's pool is used.

    Other promotional free daily generations remain web/app-only. Failed

    generations are never charged.


    **Rate limits.** Requests are limited per minute: **600 requests/min per API

    key** and **1200 requests/min per source IP** (defaults; subject to tuning).

    Every response carries `X-RateLimit-Limit`, `X-RateLimit-Remaining`, and

    `X-RateLimit-Reset` (seconds until the window resets). Exceeding a limit

    returns HTTP `429` with a `Retry-After` header — wait that long before

    retrying. Rejected requests still count against the window, so a tight retry

    loop keeps you limited; back off instead. Generation jobs additionally have
    a

    per-plan concurrency cap (the same one as the web workshop), independent of

    these request limits. `POST /v1/uploads` also has a dedicated **60
    uploads/min

    per account** cap (it's free/unmetered) on top of these limits. Every `429`

    this API returns carries `Retry-After`, including a full concurrency queue

    (a suggested wait) and the monthly spend limit (seconds until the month

    resets).


    **Characters.** Write `@handle` in the prompt of an image or video
    generation to cast a

    character: one of the free BudgetPixel AI influencers (`@barry`, `@rosa`,
    ...) or a character

    of your own. Its picture and look go with the mention, so the same face
    appears in every

    post. `GET /v1/characters` lists the ones you can cast, `GET
    /v1/characters/{handle}` gives

    one in full with every picture, and `POST /v1/characters/recommend` picks
    influencers for a

    brief.


    **Output retention.** Generated files are kept for 24 hours after the job is

    created. Job status responses give the exact time as `expires_at`; after it,

    `expired` is `true` and no download URLs are returned.
  title: BudgetPixel API
  version: '2026-06-20'
servers:
  - description: Production
    url: https://api.budgetpixel.com/v1
security:
  - ApiKeyAuth: []
tags:
  - description: Account and credit balance
    name: Account
  - description: Discover available models and pricing
    name: Models
  - description: Upload input media for image/video generation
    name: Uploads
  - description: Image job status
    name: Images
  - description: FLUX image models
    name: Black Forest Labs
  - description: SeeDream image models
    name: Bytedance
  - description: Video job status
    name: Videos
  - description: Kuaishou Kling video models
    name: Kling
  - description: SeeDance video models
    name: ByteDance (SeeDance)
  - description: Music and sound-effect job status
    name: Audios
  - description: Music generation models
    name: Music
  - description: Text-to-sound-effect models (priced per second)
    name: Sound Effects
  - description: >-
      Image-to-3D models — a picture in, a textured 3D model (GLB, plus
      FBX/USDZ/STL on Meshy) out
    name: 3D Models
  - description: Format conversion for images, video, and audio
    name: Conversions
  - description: Publish posts to your BudgetPixel feed and enter clan themes
    name: Social
  - description: Cast BudgetPixel AI influencers and your own characters with @mentions
    name: Characters
  - description: Content moderation — NSFW rating and CSAM detection
    name: Moderation
  - description: Content classification — music genre detection
    name: Classification
  - description: >-
      Search the free stock image library — available on every plan, including
      Free
    name: Stock Images
  - description: >-
      Search the free sound effect library — available on every plan, including
      Free
    name: Stock Sound Effects
  - description: >-
      Search the free background music library — available on every plan,
      including Free
    name: Stock Music
  - description: >-
      Turn a video into a depth map video to guide other video models with its
      structure and motion
    name: Depth Maps
paths:
  /videos/kling-4.0:
    post:
      tags:
        - Kling
      summary: Generate video with Kling 4.0
      description: >-
        Kuaishou Kling 4.0, with generated sound (dialogue, music and sound
        effects described in the prompt). One model for text-to-video; keyframes
        (a first frame and an optional last frame); reference images of
        characters, products, places or styles; reference videos to take motion,
        camera work or style from; and editing a video (supply a `video` and
        describe the change: the output keeps its length and shape). Frames and
        reference images combine. Name inputs in the prompt by position:
        @image_1, @image_2, ... (first frame, last frame, then reference images)
        and @video_1, ... (the video to edit, then reference videos). 720p or
        1080p at 24 fps, 3-30 seconds. Billed per second of output: 207 credits
        at 720p, 310 at 1080p (`resolution_pricing` in GET /v1/models). With any
        input video the rate is 124 at 720p and 186 at 1080p, for the output
        plus the longer of the input videos and the output: editing a 5-second
        clip bills 10 seconds. POST /v1/cost quotes any request exactly.


        **Asynchronous.** Returns a job `id` (the video is not in this
        response). Poll [`GET
        /v1/videos/{id}`](/api-reference/videos/get-video-job-status) until
        `status` is `succeeded` — the video URL is in that response's
        `video_url`.


        Examples, sample output and pricing: [Kling
        4.0](https://budgetpixel.com/models/kling-4.0)
      operationId: createVideo_kling_4_0
      requestBody:
        content:
          application/json:
            schema:
              properties:
                aspect_ratio:
                  default: '16:9'
                  description: >-
                    Aspect ratio for text-to-video and reference-only jobs. A
                    first frame or a video to edit sets the shape and this is
                    ignored.
                  enum:
                    - '16:9'
                    - '9:16'
                    - '1:1'
                    - '21:9'
                  type: string
                end_image:
                  description: >-
                    Optional last frame, used together with `image`: the video
                    moves from the first frame to this one. Same input forms and
                    limits as `image`.
                  type: string
                  x-bpx-media: image
                image:
                  description: >-
                    Optional first frame (@image_1): the video starts from it
                    and takes its shape. Provide a public image URL, a data URI,
                    raw base64, or an uploaded-file URL from POST /v1/uploads.
                    JPG or PNG, at least 300px on each side, aspect ratio
                    between 2:5 and 5:2. Can't be combined with `video`.
                  type: string
                  x-bpx-media: image
                length_seconds:
                  default: 5
                  description: >-
                    Video length in seconds, any whole number from 3 to 30.
                    Ignored when editing a `video` (the output keeps its
                    length).
                  maximum: 30
                  minimum: 3
                  type: integer
                prompt:
                  description: >-
                    Text description of the video, including the sound you want,
                    or the change to make when editing a `video`. Name inputs by
                    position: @image_1, @image_2, ... (first frame, last frame,
                    then reference images) and @video_1, @video_2, ... (the
                    video to edit, then reference videos). Write `@handle` to
                    cast a character: a BudgetPixel AI influencer or one of your
                    own ([`GET
                    /v1/characters`](/api-reference/characters/list-characters-you-can-cast)).
                  type: string
                reference_images:
                  description: >-
                    Optional reference images of characters, products, places or
                    styles, named in the prompt as @image_N (numbered after
                    `image` and `end_image`). Up to 10 images in all, counting
                    `image` and `end_image`. Same input forms and limits as
                    `image`. No extra charge.
                  items:
                    type: string
                  maxItems: 10
                  type: array
                  x-bpx-media: image
                reference_videos:
                  description: >-
                    Optional reference videos to take motion, camera work or
                    style from, named in the prompt as @video_N (numbered after
                    `video`). MP4 or MOV, 3-30 seconds each, 700-4553 pixels on
                    each side, aspect ratio between 2:5 and 5:2, up to 100MB
                    each; up to 5 videos and 30 seconds in all, counting
                    `video`. Each item is a public video URL or an uploaded-file
                    URL from POST /v1/uploads. Any input video moves the job to
                    the video-input rate, billed for the output plus the longer
                    of the input videos and the output: see POST /v1/cost.
                  items:
                    type: string
                  maxItems: 5
                  type: array
                  x-bpx-media: video
                resolution:
                  default: 720p
                  description: >-
                    Output resolution, 720p or 1080p. Sets the price per second:
                    see `resolution_pricing` in GET /v1/models.
                  enum:
                    - 720p
                    - 1080p
                  type: string
                video:
                  description: >-
                    Optional video to EDIT (@video_1): describe the change in
                    `prompt`. The output keeps the clip's length and aspect
                    ratio, so `length_seconds` and `aspect_ratio` are ignored.
                    Same limits as `reference_videos`; can't be combined with
                    `image` or `end_image`. Billed at the video-input rate for
                    twice the clip's length in whole seconds (plus any reference
                    videos).
                  type: string
                  x-bpx-media: video
              required:
                - prompt
              type: object
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateVideoResponse'
          description: Job accepted.
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/TooManyRequests'
components:
  schemas:
    CreateVideoResponse:
      properties:
        characters:
          description: >-
            The characters the prompt cast with `@handle` mentions. Absent when
            none.
          items:
            $ref: '#/components/schemas/CharacterCredit'
          type: array
        id:
          description: Opaque job id — use it to poll status.
          type: string
        message:
          type: string
        model:
          type: string
        status:
          $ref: '#/components/schemas/JobStatus'
      type: object
    CharacterCredit:
      properties:
        handle:
          example: barry
          type: string
        name:
          example: Barry
          type: string
        official:
          description: '`true` for a BudgetPixel AI influencer.'
          type: boolean
        page_url:
          format: uri
          type: string
      type: object
    JobStatus:
      description: Lifecycle state. `succeeded`/`failed`/`timeout` are terminal.
      enum:
        - pending
        - starting
        - processing
        - completing
        - succeeded
        - failed
        - timeout
      type: string
    Error:
      properties:
        error:
          properties:
            code:
              description: Stable machine-readable code.
              example: model_not_available
              type: string
            message:
              type: string
            type:
              description: Error category.
              example: invalid_request_error
              type: string
          required:
            - type
            - code
            - message
          type: object
      required:
        - error
      type: object
    ModerationBlocked:
      description: >-
        Returned (with HTTP 400) when the input content moderation gate blocks a
        generation request. The block is a property of the request's prompt or
        input media — reword the prompt or change the input and retry. Branch on
        `restriction_reason`, which is stable and machine-readable.
      properties:
        error:
          description: Human-readable explanation of the block.
          type: string
        restriction_reason:
          description: Stable machine-readable block reason.
          enum:
            - input_csam
            - input_explicit_adult
            - input_upload_nudity
            - input_celebrity_likeness
            - strict_model_nsfw
          type: string
      required:
        - error
        - restriction_reason
      type: object
    QueueFull:
      description: |
        `429` body when your account already has as many jobs of this kind
        (image, video or audio) in flight as its concurrency cap allows. Submit
        the next job when one of your running jobs finishes.
      properties:
        active_jobs:
          description: Jobs of this kind in flight right now.
          type: integer
        code:
          enum:
            - queue_full
          type: string
        error:
          description: Human-readable message.
          type: string
        queue_full:
          enum:
            - true
          type: boolean
        queue_limit:
          description: Your concurrency cap for this kind of job.
          type: integer
        retry_after_seconds:
          description: Same value as the `Retry-After` header.
          type: integer
      required:
        - error
        - code
        - queue_full
        - queue_limit
        - active_jobs
        - retry_after_seconds
      type: object
  responses:
    BadRequest:
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/Error'
              - $ref: '#/components/schemas/ModerationBlocked'
      description: >-
        The request was malformed, referenced an unavailable model, or was
        blocked by input content moderation (moderation blocks carry a
        `restriction_reason` — see ModerationBlocked).
    Unauthorized:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      description: Missing or invalid API key.
    Forbidden:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
      description: >-
        Authenticated but not permitted (plan gate, ownership, account
        restriction). Content-moderation blocks are 400, not 403.
    TooManyRequests:
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/Error'
              - $ref: '#/components/schemas/QueueFull'
      description: >
        A limit was reached. Every `429` carries `Retry-After` (seconds). The

        per-minute rate limit, the upload limit and the hourly API post cap
        answer

        with the `Error` envelope, code `rate_limited`. The monthly spend limit
        answers with

        code `monthly_spend_limit_reached`, and its `Retry-After` counts down to
        the

        start of next month (raising the limit in the console clears it sooner).

        A full concurrency queue answers with the flat `QueueFull` body (3D
        jobs:

        the `Error` envelope with code `queue_full`); its `Retry-After` is a

        suggested wait, because a slot frees as soon as one of your running jobs

        finishes.
      headers:
        Retry-After:
          description: Seconds to wait before retrying.
          schema:
            minimum: 1
            type: integer
  securitySchemes:
    ApiKeyAuth:
      bearerFormat: bpx_live_*
      description: 'API key as a bearer token: Authorization: Bearer bpx_live_xxx'
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.