---
title: "Text-to-image"
method: POST
path: "/v1/generation/{engine_id}/text-to-image"
tags: ["Version1.Image"]
---

# Text-to-image

`POST /v1/generation/{engine_id}/text-to-image`

Generate an image from a text prompt. 
### Using SDXL 1.0
Use `stable-diffusion-xl-1024-v1-0` as the `engine_id` of your request and pass in `height` & `width` as one of the following combinations:
- 1024x1024 (default)
- 1152x896
- 896x1152
- 1216x832
- 1344x768
- 768x1344
- 1536x640
- 640x1536 

### SDXL 1.0 Pricing
When specifying 30 steps or fewer, generation costs 0.9 credits.

When specifying above 30 steps, generation cost is determined using the following formula:

 `cost = 0.9 * (steps / 30)`

### Using SD 1.6
SD1.6 is a flexible-resolution base model allowing you to generate non-standard aspect ratios. The model is optimized for a resolution of 512 x 512 pixels. To generate 1 megapixel outputs, we recommend using SDXL 1.0, which is available at the same price.

Pass in `stable-diffusion-v1-6` as the `engine_id` of your request and ensure the `height` & `width` you pass in adhere to the following restrictions:
- No dimension can be less than 320 pixels
- No dimension can be greater than 1536 pixels
- Height and width must be specified in increments of 64
- The default resolution is 512 x 512

## Path parameters

- `engine_id` string, required

## Headers

- `Organization` string
- `Stability-Client-ID` string
- `Stability-Client-Version` string

## Request body

- TextToImageRequestBody — Represents the optional parameters that can be passed to any generation request.
  - `height` integer — Height of the image to generate, in pixels, in an increment divisible by 64.
  - `width` integer — Width of the image to generate, in pixels, in an increment divisible by 64.
  - `text_prompts` TextPrompt[], required — An array of text prompts to use for generation. Given a text prompt with the text `A lighthouse on a cliff` and a weight of `0.5`, it would be represented as: ``` "text_prompts": [ { "text": "A lighthouse on a cliff", "weight": 0.5 } ] ```
    - `text` string, required — The prompt itself
    - `weight` number, float — Weight of the prompt (use negative numbers for negative prompts)
  - `cfg_scale` number — How strictly the diffusion process adheres to the prompt text (higher values keep your image closer to your prompt)
  - `clip_guidance_preset` 'FAST_BLUE' | 'FAST_GREEN' | 'NONE' | 'SIMPLE' | 'SLOW' | 'SLOWER' | 'SLOWEST'
  - `sampler` 'DDIM' | 'DDPM' | 'K_DPMPP_2M' | 'K_DPMPP_2S_ANCESTRAL' | 'K_DPM_2' | 'K_DPM_2_ANCESTRAL' | 'K_EULER' | 'K_EULER_ANCESTRAL' | 'K_HEUN' | 'K_LMS' — Which sampler to use for the diffusion process. If this value is omitted we'll automatically select an appropriate sampler for you.
  - `samples` integer — Number of images to generate
  - `seed` integer — Random noise seed (omit this option or use `0` for a random seed)
  - `steps` integer — Number of diffusion steps to run.
  - `style_preset` 'enhance' | 'anime' | 'photographic' | 'digital-art' | 'comic-book' | 'fantasy-art' | 'line-art' | 'analog-film' | 'neon-punk' | 'isometric' | 'low-poly' | 'origami' | 'modeling-compound' | 'cinematic' | '3d-model' | 'pixel-art' | 'tile-texture' — Pass in a style preset to guide the image model towards a particular style. This list of style presets is subject to change.
  - `extras` Extras — Extra parameters passed to the engine. These parameters are used for in-development or experimental features and may change without warning, so please use with caution.

## Response `200`

Generation successful.

- object — An array of results from the generation request, where each image is a base64 encoded PNG.
  - `artifacts` Image[]
    - `base64` string — Image encoded in base64
    - `finishReason` 'SUCCESS' | 'ERROR' | 'CONTENT_FILTERED'
    - `seed` number — The seed associated with this image

## Other responses

- `400` — bad_request: one or more parameters were invalid.
- `401` — unauthorized: API key missing or invalid
- `403` — permission_denied: You lack the necessary permissions to perform this action
- `404` — not_found: The requested resource/engine was not found
- `500` — server_error: Some unexpected server error occurred

---

[API](https://skmtc.net/nod-ai/apis/stabilityai-rest-api.md) · [All operations](https://skmtc.net/nod-ai/apis/stabilityai-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/nod-ai/stabilityai-rest-api/versions/ea57a82c5c16/schema)
