---
title: "text-to-image"
method: POST
path: "/generation/{engine_id}/text-to-image"
tags: ["v1beta/generation"]
---

# text-to-image

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

Generate an image from text - deprecated, use v1/text-to-image instead

## Path parameters

- `engine_id` string, required

## Headers

- `Accept` 'application/json' | 'image/png'
- `Organization` string

## Request body

- TextToImageRequestBody — Represents the optional parameters that can be passed to any generation request.
  - `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: <pre> "text_prompts": [ { "text": "A lighthouse on a cliff", "weight": 0.5 } ] </pre>
    - `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'
  - `height` integer — Height of the image in pixels. Must be in increments of 64 and pass the following validation: - For 768 engines: <span style='display: flex; justify-content: flex-start; gap:8px'>589,824 <span>≤</span> `height * width` <span>≤</span> 1,048,576</span> - All other engines: <span style='display: flex; justify-content: flex-start; gap:8px'>262,144 <span>≤</span> `height * width` <span>≤</span> 1,048,576</span>
  - `width` integer — Width of the image in pixels. Must be in increments of 64 and pass the following validation: - For 768 engines: <span style='display: flex; justify-content: flex-start; gap:8px'>589,824 <span>≤</span> `height * width` <span>≤</span> 1,048,576</span> - All other engines: <span style='display: flex; justify-content: flex-start; gap:8px'>262,144 <span>≤</span> `height * width` <span>≤</span> 1,048,576</span>
  - `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

## Response `200`

OK response.

- Image[] — The result of the generation request, containing one or more images as base64 encoded strings.
  - `base64` string — Image encoded in base64
  - `finishReason` 'SUCCESS' | 'ERROR' | 'CONTENT_FILTERED'
  - `seed` number — The seed associated with this image

## Other responses

- `400` — bad_request: general error for invalid parameters <br/><br/> <p style="display: flex; margin-top: -20px; margin-bottom: 0">More specific errors:</p> - invalid_samples: Sample count may only be greater than 1 when the accept header is set to `application/json` - invalid_height_or_width: Height and width must be specified in increments of 64 - invalid_file_size: The file size of one or more of the provided files is invalid - invalid_mime_type: The mime type of one or more of the provided files is invalid - invalid_image_dimensions: The dimensions of the provided `init_image` and `mask_image` do not match - invalid_mask_image: The parameter `mask_source` was set to `MASK_IMAGE_WHITE` or `MASK_IMAGE_BLACK` but no `mask_image` was provided - invalid_prompts: One or more of the prompts contains filtered words - invalid_pixel_count: Incorrect number of pixels specified. Requirements: - For 768 engines : <span style='display: inline-flex; justify-content: flex-start; gap:8px'>589,824 <span>≤</span> `height * width` <span>≤</span> 1,048,576</span> - All other engines: <span style='display: inline-flex; justify-content: flex-start; gap:8px'>262,144 <span>≤</span> `height * width` <span>≤</span> 1,048,576</span>\n
- `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 was not found (e.g. specifing a model that does not exist)
- `500` — server_error: Some unexpected server error occurred

---

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