Skip to Content
API DocImage Generation API

Image Generation API

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

This document introduces the input and output parameters for calling the image generation model API, providing the field meanings for your reference.


Image Generation Model List

ModelFree Quota (Images)
black-forest-labs/flux.1-dev10
black-forest-labs/flux-kontext-pro5
black-forest-labs/flux-kontext-pro/multi5
black-forest-labs/flux-kontext-pro/text-to-image5
stepfun-ai/step1x-edit5
black-forest-labs/flux-kontext-max0
black-forest-labs/flux-kontext-max/multi0
black-forest-labs/flux-kontext-max/text-to-image0

Request Parameters

Request Body

Supported Parameter List

Field NameTypeRequiredDefaultSupported ModelsDescription
promptstringCond.-AllPrompt for generating the image.
modelstringRequired-AllModel name to use for this request.
nintOptional1black-forest-labs/flux.1-dev
black-forest-labs/flux-kontext-pro/text-to-image
black-forest-labs/flux-kontext-max/text-to-image
Number of images to generate.
Range [1, 4]
imagestringCond.-black-forest-labs/flux.1-dev (optional)
black-forest-labs/flux-kontext-max (required)
black-forest-labs/flux-kontext-pro (required)
stepfun-ai/step1x-edit (required)
Supports image URLs or Base64 encoding (format: data:image/;base64,).
imagesarray(string)Cond.-black-forest-labs/flux-kontext-max/multi
black-forest-labs/flux-kontext-pro/multi
Reference image array, each item should be a public URL link or the base64 encoding of the image content.
response_formatstringOptionalurlblack-forest-labs/flux.1-devSpecifies the return format for the generated image.
url: returns the image link;
b64_json: returns the Base64 encoded string.
sizestringOptional1024x1024black-forest-labs/flux.1-devPixel dimensions of the generated image, required to be between [256x256, 1536x1536].
strengthfloatOptional0.8black-forest-labs/flux.1-devDegree of reference for the conversion image, range [0.0, 1.0].
aspect_ratiostringOptional1:1black-forest-labs/flux-kontext-max/text-to-image
black-forest-labs/flux-kontext-pro/text-to-image
Aspect ratio of the generated image.
Supported dimensions: “21:9”, “16:9”, “4:3”, “3:2”, “1:1”, “2:3”, “3:4”, “9:16”, “9:21”
stepsintOptional28black-forest-labs/flux.1-dev
stepfun-ai/step1x-edit
Number of inference steps, higher values result in more refined outputs but longer run times.
seedintOptional-1AllRandom seed controlling the randomness of generated content. Range from [-1, 9999999999]. If not provided, it will be generated automatically. The same seed can reproduce the same content.
guidance_scalefloatOptional2.5AllUsed to adjust the tightness between the model’s creativity and text guidance during image generation. Higher values make the generated image more faithful to the text prompt but may reduce diversity; lower values allow more creativity and variation.
Range [1, 10].
negative_promptstringOptional-stepfun-ai/step1x-editNegative prompts used to specify content that should not appear in the generated image.

Response Parameters

Field NameTypeDescription
createdintegerUnix timestamp (seconds) for the creation time of this request.
dataarrayInformation on the output image, including the image download URL or Base64.
• If the format is specified as url, then the subfield is url;
• If the format is specified as b64_json, then the subfield is b64_json.
Note: Links will expire 7 days after creation, so be sure to save the image promptly.
errorObjectError information object
error.codestringError code
error.messagestringError message
error.paramstringRequest id

Examples

Request

curl --location 'https://api.umodelverse.ai/v1/images/generations' \ --header 'Authorization: Bearer <Your API Key>' \ --header 'Content-Type: application/json' \ --data '{ "model": "black-forest-labs/flux-kontext-pro/text-to-image", "prompt": "Retro game style, man in old school suit, upper body, true detective, detailed character, nigh sky, crimson moon silhouette, american muscle car parked on dark street in background, complex background in style of Bill Sienkiewicz and Dave McKean and Carne Griffiths, extremely detailed, mysterious, grim, provocative, thrilling, dynamic, action-packed, fallout style, vintage, game theme, masterpiece, high contrast, stark. vivid colors, 16-bit, pixelated, textured, distressed" }'

Response

{ "created": 1750667997, "data": [ { "url": "https://api.umodelverse.ai/image/xxx", "b64_json": "data:image/png;base64,iVBORw0KGgoAAAANSUhEU..." } ], "usage": { "input_tokens_details": {} } }
{ "error": { "message": "xxx", "type": "", "param": "b4a7b49c-203c-43c9-88ce-9e636e77ace8", "code": "xxx" } }

OpenAI SDK Compatibility

import os from openai import OpenAI client = OpenAI( base_url=os.getenv("BASE_URL", "https://api.umodelverse.ai/v1"), # Replace with your <API_KEY> api_key=os.getenv("API_KEY", "<API_KEY>"), ) # propmt = "Retro game style, man in old school suit, upper body, true detective, detailed character, nigh sky, crimson moon silhouette, american muscle car parked on dark street in background, complex background in style of Bill Sienkiewicz and Dave McKean and Carne Griffiths, extremely detailed, mysterious, grim, provocative, thrilling, dynamic, action-packed, fallout style, vintage, game theme, masterpiece, high contrast, stark. vivid colors, 16-bit, pixelated, textured, distressed" img = client.images.generate( prompt=propmt, model="black-forest-labs/flux-kontext-pro/text-to-image", extra_body={ "aspect_ratio": "9:16", # Image size }, ) # Get the first image data from the return img_data = img.data[0] print("Image download link:", img_data.url)