Text to Image Endpoint
Overview
The Dreambooth Text to Image API is used to create image from text based on trained or on public models.
You can make an API call to your trained models as well as to any public model. You can find a list of the public models available and their IDs here.
This endpoint generates and returns an image from a text passed in the request body.
Request
--request POST 'https://modelslab.com/api/v6/images/text2img' \
Make a POST
request to https://modelslab.com/api/v6/images/text2img endpoint and pass the required parameters as a request body.
Watch the how-to video to see it in action.
Body Attributes
Parameter | Description | Type |
---|---|---|
key | Your API Key used for request authorization. | key |
model_id | The ID of the model. Obtain the model ID from the provided source. | ID |
prompt | A text description of the things you want in the generated image. | string |
negative_prompt | Items you don't want in the image. | string |
width | The width of the image. Maximum value is 1024. | integer |
height | The height of the image. Maximum value is 1024. | integer |
samples | The number of images to be returned in response. The maximum value is 4. | integer |
num_inference_steps | The number of denoising steps. values range from 1 to 20, and any value above 20 will be capped at 20. | |
safety_checker | A checker for NSFW images. If detected, such images will be replaced by a blank image. Default is "yes". Options: "yes"/"no". | string |
safety_checker_type | Modify image if NSFW images are found. Default is "sensitive_content_text". Options: "blur", "sensitive_content_text", "pixelate", "black". | string |
enhance_prompt | Enhance prompts for better results. Default is "yes". Options: "yes"/"no". | string |
enhance_style | Allows you to set the style of the image for better results. Available styles include: enhance , cinematic-diva , nude , nsfw , sex , abstract-expressionism , academia , action-figure , adorable-3d-character , adorable-kawaii , art-deco , art-nouveau , astral-aura , avant-garde , baroque , bauhaus-style-poster , blueprint-schematic-drawing , caricature , cel-shaded-art , character-design-sheet , classicism-art , color-field-painting , colored-pencil-art , conceptual-art , constructivism , cubism , dadaism , dark-fantasy , dark-moody-atmosphere , dmt-art , doodle-art , double-exposure , dripping-paint-splatter , expressionism , faded-polaroid-photo , fauvism , flat-2d , fortnite-style , futurism , glitchcore , glo-fi , googie-style , graffiti-art , harlem-renaissance-art , high-fashion , idyllic , impressionism , infographic-drawing , ink-dripping-drawing , japanese-ink-drawing , knolling-photography , light-cheery-atmosphere , logo-design , luxurious-elegance , macro-photography , mandola-art , marker-drawing , medievalism , minimalism , neo-baroque , neo-byzantine , neo-futurism , neo-impressionism , neo-rococo , neoclassicism , op-art , ornate-and-intricate , pencil-sketch-drawing , pop-art-2 , rococo , silhouette-art , simple-vector-art , sketchup , steampunk-2 , surrealism , suprematism , terragen , tranquil-relaxing-atmosphere , sticker-designs , vibrant-rim-light , volumetric-lighting , watercolor , whimsical-and-playful , sharp , masterpiece , photograph , negative , cinematic , ads-advertising , ads-automotive , ads-corporate , ads-fashion-editorial , ads-food-photography , ads-gourmet-food-photography , ads-luxury , ads-real-estate , ads-retail , abstract , constructivist , cubist , expressionist , graffiti , hyperrealism , impressionist , pointillism , pop-art , psychedelic , renaissance , steampunk , surrealist , typography , futuristic-biomechanical , futuristic-biomechanical-cyberpunk , futuristic-cybernetic , futuristic-cybernetic-robot , futuristic-cyberpunk-cityscape , futuristic-futuristic , futuristic-retro-cyberpunk , futuristic-retro , futuristic-sci-fi , futuristic-vaporwave , game-bubble , game-cyberpunk , game-fighting , game-gta , game-mario , game-minecraft , game-pokemon , game-retro-arcade , game-retro , game-rpg-fantasy , game-strategy , game-streetfighter , game-zelda , misc-architectural , misc-disco , misc-dreamscape , misc-dystopian , misc-fairy-tale , misc-gothic , misc-grunge , misc-horror , misc-kawaii , misc-lovecraftian , misc-macabre , misc-manga , misc-metropolis , misc-minimalist , misc-monochrome , misc-nautical , misc-space , misc-stained-glass , misc-techwear-fashion , misc-tribal , misc-zentangle , papercraft-collage , papercraft-flat-papercut , papercraft-kirigami , papercraft-paper-mache , papercraft-paper-quilling , papercraft-papercut-collage , papercraft-papercut-shadow-box , papercraft-stacked-papercut , papercraft-thick-layered-papercut , photo-alien , photo-film-noir , photo-glamour , photo-hdr , photo-iphone-photographic , photo-long-exposure , photo-neon-noir , photo-silhouette , photo-tilt-shift , 3d-model , analog-film , anime , cinematic , comic-book , craft-clay , digital-art , fantasy-art , isometric , line-art , lowpoly , neonpunk , origami , photographic , pixel-art , texture . | string |
seed | Used to reproduce results. The same seed will generate the same image again. Pass null for a random number. | integral |
guidance_scale | Scale for classifier-free guidance. Minimum value is 1, maximum value is 20. | integer |
tomesd | Enable tomesd to generate images quickly. Default is "yes". Options: "yes"/"no". | string |
use_karras_sigmas | Use Keras sigmas to generate images. Produces nice results. Default is "yes". Options: "yes"/"no". | string |
algorithm_type | Used in DPMSolverMultistepScheduler scheduler. Default is "none". | string |
vae | Use a custom VAE for generating images. Default is null. | ID |
lora_strength | Specify the strength of the LoRa model you're using. If using multiple LoRa, provide each value as a comma-separated range from minimum 0.1 to maximum 1. | string |
lora_model | Pass LoRa model ID. Multiple LoRa models are supported; pass comma-separated values (e.g., contrast-fix, yae-miko-genshin). | ID |
multi_lingual | Allow multilingual prompts to generate images. Set to "yes" if using a language other than English in text prompts. | string |
panorama | Set to "yes" to generate a panorama image. | string |
self_attention | If you want a high-quality image, set to "yes". This will take more time. | string |
upscale | Set to "2" to upscale the image resolution two times (2x). Options: 1, 2, 3. | integer |
clip_skip | Clip Skip. Minimum value is 1, maximum value is 8. | integer |
base64 | Get response as a base64 string. Default is "no". Options: "yes"/"no". | string |
embeddings_model | Use to pass an embeddings model. | ID |
scheduler | Use to set a scheduler. | scheduler |
ip_adapter_id | IP adapter ID. Supported IDs are ip-adapter_sdxl , ip-adapter_sd15 , ip-adapter-plus-face_sd15 , ip-adapter-plus_sdxl_vit-h , ip-adapter-plus-face_sdxl_vit-h . | string |
ip_adapter_scale | Scale should be between 0 and 1. | float |
ip_adapter_image | Valid image URL for IP adapter. | URL |
webhook | Set a URL to receive a POST API call once image generation is complete. | URL |
track_id | This ID is returned in the response to the webhook API call and is used to identify the webhook request. | ID |
highres_fix | High-resolution fix for generated image. Default is "no". Options: "yes"/"no". | string |
temp | Create a temporary image link valid for 24 hours. Options: "yes"/"no". | string |
The model_id:"flux" does not support the following parameters negative_prompt
, enhance_prompt
,enhance_style
, lora trained on SD models
, ip_adaptors
, embedding_models
, upscale
and highres_fix
.
You can also use multi Lora. Just make sure to pass comma saparated lora model ids to the lora_model
as "more_details,animie"
in the request body.
Flux generations
Model | Text to Image | Image to Image | Inpaint | ControlNet | Lora |
---|---|---|---|---|---|
flux | Yes | No | No | No | No |
fluxschnell | Yes | Yes | No | No | No |
fluxdev | Yes | Yes | Yes | Yes | Yes |
Schedulers
This endpoint also supports schedulers. Use the "scheduler" parameter in the request body to pass a specific scheduler from the list below:
- DDPMScheduler
- DDIMScheduler
- PNDMScheduler
- LMSDiscreteScheduler
- EulerDiscreteScheduler
- EulerAncestralDiscreteScheduler
- DPMSolverMultistepScheduler
- HeunDiscreteScheduler
- KDPM2DiscreteScheduler
- DPMSolverSinglestepScheduler
- KDPM2AncestralDiscreteScheduler
- UniPCMultistepScheduler
- DDIMInverseScheduler
- DEISMultistepScheduler
- IPNDMScheduler
- KarrasVeScheduler
- ScoreSdeVeScheduler
- LCMScheduler
Example
Body
{
"key": "",
"model_id": "your_model_id",
"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",
"negative_prompt": "",
"width": "512",
"height": "512",
"samples": "1",
"num_inference_steps": "31",
"safety_checker": "no",
"enhance_prompt": "yes",
"seed": null,
"guidance_scale": 7.5,
"panorama": "no",
"self_attention": "no",
"upscale": "no",
"embeddings_model": null,
"lora_model": null,
"tomesd": "yes",
"clip_skip": "2",
"use_karras_sigmas": "yes",
"vae": null,
"lora_strength": null,
"scheduler": "UniPCMultistepScheduler",
"webhook": null,
"track_id": null
}
Request
- JS
- PHP
- NODE
- PYTHON
- JAVA
var myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
var raw = JSON.stringify({
"key": "",
"model_id": "your_model_id",
"prompt": "actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera",
"negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
"width": "512",
"height": "512",
"samples": "1",
"num_inference_steps": "30",
"safety_checker": "no",
"enhance_prompt": "yes",
"seed": null,
"guidance_scale": 7.5,
"panorama": "no",
"self_attention": "no",
"upscale": "no",
"embeddings_model": null,
"lora_model": null,
"tomesd": "yes",
"use_karras_sigmas": "yes",
"vae": null,
"lora_strength": null,
"scheduler": "UniPCMultistepScheduler",
"webhook": null,
"track_id": null
});
var requestOptions = {
method: 'POST',
headers: myHeaders,
body: raw,
redirect: 'follow'
};
fetch("https://modelslab.com/api/v6/images/text2img", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
<?php
$payload = [
"key" => "",
"model_id" => "your_model_id",
"prompt" => "actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera",
"negative_prompt" => "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
"width" => "512",
"height" => "512",
"samples" => "1",
"num_inference_steps" => "30",
"safety_checker" => "no",
"enhance_prompt" => "yes",
"seed" => null,
"guidance_scale" => 7.5,
"panorama" => "no",
"self_attention" => "no",
"upscale" => "no",
"embeddings_model" => null,
"lora_model" => null,
"tomesd" => "yes",
"use_karras_sigmas" => "yes",
"vae" => null,
"lora_strength": null,
"scheduler" => "UniPCMultistepScheduler",
"webhook" => null,
"track_id" => null
];
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://modelslab.com/api/v6/images/text2img',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => json_encode($payload),
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://modelslab.com/api/v6/images/text2img',
'headers': {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"key": "",
"model_id": "your_model_id",
"prompt": "actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera",
"negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
"width": "512",
"height": "512",
"samples": "1",
"num_inference_steps": "30",
"safety_checker": "no",
"enhance_prompt": "yes",
"seed": null,
"guidance_scale": 7.5,
"panorama": "no",
"self_attention": "no",
"upscale": "no",
"embeddings_model": null,
"lora_model": null,
"tomesd": "yes",
"use_karras_sigmas": "yes",
"vae": null,
"lora_strength": null,
"scheduler": "UniPCMultistepScheduler",
"webhook": null,
"track_id": null
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
import requests
import json
url = "https://modelslab.com/api/v6/images/text2img"
payload = json.dumps({
"key": "",
"model_id": "your_model_id",
"prompt": "actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera",
"negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime",
"width": "512",
"height": "512",
"samples": "1",
"num_inference_steps": "30",
"safety_checker": "no",
"enhance_prompt": "yes",
"seed": None,
"guidance_scale": 7.5,
"panorama": "no",
"self_attention": "no",
"upscale": "no",
"embeddings_model": None,
"lora_model": None,
"tomesd": "yes",
"use_karras_sigmas": "yes",
"vae": None,
"lora_strength": None,
"scheduler": "UniPCMultistepScheduler",
"webhook": None,
"track_id": None
})
headers = {
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"key\": \"\",\n \"model_id\": \"your_model_id\",\n \"prompt\": \"actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera\",\n \"negative_prompt\": \"painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime\",\n \"width\": \"512\",\n \"height\": \"512\",\n \"samples\": \"1\",\n \"num_inference_steps\": \"30\",\n \"safety_checker\": \"no\",\n \"enhance_prompt\": \"yes\",\n \"seed\": null,\n \"guidance_scale\": 7.5,\n , \"panorama\": \"no\",\n \"self_attention\": \"no\",\n \"upscale\": \"no\",\n \"embeddings_model\": \"embeddings_model_id\",\n \"lora_model\" \n \"tomesd\": \"yes\",\n \"use_karras_sigmas\": \"yes\",\n \"vae\": null,\n \"lora_strength\": null,\n \"scheduler\": \"UniPCMultistepScheduler\",\n \"webhook\": null,\n \"track_id\": null\n}");
Request request = new Request.Builder()
.url("https://modelslab.com/api/v6/images/text2img")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
Response
{
"status": "success",
"generationTime": 14.079592943191528,
"id": 13441520,
"output": [
"https://pub-8b49af329fae499aa563997f5d4068a4.r2.dev/generations/4118bb93-2c49-4d1d-9837-f43a0801e42e-0.png"
],
"meta": {
"prompt": "mdjrny-v4 style actual 8K portrait photo of gareth person, portrait, happy colors, bright eyes, clear eyes, warm smile, smooth soft skin, big dreamy eyes, beautiful intricate colored hair, symmetrical, anime wide eyes, soft lighting, detailed face, by makoto shinkai, stanley artgerm lau, wlop, rossdraws, concept art, digital painting, looking into camera DSLR photography, sharp focus, Unreal Engine 5, Octane Render, Redshift, ((cinematic lighting)), f/1.4, ISO 200, 1/160s, 8K, RAW, unedited, symmetrical balance, in-frame",
"model_id": "midjourney",
"negative_prompt": "painting, extra fingers, mutated hands, poorly drawn hands, poorly drawn face, deformed, ugly, blurry, bad anatomy, bad proportions, extra limbs, cloned face, skinny, glitchy, double torso, extra arms, extra hands, mangled fingers, missing lips, ugly face, distorted face, extra legs, anime ((out of frame)), ((extra fingers)), mutated hands, ((poorly drawn hands)), ((poorly drawn face)), (((mutation))), (((deformed))), (((tiling))), ((naked)), ((tile)), ((fleshpile)), ((ugly)), (((abstract))), blurry, ((bad anatomy)), ((bad proportions)), ((extra limbs)), cloned face, glitchy, ((extra breasts)), ((double torso)), ((extra arms)), ((extra hands)), ((mangled fingers)), ((missing breasts)), (missing lips), ((ugly face)), ((fat)), ((extra legs))",
"scheduler": "DDPMScheduler",
"safetychecker": "no",
"W": 512,
"H": 512,
"guidance_scale": 7.5,
"seed": 3292243727,
"steps": 20,
"n_samples": 1,
"full_url": "no",
"upscale": "no",
"panorama": "no",
"self_attention": "no",
"embeddings": null,
"lora_model": null,
"lora_strength": null,
"outdir": "out",
"file_prefix": "4118bb93-2c49-4d1d-9837-f43a0801e42e"
}
}