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

# Flux 2 Klein - Create image from text

> Generate images with sub-second speed using FLUX.2 [klein], the fastest model in the FLUX.2 family by Black Forest Labs.

**Key Features:**
- Sub-second generation time
- Up to 4 reference images for style/subject transfer
- 10 preset aspect ratios with 1k or 2k resolution options
- Adjustable safety tolerance (0-5)
- Multiple output formats (PNG/JPEG)

**Use Cases:**
- Real-time applications requiring fast generation
- Style transfer with reference images
- Rapid prototyping and iteration
- High-volume image generation




## OpenAPI

````yaml post /v1/ai/text-to-image/flux-2-klein
openapi: 3.0.0
info:
  description: >-
    The Magnific API is your gateway to a vast collection of high-quality
    digital resources for your applications and projects. As a leading platform,
    it offers a wide range of graphics, including vectors, photos,
    illustrations, icons, PSD templates, and more, all curated by talented
    designers from around the world.
  title: Magnific API
  version: 1.0.0
servers:
  - description: B2B API Production V1
    url: https://api.magnific.com
security:
  - magnificApiKey: []
paths:
  /v1/ai/text-to-image/flux-2-klein:
    post:
      tags:
        - text-to-image
      summary: Flux 2 Klein - Create image from text
      description: >
        Generate images with sub-second speed using FLUX.2 [klein], the fastest
        model in the FLUX.2 family by Black Forest Labs.


        **Key Features:**

        - Sub-second generation time

        - Up to 4 reference images for style/subject transfer

        - 10 preset aspect ratios with 1k or 2k resolution options

        - Adjustable safety tolerance (0-5)

        - Multiple output formats (PNG/JPEG)


        **Use Cases:**

        - Real-time applications requiring fast generation

        - Style transfer with reference images

        - Rapid prototyping and iteration

        - High-volume image generation
      operationId: create_image_flux_2_klein
      requestBody:
        content:
          application/json:
            examples:
              required-params:
                $ref: '#/components/examples/request-flux-2-klein-required-params'
              all-params:
                $ref: '#/components/examples/request-flux-2-klein-all-params'
            schema:
              $ref: '#/components/schemas/ttif2k-request-content'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/create_image_from_text_flux_200_response'
          description: OK - Task created successfully
        '400':
          $ref: '#/components/responses/400-bad-request'
        '401':
          $ref: '#/components/responses/401-unauthorized'
        '500':
          $ref: '#/components/responses/500-internal-server-error'
        '503':
          $ref: '#/components/responses/503-service-unavailable'
components:
  examples:
    request-flux-2-klein-required-params:
      summary: Minimum required parameters
      value:
        prompt: a beautiful sunset over the ocean with dramatic clouds
    request-flux-2-klein-all-params:
      summary: Complete request with all parameters
      value:
        prompt: >-
          a futuristic cityscape at night with neon lights reflecting on wet
          streets, cyberpunk aesthetic
        aspect_ratio: widescreen_16_9
        resolution: 2k
        seed: 42
        safety_tolerance: 2
        output_format: png
        webhook_url: https://your-app.com/webhooks/flux-2-klein
  schemas:
    ttif2k-request-content:
      properties:
        prompt:
          description: >
            Text description of the image you want to generate.


            **FLUX.2 [klein]** is the fastest model in the FLUX.2 family,
            optimized for sub-second generation while maintaining high quality.
            It supports up to 4 reference images for style and subject transfer.


            **Tips for better results:**

            - Be specific about subjects, scenes, and visual details

            - Use reference images to guide style and composition

            - Combine prompt with reference images for best results


            **Examples:**

            - Simple: `"a mountain landscape at sunset"`

            - Detailed: `"portrait of a person in natural lighting, soft focus
            background"`

            - With style: `"abstract art in the style of watercolor painting"`
          example: a beautiful sunset over the ocean with dramatic clouds
          type: string
        aspect_ratio:
          default: square_1_1
          description: >
            Aspect ratio of the generated image. Determines the proportional
            relationship between width and height.


            | Aspect Ratio | Base Dimensions (1k) |

            |--------------|---------------------|

            | `square_1_1` | 1024 × 1024 |

            | `widescreen_16_9` | 1344 × 768 |

            | `social_story_9_16` | 768 × 1344 |

            | `portrait_2_3` | 832 × 1216 |

            | `traditional_3_4` | 960 × 1280 |

            | `vertical_1_2` | 704 × 1408 |

            | `horizontal_2_1` | 1408 × 704 |

            | `social_post_4_5` | 896 × 1152 |

            | `standard_3_2` | 1216 × 832 |

            | `classic_4_3` | 1280 × 960 |
          enum:
            - square_1_1
            - classic_4_3
            - traditional_3_4
            - widescreen_16_9
            - social_story_9_16
            - standard_3_2
            - portrait_2_3
            - horizontal_2_1
            - vertical_1_2
            - social_post_4_5
          example: square_1_1
          type: string
        resolution:
          default: 1k
          description: >
            Resolution multiplier for the generated image.


            - `1k`: Uses base dimensions (default)

            - `2k`: Doubles the base dimensions (capped at 2048px per side)


            Final dimensions are calculated by multiplying base dimensions by
            the resolution factor,

            then scaling proportionally if either dimension exceeds 2048px, and
            aligning to multiples of 16.
          enum:
            - 1k
            - 2k
          example: 1k
          type: string
        seed:
          description: >
            Random seed for reproducible results.


            **Use case:** Generate variations of the same image by using the
            same seed with modified prompts.


            **Valid range:** 0 to 4,294,967,295

            **Default:** Random seed (if not provided)
          example: 42
          maximum: 4294967295
          minimum: 0
          nullable: true
          type: integer
        input_image:
          description: >
            Base64-encoded reference image for **style/subject transfer**.


            **Supported formats:** JPEG, PNG

            **Use cases:**

            - Style transfer from reference images

            - Subject preservation

            - Composition guidance


            **Note:** Supports up to 4 reference images using `input_image`,
            `input_image_2`, `input_image_3`, and `input_image_4`.
          nullable: true
          type: string
        input_image_2:
          description: Second base64-encoded reference image for multi-image generation.
          nullable: true
          type: string
        input_image_3:
          description: Third base64-encoded reference image for multi-image generation.
          nullable: true
          type: string
        input_image_4:
          description: Fourth base64-encoded reference image for multi-image generation.
          nullable: true
          type: string
        safety_tolerance:
          default: 2
          description: >
            Content moderation tolerance level.


            **Range:** 0 to 5

            - **0:** Most strict filtering

            - **5:** Least strict filtering

            **Default:** 2


            **Note:** Lower values filter more content. Choose based on your
            application requirements.
          maximum: 5
          minimum: 0
          type: integer
        output_format:
          description: |
            Output image format.

            **PNG:** Lossless, supports transparency, larger file
            **JPEG:** Lossy, smaller file, no transparency
          enum:
            - jpeg
            - png
          nullable: true
          type: string
        webhook_url:
          description: >
            Optional callback URL that will receive asynchronous notifications
            whenever the task changes status. The payload sent to this URL is
            the same as the corresponding GET endpoint response, but without the
            data field.
          example: https://www.example.com/webhook
          format: uri
          type: string
      required:
        - prompt
      type: object
    create_image_from_text_flux_200_response:
      example:
        data:
          task_id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
          status: CREATED
      properties:
        data:
          $ref: '#/components/schemas/task'
      required:
        - data
      type: object
    task:
      example:
        task_id: 046b6c7f-0b8a-43b9-b35d-6489e6daee91
        status: CREATED
      properties:
        task_id:
          description: Task identifier
          format: uuid
          type: string
        status:
          description: Task status
          enum:
            - CREATED
            - IN_PROGRESS
            - COMPLETED
            - FAILED
          type: string
      required:
        - status
        - task_id
      type: object
    inline_object:
      example:
        message: message
        request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
      properties:
        request_id:
          description: >-
            Identifier of the HTTP request, the same value as the `X-Request-Id`
            response header. The API gateway adds it to every error response of
            the public API (`/v1` on `api.magnific.com` and `api.magnific.com`),
            so it is absent when a service is called directly, without the
            gateway. Include it when you contact support. It identifies the
            request, not a task.
          example: ak-97f5c07b9dd04324842b8f8b55a0edf1
          type: string
        message:
          type: string
      type: object
    inline_object_1:
      properties:
        request_id:
          description: >-
            Identifier of the HTTP request, the same value as the `X-Request-Id`
            response header. The API gateway adds it to every error response of
            the public API (`/v1` on `api.magnific.com` and `api.magnific.com`),
            so it is absent when a service is called directly, without the
            gateway. Include it when you contact support. It identifies the
            request, not a task.
          example: ak-97f5c07b9dd04324842b8f8b55a0edf1
          type: string
        message:
          example: Validation error
          type: string
        invalid_params:
          $ref: '#/components/schemas/inline_object_1_invalid_params'
      required:
        - invalid_params
        - message
      type: object
    inline_object_2:
      example:
        message: Internal Server Error
        request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
      properties:
        request_id:
          description: >-
            Identifier of the HTTP request, the same value as the `X-Request-Id`
            response header. The API gateway adds it to every error response of
            the public API (`/v1` on `api.magnific.com` and `api.magnific.com`),
            so it is absent when a service is called directly, without the
            gateway. Include it when you contact support. It identifies the
            request, not a task.
          example: ak-97f5c07b9dd04324842b8f8b55a0edf1
          type: string
        message:
          example: Internal Server Error
          type: string
      type: object
    inline_object_3:
      example:
        message: Service Unavailable. Please try again later.
        request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
      properties:
        request_id:
          description: >-
            Identifier of the HTTP request, the same value as the `X-Request-Id`
            response header. The API gateway adds it to every error response of
            the public API (`/v1` on `api.magnific.com` and `api.magnific.com`),
            so it is absent when a service is called directly, without the
            gateway. Include it when you contact support. It identifies the
            request, not a task.
          example: ak-97f5c07b9dd04324842b8f8b55a0edf1
          type: string
        message:
          example: Service Unavailable. Please try again later.
          type: string
      type: object
    inline_object_1_invalid_params:
      anyOf:
        - items:
            $ref: '#/components/schemas/inline_object_1_invalid_params_anyOf_inner'
          type: array
        - items:
            description: Name of the invalid parameter.
            example: image_size
            type: string
          type: array
        - additionalProperties:
            description: Reason the parameter is invalid, or the rejected value.
            example: The term can not be empty
            nullable: true
            type: string
          type: object
      description: >-
        The parameters that failed validation. Most endpoints send a list of
        objects with the `reason` and the parameter in `name`, `field` or both;
        it can be empty. A few send a list of parameter names, or an object that
        maps each parameter to its reason or to the rejected value.
    inline_object_1_invalid_params_anyOf_inner:
      properties:
        name:
          description: Name of the invalid parameter.
          example: page
          type: string
        field:
          description: >-
            Name of the invalid parameter, in the services that send `field`
            instead of `name`.
          example: page
          type: string
        reason:
          example: Parameter 'page' must be greater than 0
          type: string
      required:
        - reason
      type: object
  responses:
    400-bad-request:
      content:
        application/json:
          examples:
            invalid_page:
              summary: Parameter 'page' is not valid
              value:
                request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
                message: Parameter 'page' must be greater than 0
            invalid_query:
              summary: Parameter 'query' is not valid
              value:
                request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
                message: Parameter 'query' must not be empty
            invalid_filter:
              summary: Parameter 'filter' is not valid
              value:
                request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
                message: Parameter 'filter' is not valid
            generic_bad_request:
              summary: Bad Request
              value:
                request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
                message: Parameter ':attribute' is not valid
          schema:
            $ref: '#/components/schemas/inline_object'
        application/problem+json:
          examples:
            invalid_page:
              summary: Parameter 'page' is not valid
              value:
                request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
                message: Validation error
                invalid_params:
                  - name: page
                    field: page
                    reason: Parameter 'page' must be greater than 0
                  - name: per_page
                    field: per_page
                    reason: Parameter 'per_page' must be greater than 0
          schema:
            $ref: '#/components/schemas/inline_object_1'
      description: >-
        Bad Request - The server could not understand the request due to invalid
        syntax.
    401-unauthorized:
      content:
        application/json:
          examples:
            invalid_api_key:
              summary: API key is not valid
              value:
                request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
                message: Invalid API key
            missing_api_key:
              summary: API key is not provided
              value:
                request_id: ak-97f5c07b9dd04324842b8f8b55a0edf1
                message: Missing API key
          schema:
            $ref: '#/components/schemas/inline_object'
      description: >-
        Unauthorized - The client must authenticate itself to get the requested
        response.
    500-internal-server-error:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/inline_object_2'
      description: >-
        Internal Server Error - The server has encountered a situation it
        doesn't know how to handle.
    503-service-unavailable:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/inline_object_3'
      description: Service Unavailable
  securitySchemes:
    magnificApiKey:
      description: >
        Your Magnific API key. Required for authentication. [Learn how to obtain
        an API key](https://docs.magnific.com/quickstart)
      in: header
      name: x-magnific-api-key
      type: apiKey

````

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