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

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

This document introduces the input and output parameters for calling the black-forest-labs/flux-kontext-pro model API, allowing you to refer to the field meanings when using the interface.


Request Parameters

Request Body

Field NameTypeRequiredDefaultDescription
promptstringConditional Required-Prompt
modelstringRequired-The model name used for this request, which is black-forest-labs/flux-kontext-pro.
imagestringRequired-Base64 data or image link http://xxx
nintOptional1Number of generated images, the range is 1~4
strengthfloatOptional0.8Degree of reference to the transformed image, the range is 0~1
seedintOptional-1Random seed used to control the randomness of the model’s output. If you want the output to be consistent, use the same seed parameter value.
stepsintOptional20Number of inference steps, the range is 1~50
guidance_scalefloatOptional2.5Degree of consistency between the model’s output and the prompt, or the degree of freedom in generated images; the larger the value, the less freedom the model has, and the stronger the relevance with the user’s input prompt.
Value range [1, 20].
negative_promptstringOptional-Negative prompt, used to specify content you don’t want to appear in the generated image
response_formatstringOptional”url”Specifies the format to return the generated image, default is url, optional b64_json

Response Parameters

Field NameTypeDescription
createdintegerThe Unix timestamp (seconds) for when the request was created.
dataarrayInformation about the output image, including the image download URL or Base64.
• When the specified format is url, the subfield is url;
• When the specified format is b64_json, the subfield is b64_json.
Note: The link will expire within 7 days after generation, please be sure to save the image in time.
errorObjectError information 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-pro", "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-pro", 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" } }