Skip to main content
POST
/
realtime
/
text2img
Generate image from text prompt (Real-Time)
curl --request POST \
  --url https://modelslab.com/api/v6/realtime/text2img \
  --header 'Content-Type: application/json' \
  --data '{
  "key": "<string>",
  "prompt": "<string>",
  "negative_prompt": "<string>",
  "width": 512,
  "height": 512,
  "samples": 1,
  "safety_checker": false,
  "seed": 123,
  "instant_response": false,
  "base64": false,
  "webhook": "<string>",
  "track_id": "<string>"
}'
{
  "status": "success",
  "generationTime": 123,
  "id": 123,
  "output": [
    "<string>"
  ],
  "proxy_links": [
    "<string>"
  ],
  "meta": {},
  "nsfw_content_detected": true
}
Text to image endpoint result
This API currently supports the following image formats: PNG and JPG.

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/realtime/text2img' \

Body

json
{  
    "key": "your_api_key",  
    "prompt": "ultra realistic close up portrait ((beautiful pale cyberpunk female with heavy black eyeliner))",  
    "negative_prompt": "bad quality",  
    "width": "512",  
    "height": "512",  
    "safety_checker": false,  
    "seed": null,  
    "samples": 1,  
    "base64": false,  
    "webhook": null,  
    "track_id": null
}

Body

application/json
key
string
required

Your API Key used for request authorization.

prompt
string
required

Text prompt with description of the things you want in the image to be generated.

negative_prompt
string

Items you don't want in the image.

width
integer
default:512

Width of the generated image in pixels. Max: 1024.

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

Height of the generated image in pixels. Max: 1024.

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

Number of images to be returned in response. Maximum value is 4.

Required range: x <= 4
safety_checker
boolean
default:false

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

seed
integer | null

Seed is used to reproduce results; the same seed will give you the same image in return. Pass 'null' for a random number.

instant_response
boolean
default:false

Queue response instantly before processing finishes instead of waiting a minimum amount of time.

base64
boolean
default:false

Get response as base64 string.

webhook
string<uri>

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

track_id
string

This ID is returned in the response to the webhook API call and is used to identify the webhook request.

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.

I