> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/stackai-tools/images-audio-and-video/text-to-image.md).

# Text to Image

Generate an image from a written description. Use this tool when a workflow needs an illustration or other newly created visual.

## Use this tool

1. Write **Image Generation Prompt** with the subject, composition, and required style.
2. Choose **Image Generation Model**.
3. Set the size and other options supported by that model.
4. Run the tool and open **Image URL** to review the result.

## Behavior and limits

Settings are model-specific. Quality, background, output format, and compression options apply to GPT Image models; Gemini has separate aspect-ratio and image-size controls. Generated text and details may need review before use.

## Inputs

| Field                              | Parameter | Description                               |
| ---------------------------------- | --------- | ----------------------------------------- |
| Image Generation Prompt (required) | `prompt`  | Text description of the image to generate |

## Configuration

| Field                             | Parameter              | Description                                                                     |
| --------------------------------- | ---------------------- | ------------------------------------------------------------------------------- |
| Image Generation Model (required) | `model`                | AI model to use for image generation                                            |
| Image Size                        | `size`                 | Size/aspect ratio of the generated image                                        |
| Image Quality                     | `quality`              | Quality level for image generation (GPT Image models only)                      |
| Background Style                  | `background`           | Background style for the generated image (GPT Image models only)                |
| Output Format                     | `output_format`        | File format for the generated image (GPT Image models only)                     |
| Output Compression                | `output_compression`   | Compression level (0-100) for the generated image (GPT Image models only)       |
| Aspect Ratio (Gemini)             | `aspect_ratio`         | Aspect ratio for Gemini image generation                                        |
| Image Size (Gemini)               | `image_size`           | Image size preset for Gemini image generation                                   |
| Use Google Search (Gemini)        | `enable_google_search` | Allow Gemini image generation to use Google Search grounding. Default: `false`. |

## Outputs

| Field     | Parameter   | Description                                      |
| --------- | ----------- | ------------------------------------------------ |
| Image URL | `image_url` | Direct URL to the generated image (if available) |

## Related guides

* [File Inputs, Supported Formats, and Size Limits](https://docs.stackai.com/technical-reference/files-knowledge-and-retrieval/file-inputs-supported-formats-and-size-limits.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/stackai-tools/images-audio-and-video/text-to-image.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
