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

black-forest-labs/flux-kontext-max/text-to-image API

This document provides details on the input and output parameters for the black-forest-labs/flux-kontext-max/text-to-image model API, aiding you in understanding the meaning of fields when using the API.


Request Parameters

Request Body

Field NameTypeRequiredDefaultDescription
promptstringRequired-Prompt
modelstringRequired-The model name used for this request, which should be black-forest-labs/flux-kontext-max/text-to-image.
nintOptional1Number of images to generate, ranging from 1 to 4
aspect_ratiostringOptional”1:1”Aspect ratio of the image in the format “width:height”, e.g., “16:9” or “1:1”. Supported dimensions: “21:9”, “16:9”, “4:3”, “3:2”, “1:1”, “2:3”, “3:4”, “9:16”, “9:21”
seedintOptional-1Random seed used to control the randomness of the model output. If you want the generated content to remain consistent, use the same seed value.
stepsintOptional20Number of inference steps, ranging from 1 to 50
guidance_scalefloatOptional2.5Degree of relevance between model output and prompt, i.e., the freedom of the generated image; the larger the value, the lower the freedom of the model, resulting in stronger relevance to the user’s prompt. Value range: [1, 10].
negative_promptstringOptional-Negative prompt, used to specify content you do not wish to appear in the generated image
response_formatstringOptional”url”Specifies the format to return the generated image in, default is url, options include b64_json

Response Parameters

Field NameTypeDescription
createdintegerUnix timestamp (seconds) of the creation time of this request.
dataarrayInformation of the output images, including the URL for downloading the image or the Base64 encoding.
• If the format of the generated image return is specified as url, the corresponding subfield is url;
• If specified as b64_json, the corresponding subfield is b64_json.
Note: The link will expire within 7 days after generation, please save the image promptly.
errorObjectError information object
error.codestringError code
error.messagestringError message
error.paramstringRequest id

Examples

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/text-to-image", "prompt": "Convert to quick pencil sketch", "aspect_ratio": "16:9" }'
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/text-to-image", prompt="Convert to quick pencil sketch", extra_body={ "aspect_ratio": "16:9" } ) 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" } }