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

# Flux kontext Image to Image

> Create high quality image from text using FLUX Kontext model.

<img src="https://mintcdn.com/mod/i8dYICFkuz1vpdrI/images/image-generation/flux/assets/images/Text-to-image-1-a226305d52e197b14c4cc0b1534ea06c.jpg?fit=max&auto=format&n=i8dYICFkuz1vpdrI&q=85&s=bcb4615889963132d06bd5293e8e6684" alt="Text to image endpoint result" width="691" height="518" data-path="images/image-generation/flux/assets/images/Text-to-image-1-a226305d52e197b14c4cc0b1534ea06c.jpg" />

## Request

Make a `POST` request to below endpoint and pass the required parameters as a request body.

```curl curl theme={null}
--request POST 'https://modelslab.com/api/v6/images/img2img' \
```

## Body

```json json theme={null}
{
  "key": "your_api_key",
  "init_image": "https://assets.modelslab.ai/generations/197fdb87-3d94-4a3d-bf2b-6c1b2a73a623",
  "init_image_2": "https://pub-3626123a908346a7a8be8d9295f44e26.r2.dev/generations/output.jpg",
  "prompt": "a girl from image one holding the can from image two",
  "negative_prompt": "(worst quality:2), (low quality:2), (normal quality:2), (jpeg artifacts), (blurry), (duplicate), (morbid), (mutilated), (out of frame), (extra limbs), (bad anatomy), (disfigured), (deformed), (cross-eye), (glitch), (oversaturated), (overexposed), (underexposed), (bad proportions), (bad hands), (bad feet), (cloned face), (long neck), (missing arms), (missing legs), (extra fingers), (fused fingers), (poorly drawn hands), (poorly drawn face), (mutation), (deformed eyes), watermark, text, logo, signature, grainy, tiling, censored, nsfw, ugly, blurry eyes, noisy image, bad lighting, unnatural skin, asymmetry",
  "model_id": "flux-kontext-dev",
  "num_inference_steps": "28",
  "safety_checker": true,
  "strength": "0.5",
  "guidance": "2.5",
  "enhance_prompt": null
}
```


## OpenAPI

````yaml POST /images/img2img
openapi: 3.1.0
info:
  title: ModelsLab Image Editing API
  description: >-
    Image editing endpoints for ModelsLab API including background removal,
    super resolution, face generation, fashion try-on, and various image
    manipulation tools
  license:
    name: MIT
  version: 6.0.0
servers:
  - url: https://modelslab.com/api/v6
    description: Image Editing API v6 server
security: []
paths:
  /images/img2img:
    post:
      summary: Generate image from text and reference images (Flux Kontext Model)
      description: >-
        The Image to Image API is used to create high-quality images from text
        prompts combined with reference images using the Flux Kontext model.
        This endpoint allows you to blend elements from multiple input images
        guided by text descriptions.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FluxKontextImageToImageRequest'
      responses:
        '200':
          description: Flux Kontext Image to Image generation response
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: >-
                      #/components/schemas/FluxKontextImageGenerationSuccessResponse
                  - $ref: >-
                      #/components/schemas/FluxKontextImageGenerationProcessingResponse
                  - $ref: >-
                      #/components/schemas/FluxKontextImageGenerationErrorResponse
        '400':
          $ref: '#/components/responses/StandardErrorResponse'
        '401':
          $ref: '#/components/responses/StandardErrorResponse'
        '500':
          $ref: '#/components/responses/StandardErrorResponse'
components:
  schemas:
    FluxKontextImageToImageRequest:
      type: object
      required:
        - key
        - model_id
        - prompt
        - init_image
      properties:
        key:
          type: string
          description: Your API Key used for request authorization.
        model_id:
          type: string
          description: >-
            The ID of the model. Must be 'flux-kontext-dev' for Flux Kontext
            model.
          default: flux-kontext-dev
        prompt:
          type: string
          description: >-
            A text description of the things you want in the generated image,
            referencing elements from the input images.
        negative_prompt:
          type: string
          description: >-
            Items you don't want in the image. Helps exclude unwanted elements,
            artifacts, or styles from the generation.
        init_image:
          type: string
          format: uri
          description: >-
            URL of the primary reference image to use as a base for the
            generation.
        init_image_2:
          type: string
          format: uri
          description: >-
            URL of the secondary reference image to incorporate elements from.
            Optional for single-image workflows.
        safety_checker:
          type: boolean
          description: Whether to run the safety checker
        num_inference_steps:
          oneOf:
            - type: integer
              minimum: 1
              maximum: 50
            - type: string
              pattern: ^[1-9][0-9]*$
          default: '28'
          description: >-
            The number of denoising steps. Values typically range from 1 to 50.
            Can be provided as integer or string.
        strength:
          oneOf:
            - type: number
              minimum: 0
              maximum: 1
            - type: string
              pattern: ^0(\.[0-9]+)?$|^1(\.0+)?$
          default: '0.5'
          description: >-
            Controls how much the output image should resemble the input image.
            0.0 means identical to input, 1.0 means completely different. Can be
            provided as number or string.
        guidance:
          oneOf:
            - type: number
              minimum: 0
              maximum: 20
            - type: string
              pattern: ^([0-9]*[.])?[0-9]+$
          default: '2.5'
          description: >-
            Scale for classifier-free guidance. Higher values make the model
            follow the prompt more closely. Can be provided as number or string.
        enhance_prompt:
          type: boolean
          nullable: true
          description: >-
            Enhance prompts for better results. Set to null to use model
            defaults.
        width:
          type: integer
          default: 512
          maximum: 1024
          description: The width of the output image in pixels. Maximum value is 1024.
        height:
          type: integer
          default: 512
          maximum: 1024
          description: The height of the output image in pixels. Maximum value is 1024.
        samples:
          type: integer
          default: 1
          maximum: 4
          description: The number of images to be returned in response. Maximum value is 4.
        seed:
          oneOf:
            - type: integer
            - type: 'null'
          description: >-
            Used to reproduce results. The same seed will generate the same
            image again. Pass null for a random number.
        base64:
          type: boolean
          default: false
          description: Get response as a base64 string.
        webhook:
          type: string
          format: uri
          description: URL to receive a POST API call once image generation is complete.
        track_id:
          type: string
          description: >-
            This ID is returned in the response to the webhook API call and is
            used to identify the webhook request.
        temp:
          type: boolean
          default: false
          description: Create a temporary image link valid for 24 hours.
    FluxKontextImageGenerationSuccessResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - success
          description: Status of the image generation.
        generationTime:
          type: number
          description: Time taken to generate the image in seconds.
        id:
          type: integer
          description: Unique identifier for the image generation request.
        output:
          type: array
          items:
            type: string
            format: uri
          description: Array of generated image URLs.
        proxy_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of proxy image URLs.
        meta:
          type: object
          description: Metadata about the image generation including all parameters used.
          additionalProperties: true
        nsfw_content_detected:
          type: boolean
          description: Indicates if NSFW content was detected in the generated image.
    FluxKontextImageGenerationProcessingResponse:
      type: object
      properties:
        status:
          type: string
          enum:
            - processing
          description: Status of the image generation.
        tip:
          type: string
          description: Information about faster processing options.
        eta:
          type: number
          description: Estimated time for completion in seconds.
        message:
          type: string
          description: Processing status message.
        fetch_result:
          type: string
          format: uri
          description: URL to fetch the result when processing.
        id:
          type: integer
          description: Unique identifier for the image generation request.
        output:
          type: array
          items:
            type: string
          description: Empty array during processing.
        meta:
          type: object
          description: Metadata about the image generation including all parameters used.
          additionalProperties: true
        future_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of future image URLs for queued requests.
        proxy_links:
          type: array
          items:
            type: string
            format: uri
          description: Array of proxy image URLs.
    FluxKontextImageGenerationErrorResponse:
      type: object
      required:
        - status
        - message
      properties:
        status:
          type: string
          enum:
            - error
        message:
          type: string
          description: Error message description.
  responses:
    StandardErrorResponse:
      description: Standard error response
      content:
        application/json:
          schema:
            type: object
            properties:
              status:
                type: string
                enum:
                  - error
              message:
                type: string
                description: Error message

````