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

# Kling Image Expansion

> [Core Function] Kling Image Expansion is an outpainting model. [Strengths] It intelligently extends the borders of an image (horizontal, vertical, or asymmetric) while matching the original style and context. [Best For] Highly recommended for: changing aspect ratios, extending landscapes, and filling out cropped photos. [Limitations] Do NOT use this model for inpainting or style transfer. [Routing] Use this specifically when the user asks to 'expand', 'extend', or 'uncrop' an image.



## OpenAPI

````yaml /model-api/kling/kling-i2i.json post /kling/kling-image-expansion
openapi: 3.1.0
info:
  description: The image-to-image models API from Kling AI.
  version: 1.0.0
  contact:
    name: Modellix Support
    email: support@modellix.ai
  title: Kling Image-to-Image Models API
servers:
  - url: https://api.modellix.ai/api/v1
    description: The image-to-image models API from Kling AI.
security:
  - bearerAuth: []
paths:
  /kling/kling-image-expansion:
    post:
      summary: Kling Image Expansion
      description: >-
        [Core Function] Kling Image Expansion is an outpainting model.
        [Strengths] It intelligently extends the borders of an image
        (horizontal, vertical, or asymmetric) while matching the original style
        and context. [Best For] Highly recommended for: changing aspect ratios,
        extending landscapes, and filling out cropped photos. [Limitations] Do
        NOT use this model for inpainting or style transfer. [Routing] Use this
        specifically when the user asks to 'expand', 'extend', or 'uncrop' an
        image.
      operationId: klingImageExpansionAsync
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/KlingImageExpansionRequest'
            examples:
              horizontal_panorama:
                summary: Horizontal panorama expansion
                value:
                  image: https://example.com/city-center.jpg
                  up_expansion_ratio: 0
                  down_expansion_ratio: 0
                  left_expansion_ratio: 1
                  right_expansion_ratio: 1
                  prompt: Extend cityscape with more buildings
                  'n': 2
              vertical_sky_ground:
                summary: Vertical expansion (sky and ground)
                value:
                  image: https://example.com/mountain.jpg
                  up_expansion_ratio: 0.8
                  down_expansion_ratio: 0.6
                  left_expansion_ratio: 0
                  right_expansion_ratio: 0
                  prompt: Add dramatic sky above and valley below
              uniform_expansion:
                summary: Uniform expansion on all sides
                value:
                  image: https://example.com/portrait.jpg
                  up_expansion_ratio: 0.5
                  down_expansion_ratio: 0.5
                  left_expansion_ratio: 0.5
                  right_expansion_ratio: 0.5
                  prompt: Expand background consistently
                  'n': 4
              asymmetric_expansion:
                summary: Asymmetric expansion
                value:
                  image: https://example.com/building.jpg
                  up_expansion_ratio: 1.5
                  down_expansion_ratio: 0.2
                  left_expansion_ratio: 0.3
                  right_expansion_ratio: 0.7
              base64_format:
                summary: Base64 image format
                value:
                  image: iVBORw0KGgoAAAANSUhEUgAAAAUA...
                  up_expansion_ratio: 0.5
                  down_expansion_ratio: 0.5
                  left_expansion_ratio: 0.5
                  right_expansion_ratio: 0.5
      responses:
        '200':
          description: Task submitted successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AsyncTaskResponse'
              example:
                code: 0
                message: success
                data:
                  status: pending
                  task_id: task-expansion-xyz789
                  model_id: model-123
                  get_result:
                    method: GET
                    url: https://api.modellix.ai/api/v1/tasks/task-expansion-xyz789
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '429':
          $ref: '#/components/responses/TooManyRequests'
        '500':
          $ref: '#/components/responses/InternalServerError'
components:
  schemas:
    KlingImageExpansionRequest:
      type: object
      required:
        - image
        - up_expansion_ratio
        - down_expansion_ratio
        - left_expansion_ratio
        - right_expansion_ratio
      properties:
        prompt:
          type: string
          description: Positive prompt to guide content generation in expanded areas
          maxLength: 2500
          example: Extend with natural landscape elements
        image:
          type: string
          description: >-
            Original image (URL or Base64 encoded, do not include 'data:' prefix
            for Base64). Supported formats: .jpg, .jpeg, .png. Maximum size:
            10MB. Minimum dimensions: 300x300px
          minLength: 1
          example: https://example.com/original.jpg
        up_expansion_ratio:
          type: number
          format: float
          description: >-
            Upward expansion ratio, based on original image height. Range:
            0.0-2.0
          minimum: 0
          maximum: 2
          example: 0.5
        down_expansion_ratio:
          type: number
          format: float
          description: >-
            Downward expansion ratio, based on original image height. Range:
            0.0-2.0
          minimum: 0
          maximum: 2
          example: 0.5
        left_expansion_ratio:
          type: number
          format: float
          description: >-
            Leftward expansion ratio, based on original image width. Range:
            0.0-2.0
          minimum: 0
          maximum: 2
          example: 0.5
        right_expansion_ratio:
          type: number
          format: float
          description: >-
            Rightward expansion ratio, based on original image width. Range:
            0.0-2.0
          minimum: 0
          maximum: 2
          example: 0.5
        'n':
          type: integer
          description: Number of images to generate per request
          default: 1
          minimum: 1
          maximum: 9
          example: 1
      description: >-
        Note: All four expansion ratio parameters are required. Set to 0.0 for
        directions that do not need expansion. This model does NOT support:
        negative_prompt, aspect_ratio, resolution, image_fidelity,
        image_reference, or human_fidelity parameters.
    AsyncTaskResponse:
      type: object
      required:
        - code
        - message
        - data
      properties:
        code:
          type: integer
          description: Response code, 0 indicates success
          example: 0
        message:
          type: string
          description: Response message
          example: success
        data:
          type: object
          required:
            - status
            - task_id
            - model_id
          properties:
            status:
              type: string
              enum:
                - pending
                - processing
              description: Task status
              example: pending
            task_id:
              type: string
              description: Unique task identifier
              example: task-abc123
            model_id:
              type: string
              description: Model ID
              example: model-123
            get_result:
              type: object
              description: API information to query the task result
              properties:
                method:
                  type: string
                  description: HTTP method
                  example: GET
                url:
                  type: string
                  description: Full URL to query the task result
                  example: https://api.modellix.ai/api/v1/tasks/task-abc123
          description: Detailed data about the submitted asynchronous task.
    ErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: integer
          description: Error code (equals HTTP status code)
          example: 400
        message:
          type: string
          description: 'Error message in format ''Category: detail'''
          example: 'Invalid parameters: parameter ''image'' is required'
  responses:
    BadRequest:
      description: Invalid request parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 400
            message: 'Invalid parameters: parameter ''image'' is required'
    Unauthorized:
      description: Unauthorized - Invalid or missing API Key
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 401
            message: 'Authentication failed: invalid API key'
    TooManyRequests:
      description: Too many requests - Rate limit exceeded
      headers:
        X-RateLimit-Limit:
          description: Maximum requests per minute
          schema:
            type: integer
            example: 100
        X-RateLimit-Remaining:
          description: Remaining quota in current window
          schema:
            type: integer
            example: 0
        X-RateLimit-Reset:
          description: Rate limit window reset time (Unix timestamp)
          schema:
            type: integer
            example: 1704067260
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 429
            message: >-
              Rate limit exceeded: 100 requests per minute, retry after 60
              seconds
    InternalServerError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          example:
            code: 500
            message: Internal server error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: 'API Key authentication. Format: `Bearer YOUR_API_KEY`.'

````