Skip to Content
API CallImage Generationblack-forest-labs/flux-kontext-max

black-forest-labs/flux-kontext-max API

This document introduces the input and output parameters for invoking the black-forest-labs/flux-kontext-max model API, providing a reference for understanding the meaning of fields when using the interface.


Request Parameters

Request Body

Field NameTypeRequiredDefaultDescription
promptstringConditionally Required-Prompt
modelstringRequired-The name of the model used for this request, which in this case is black-forest-labs/flux-kontext-max.
imagestringRequired-Base64 data or image link http://xxx
nintOptional1Number of images to generate, with a range of 1~4
strengthfloatOptional0.8Degree to which the reference image is transformed, with a range of 0~1
seedintOptional-1Random seed for controlling the randomness of model generation. For consistent outputs, use the same seed value.
stepsintOptional20Number of inferences, with a range of 1~50
guidance_scalefloatOptional2.5The degree to which the model output conforms to the prompt, i.e., the freedom of image generation; the larger the value, the less freedom the model has, and the more closely it is related to the user’s input prompt. [1, 10].
negative_promptstringOptional-Negative prompt for specifying content not desired in generated images
response_formatstringOptional”url”Specifies the format in which generated images are returned, default is url, can also be b64_json.

Response Parameters

Field NameTypeDescription
createdintegerUnix timestamp (seconds) when the request was created.
dataarrayInformation about output images, including image download URL or Base64.
• When the specified format for the generated image is URL, the subfield is URL;
• When the format is b64_json, the subfield is b64_json.
Note: The link will expire 7 days after generation, please make sure to save the image in a timely manner.
errorObjectError message object
error.codestringError code
error.messagestringError message
error.paramstringRequest id

Example

OPENAI Compatible Interface

POST https://api.umodelverse.ai/v1/images/generations

Synchronous Request

curl --location 'https://api.umodelverse.ai/v1/images/generations' \ --header "Authorization: Bearer $MODELVERSE_API_KEY" \ --header 'Content-Type: application/json' \ --data '{ "model": "black-forest-labs/flux-kontext-max", "prompt": "Convert to quick pencil sketch", "image": "data:image/png;base64,{image_base64_string}" }'
import os from openai import OpenAI client = OpenAI( base_url=os.getenv("BASE_URL", "https://api.umodelverse.ai/v1"), api_key=os.getenv("API_KEY", "$MODELVERSE_API_KEY") ) response = client.images.generate( model="black-forest-labs/flux-kontext-max", prompt="Convert to quick pencil sketch", extra_body={ "image": "data:image/png;base64,{image_base64_string}" } ) print(response.data[0].url)

Response

{ "created": 1750667997, "data": [ { "url": "https://xxxxx/xxxx.png", "b64_json": "data:image/png;base64,{image_base64_string}" } ], "usage": { "input_tokens_details": {} } }
{ "error": { "message": "error_message", "type": "error_type", "param": "request_id", "code": "error_code" } }