Skip to main content
POST
/
text2img
Text-to-Image
curl --request POST \
  --url https://modelslab.com/api/v6/images/text2img \
  --header 'Content-Type: application/json' \
  --data '{
  "key": "<string>",
  "prompt": "<string>",
  "negative_prompt": "<string>",
  "width": 512,
  "height": 512,
  "samples": 1,
  "num_inference_steps": 31,
  "safety_checker": false,
  "safety_checker_type": "sensitive_content_text",
  "seed": 123,
  "guidance_scale": 7.5,
  "use_karras_sigmas": true,
  "algorithm_type": "none",
  "vae": "<string>",
  "lora_strength": "<string>",
  "lora_model": "<string>",
  "clip_skip": 2,
  "base64": false,
  "temp": false,
  "webhook": "<string>",
  "track_id": "<string>",
  "ip_adapter_id": "ip-adapter_sdxl",
  "ip_adapter_scale": 0.5,
  "ip_adapter_image": "<string>",
  "scheduler": "DDPMScheduler",
  "model_id": "<string>",
  "multi_lingual": false,
  "upscale": false,
  "highres_fix": false
}'
{
  "status": "success",
  "generationTime": 123,
  "id": 123,
  "output": [
    "<string>"
  ],
  "proxy_links": [
    "<string>"
  ],
  "meta": {},
  "nsfw_content_detected": true,
  "webhook_status": "<string>",
  "tip": "<string>"
}
Text to image endpoint result

Request

Make a POST request to below endpoint and pass the required parameters as a request body.
curl
--request POST 'https://modelslab.com/api/v6/images/text2img' \

Body

json
{  
    "key": "your_api_key",  
    "model_id": "flux",  
    "prompt": "ultra realistic close up portrait ((beautiful pale cyberpunk female with heavy black eyeliner)), blue eyes, shaved side haircut, hyper detail, cinematic lighting, magic neon, dark red city, Canon EOS R3, nikon, f/1.4, ISO 200, 1/160s, 8K, RAW, unedited, symmetrical balance, in-frame, 8K",  
    "width": "512",  
    "height": "512",  
    "samples": "1",  
    "num_inference_steps": "31",  
    "safety_checker": "no",    
    "seed": null,  
    "guidance_scale": 7.5,   
    "clip_skip": "2",  
    "vae": null,  
    "webhook": null,  
    "track_id": null
}

Body

application/json
model_id
string
required

The ID of the model to be used. It can be a public model or one you have trained.

key
string
required

Your API Key used for request authorization.

prompt
string
required

A text description of what you want in the generated image.

multi_lingual
boolean
default:false

Allow multilingual prompts. Set to 'true' if using a language other than English.

upscale
boolean
default:false

Set to 'true' to upscale the image resolution two times (2x).

highres_fix
boolean
default:false

Enable high-resolution fix for generated images.

negative_prompt
string

Items you don't want in the image.

width
integer
default:512

The width of the image in pixels.

Required range: x <= 1024
height
integer
default:512

The height of the image in pixels.

Required range: x <= 1024
samples
integer
default:1

The number of images to be returned in response. Maximum is 4.

Required range: x <= 4
num_inference_steps
integer
default:31

The number of denoising steps. Values range from 1 to 20, and any value above 20 will be capped at 20.

Required range: 1 <= x <= 20
safety_checker
boolean
default:false

A checker for NSFW images. If detected, such images will be replaced by a blank image.

safety_checker_type
enum<string>
default:sensitive_content_text

How to modify the image if NSFW content is found.

Available options:
blur,
sensitive_content_text,
pixelate,
black
seed
integer | null

Seed for reproducible results. The same seed generates the same image. Pass null for a random number.

guidance_scale
number
default:7.5

Scale for classifier-free guidance.

Required range: 1 <= x <= 20
use_karras_sigmas
boolean
default:true

Use Karras sigmas to generate images. Produces nice results.

algorithm_type
enum<string>
default:none

Used in DPMSolverMultistepScheduler scheduler.

Available options:
none,
dpmsolver+++
vae
string | null

Use a custom VAE for generating images. Default is null.

lora_strength
string

Strength of the LoRa model(s). If multiple LoRa models, provide comma-separated values (0.1 to 1).

lora_model
string

LoRa model ID(s). Multiple LoRa models are supported; pass comma-separated values (e.g., 'contrast-fix,yae-miko-genshin').

clip_skip
integer
default:2

Number of CLIP layers to skip.

Required range: 1 <= x <= 8
base64
boolean
default:false

If true, response output is base64 string. Input images can also be base64.

temp
boolean
default:false

If true, stores image in temporary storage (cleaned every 24 hours).

webhook
string<uri>

URL to receive a POST API call once image generation is complete.

track_id
string

Unique ID used in webhook response to identify the request.

ip_adapter_id
enum<string>

IP adapter ID.

Available options:
ip-adapter_sdxl,
ip-adapter_sd15,
ip-adapter-plus-face_sd15,
ip-adapter-plus_sdxl_vit-h,
ip-adapter-plus-face_sdxl_vit-h
ip_adapter_scale
number

Scale for the IP adapter (0 to 1).

Required range: 0 <= x <= 1
ip_adapter_image
string<uri>

Valid image URL for IP adapter.

scheduler
enum<string>

Available schedulers for image generation.

Available options:
DDPMScheduler,
DDIMScheduler,
PNDMScheduler,
LMSDiscreteScheduler,
EulerDiscreteScheduler,
EulerAncestralDiscreteScheduler,
DPMSolverMultistepScheduler,
HeunDiscreteScheduler,
KDPM2DiscreteScheduler,
DPMSolverSinglestepScheduler,
KDPM2AncestralDiscreteScheduler,
UniPCMultistepScheduler,
DDIMInverseScheduler,
DEISMultistepScheduler,
IPNDMScheduler,
KarrasVeScheduler,
ScoreSdeVeScheduler,
LCMScheduler

Response

Text-to-image generation response

  • Option 1
  • Option 2
  • Option 3
status
enum<string>

Status of the image generation.

Available options:
success
generationTime
number

Time taken to generate the image in seconds.

id
integer

Unique identifier for the image generation request.

output
string<uri>[]

Array of generated image URLs.

Array of proxy image URLs.

meta
object

Metadata about the image generation including all parameters used.

nsfw_content_detected
boolean

Indicates if NSFW content was detected in the generated image.

webhook_status
string

Status of the webhook notification.

tip
string

Additional information or tips for the user.

I