# Flux Kontext Pro Image Generation/Edit

> Image Generation

Submit a synchronous JSON request to the documented Flux-specific
ModelVerse path. The request must include a text prompt and may include
up to four Base64 input images for contextual image editing.

## Endpoint

`POST https://api.modelverse.cn/v1/flux-kontext-pro`

## Request Body

## Responses

- **200** — Image response containing Base64 image data.
- **400** — Invalid request parameters or image generation error.
- **default** — Error response.

## OpenAPI Definition

```json
{
  "openapi": "3.1.0",
  "x-language": "en-US",
  "info": {
    "title": "ModelVerse flux-kontext-pro Image API",
    "version": "1.0.0",
    "description": "Self-contained OpenAPI 3.1 schema for the ModelVerse `flux-kontext-pro`\nimage API.\n\nThe source document describes a Flux-specific JSON endpoint at\n`POST /v1/flux-kontext-pro` and bearer-token authentication through the\n`Authorization` header.\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint documented for this model."
    }
  ],
  "tags": [
    {
      "name": "flux-kontext-pro",
      "description": "Image creation and contextual image editing with flux-kontext-pro."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/flux-kontext-pro": {
      "post": {
        "tags": [
          "flux-kontext-pro"
        ],
        "operationId": "createFluxKontextProImage",
        "summary": "Flux Kontext Pro Image Generation/Edit",
        "description": "Submit a synchronous JSON request to the documented Flux-specific\nModelVerse path. The request must include a text prompt and may include\nup to four Base64 input images for contextual image editing.\n",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FluxKontextProRequest"
              },
              "examples": {
                "textOnly": {
                  "summary": "Source document prompt-only request",
                  "value": {
                    "prompt": "A photograph of a red fox in an autumn forest"
                  }
                },
                "contextualEdit": {
                  "summary": "Contextual edit with input images and deterministic seed",
                  "value": {
                    "prompt": "Place the subject from the first image into the autumn forest scene",
                    "input_image": "{image_base64_string}",
                    "input_image_2": "{reference_image_base64_string}",
                    "seed": 12345,
                    "aspect_ratio": "16:9",
                    "output_format": "jpg",
                    "prompt_upsampling": true,
                    "safety_tolerance": "3"
                  }
                },
                "webhook": {
                  "summary": "Request with webhook callback fields",
                  "value": {
                    "prompt": "A clean product photo on a white background",
                    "input_image": "{product_image_base64_string}",
                    "output_format": "png",
                    "webhook_url": "https://example.com/modelverse/webhook",
                    "webhook_secret": "{webhook_secret}"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Image response containing Base64 image data.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FluxKontextProResponse"
                },
                "examples": {
                  "generatedImage": {
                    "summary": "Generated image response",
                    "value": {
                      "createed": 1750667997,
                      "data": [
                        {
                          "b64_json": "{image_base64_string}"
                        }
                      ]
                    }
                  },
                  "editedImage": {
                    "summary": "Contextual edit response",
                    "value": {
                      "createed": 1750668123,
                      "data": [
                        {
                          "b64_json": "{edited_image_base64_string}"
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters or image generation error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FluxKontextProErrorResponse"
                },
                "examples": {
                  "invalidRequest": {
                    "$ref": "#/components/examples/FluxKontextProError"
                  }
                }
              }
            }
          },
          "default": {
            "description": "Error response.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FluxKontextProErrorResponse"
                },
                "examples": {
                  "error": {
                    "$ref": "#/components/examples/FluxKontextProError"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "ModelVerse API key sent in the `Authorization: Bearer <API_KEY>`\nheader.\n"
      }
    },
    "schemas": {
      "FluxKontextProPrompt": {
        "type": "string",
        "minLength": 1,
        "description": "Text prompt describing the requested image or edit.",
        "examples": [
          "A photograph of a red fox in an autumn forest"
        ]
      },
      "FluxKontextProBase64Image": {
        "type": "string",
        "minLength": 1,
        "contentEncoding": "base64",
        "description": "Base64-encoded image data.",
        "examples": [
          "{image_base64_string}"
        ]
      },
      "FluxKontextProSeed": {
        "type": "integer",
        "description": "Optional seed used to make generation repeatable.",
        "examples": [
          12345
        ]
      },
      "FluxKontextProAspectRatio": {
        "type": "string",
        "pattern": "^[1-9][0-9]*:[1-9][0-9]*$",
        "x-min-aspect-ratio": "9:21",
        "x-max-aspect-ratio": "21:9",
        "description": "Image aspect ratio between 21:9 and 9:21.",
        "examples": [
          "1:1",
          "16:9",
          "9:16",
          "21:9",
          "9:21"
        ]
      },
      "FluxKontextProOutputFormat": {
        "type": "string",
        "enum": [
          "png",
          "jpg"
        ],
        "default": "png",
        "description": "Output image format. The source document describes `png` and `jpg`\nas selectable values, with `png` as the default.\n"
      },
      "FluxKontextProWebhookUrl": {
        "type": "string",
        "format": "uri",
        "description": "Webhook URL used to receive generation results.",
        "examples": [
          "https://example.com/modelverse/webhook"
        ]
      },
      "FluxKontextProWebhookSecret": {
        "type": "string",
        "minLength": 1,
        "description": "Webhook secret used to verify webhook requests."
      },
      "FluxKontextProPromptUpsampling": {
        "type": "boolean",
        "default": false,
        "description": "Whether to upsample the prompt. When enabled, the prompt is\nautomatically modified to produce a more creative generation.\n"
      },
      "FluxKontextProSafetyTolerance": {
        "type": "string",
        "enum": [
          "0",
          "1",
          "2",
          "3",
          "4",
          "5",
          "6"
        ],
        "description": "Input and output moderation tolerance level. The source document lists\nselectable values as 1-6 and also describes 0 as the strictest setting\nand 6 as the least strict setting.\n"
      },
      "FluxKontextProRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "prompt"
        ],
        "properties": {
          "prompt": {
            "$ref": "#/components/schemas/FluxKontextProPrompt"
          },
          "input_image": {
            "$ref": "#/components/schemas/FluxKontextProBase64Image"
          },
          "input_image_2": {
            "$ref": "#/components/schemas/FluxKontextProBase64Image"
          },
          "input_image_3": {
            "$ref": "#/components/schemas/FluxKontextProBase64Image"
          },
          "input_image_4": {
            "$ref": "#/components/schemas/FluxKontextProBase64Image"
          },
          "seed": {
            "$ref": "#/components/schemas/FluxKontextProSeed"
          },
          "aspect_ratio": {
            "$ref": "#/components/schemas/FluxKontextProAspectRatio"
          },
          "output_format": {
            "$ref": "#/components/schemas/FluxKontextProOutputFormat"
          },
          "webhook_url": {
            "$ref": "#/components/schemas/FluxKontextProWebhookUrl"
          },
          "webhook_secret": {
            "$ref": "#/components/schemas/FluxKontextProWebhookSecret"
          },
          "prompt_upsampling": {
            "$ref": "#/components/schemas/FluxKontextProPromptUpsampling"
          },
          "safety_tolerance": {
            "$ref": "#/components/schemas/FluxKontextProSafetyTolerance"
          }
        }
      },
      "FluxKontextProResponse": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "createed",
          "data"
        ],
        "properties": {
          "createed": {
            "type": "integer",
            "format": "int64",
            "description": "Creation timestamp. The source document spells this response field as `createed`."
          },
          "data": {
            "type": "array",
            "minItems": 1,
            "description": "Image data returned by the API.",
            "items": {
              "$ref": "#/components/schemas/FluxKontextProImageData"
            }
          }
        }
      },
      "FluxKontextProImageData": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "b64_json"
        ],
        "properties": {
          "b64_json": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "Base64-encoded output image data."
          }
        }
      },
      "FluxKontextProErrorResponse": {
        "type": "object",
        "additionalProperties": true,
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/FluxKontextProError"
          }
        }
      },
      "FluxKontextProError": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "message": {
            "type": "string",
            "description": "Error message."
          },
          "type": {
            "type": "string",
            "description": "Error type."
          },
          "param": {
            "type": "string",
            "description": "Request ID or related parameter."
          },
          "code": {
            "type": "string",
            "description": "Error code."
          }
        }
      }
    },
    "examples": {
      "FluxKontextProError": {
        "summary": "Error response",
        "value": {
          "error": {
            "message": "error_message",
            "type": "error_type",
            "param": "request_id",
            "code": "error_code"
          }
        }
      }
    }
  }
}
```
