POST
/
v2
/
txt2img

The Text-to-Image V2 API is deprecated and will be removed in the future. Please migrate to Text-to-Image V3.

POST Text to Image V2

The text-to-image endpoint will return only a task_id. You should use the task_id to call the /v2/progress API endpoint to retrieve the image generation results. We will gradually phase out the V2 endpoints. It is recommended to use the V3 endpoints to generate images.

Request Headers

Authorization
string
required

Request Body

extra
object
prompt
string
required

Positive prompt words, separated by ,. If you want to use LoRA, you can call the /v3/model endpoint with the parameter filter.types=lora to retrieve the sd_name_in_api field as the model_name. Remember that the format for LoRA models is <lora:$sd_name:$weight>.

negative_prompt
string
required

Negative prompt words, separated by ,.

sampler_name
string
required

This denoising process is called sampling because Stable Diffusion generates a new sample image at each step.
Enum: DPM++ 2M Karras, DPM++ SDE Karras, DPM++ 2M SDE Exponential, DPM++ 2M SDE Karras, Euler a, Euler, LMS, Heun, DPM2, DPM2 a, DPM++ 2S a, DPM++ 2M, DPM++ SDE, DPM++ 2M SDE, DPM++ 2M SDE Heun, DPM++ 2M SDE Heun Karras, DPM++ 2M SDE Heun Exponential, DPM++ 3M SDE, DPM++ 3M SDE Karras, DPM++ 3M SDE Exponential, DPM fast, DPM adaptive, LMS Karras, DPM2 Karras, DPM2 a Karras, DPM++ 2S a Karras, Restart, DDIM, PLMS, UniPC

batch_size
integer
required

The number of images generated in one single generation. Range: [0, 8]

n_iter
integer
required

The number of generations. Range: [0, 8]

steps
integer
required

Think of steps as iterations in the image creation process. Range: (0, 50]

cfg_scale
integer
required

This setting determines how closely Stable Diffusion will adhere to your prompt. Range: (0, 30]

seed
integer
required

A seed is a number from which Stable Diffusion generates noise.

height
integer
required

Height of the image. Range: (0, 2048]

width
integer
required

Width of the image. Range: (0, 2048]

model_name
string
required

Name of the Stable Diffusion model. You can call the /v3/model endpoint with the parameter filter.types=checkpoint to retrieve the sd_name_in_api field as the model_name.

restore_faces
boolean
required

Enable the Stable Diffusion face restoration plugin.

restore_faces_model
null
required
sd_vae
string¦null

VAE (Variational Auto Encoder). sd_vae can be accessed in the API /v3/model with query parameters filter.types=vae to retrieve the sd_name field as the sd_vae.

clip_skip
integer

This parameter indicates the number of layers to stop from the bottom during optimization, so clip_skip on 2 would mean, that in SD1.x model where the CLIP has 12 layers, you would stop at 10th layer.

enable_hr
boolean¦null

Hires.fix function switch.

hr_upscaler
string¦null

Upscalers model names. AI upscalers are models trained with massive amounts of data.
Enum: Latent, ESRGAN_4x, R-ESRGAN 4x+, R-ESRGAN 4x+ Anime6B

hr_scale
number¦null

The magnification factor of the image, if params hr_resize_x and hr_resize_y are set, this parameter will be ignored.
Enum: 1, 2

hr_resize_x
integer¦null

The target image width, the maximum image size is 2048, only take effect when parameters hr_scale=1.

hr_resize_y
integer¦null

The target image hight, the maximum image size is 2048, only take effect when parameters hr_scale=1.

img_expire_ttl
integer¦null

Image storage time (seconds). Range [0, 604800]

sd_refiner
object¦null

Refiner infos to enhances the image details.

controlnet_units
object[]¦null

ControlNet.

Response

code
integer
msg
string
data
object

Example

request

curl --location 'https://api.novita.ai/v2/txt2img' \
--header 'Authorization: Bearer {{API Key}}' \
--header 'Content-Type: application/json' \
--data '{
  'extra': {
    'enable_nsfw_detection': false,
    'nsfw_detection_level': 0,
    'enable_progress_info': false
  },
  'prompt': 'Luxury suite design, Spacious suite area, Luxuriously plush large bed, Refined office desk, Carefully selected furniture for the luxurious suite, High-end and opulent decor, Private office and lounge area, Comfortably luxurious office chair, Amenities for luxury travelers, Premium bedding and linens, Uniquely designed lighting fixtures, Luxurious suite curtain design, Private work corner, Luxurious amenities, Lavish lounge area, Sophisticated indoor plant, decorations, Exquisite luxury design, Exclusive services for the luxury suite, Luxury color scheme. Exclusive furniture for the luxury suite, a bedroom with a large bed and a desk',
  'negative_prompt': '(badhandv4:1.2),(worst quality:2),(low quality:2),(normal quality:2),lowres,bad anatomy,bad hands,((monochrome)),((grayscale)) watermark,moles, easynegative ng_deepnegative_v1_75t, (oversized head:2), (big head:2), (deformed face:1.5),( blurry face:2), bad eyes, irregular eyes, asymmetric eyes, ugly, teeth, (navel:0.9), artefact, jpg artefact, blurry face, blurry, blurred, pixelated, bad eyes, crossed eyes, blurry eyes',
  'sampler_name': 'DPM++ 2M Karras',
  'batch_size': 1,
  'n_iter': 1,
  'steps': 25,
  'cfg_scale': 7,
  'seed': -1,
  'height': 512,
  'width': 512,
  'model_name': 'sd_xl_base_0.9.safetensors',
  'restore_faces': false,
  'restore_faces_model': '',
  'sd_vae': '',
  'clip_skip': 1,
  'enable_hr': false,
  'hr_upscaler': 'Latent',
  'hr_scale': 1,
  'hr_resize_x': null,
  'hr_resize_y': null,
  'img_expire_ttl': null,
  'sd_refiner': {
    'checkpoint': 'sd_xl_refiner_1.0.safetensors',
    'switch_at': null
  },
  'controlnet_units': [
    {
      'model': '',
      'weight': null,
      'input_image': '',
      'module': 'none',
      'control_mode': 0,
      'mask': '',
      'resize_mode': 0,
      'processor_res': null,
      'threshold_a': null,
      'threshold_b': null,
      'guidance_start': null,
      'guidance_end': null,
      'pixel_perfect': false
    }
  ]
}'

response

{
  "code": 0,
  "msg": "",
  "data": {
    "task_id": "d4cf3973-8414-4a5e-aa6f-ef54caf73662"
  }
}