Text to image: Turning words into pictures with AI

The foundational pipeline: generate images from text prompts using diffusion models, with control over every step of the process.

Introduction

Text-to-image generation transforms textual descriptions into visual content, allowing you to create images from just words. While the concept is simple, understanding the various parameters and how they interact gives you precise control over your results.

This page covers the core pipeline, how text becomes an image, how to structure requests, and how to choose the right model. For deep dives into individual parameters, each one has its own concept page linked below.

Basic request example

Here's a simple text-to-image request to get you started:

import { createClient } from '@runware/sdk'

const client = await createClient({ apiKey: process.env.RUNWARE_API_KEY })
await client.connect()

const [result] = await client.run({
  model: '<model-air>',
  positivePrompt: 'An astronaut floating inside a giant hourglass in space, surrounded by stars and glowing dust, with galaxies swirling faintly above and golden sand below. Dreamy, surreal, cinematic',
  width: 1024,
  height: 1024,
  steps: 30
})
import asyncio
import os

from runware import Runware


async def main():
    async with Runware(api_key=os.environ["RUNWARE_API_KEY"]) as client:
        results = await client.run({
            "model": "<model-air>",
            "positivePrompt": "An astronaut floating inside a giant hourglass in space, surrounded by stars and glowing dust, with galaxies swirling faintly above and golden sand below. Dreamy, surreal, cinematic",
            "width": 1024,
            "height": 1024,
            "steps": 30
        })


asyncio.run(main())
curl https://api.runware.ai/v1 \
  -H "Authorization: Bearer $RUNWARE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '[
    {
      "taskType": "imageInference",
      "taskUUID": "a770f077-f413-47de-9dac-be0b26a35da6",
      "model": "<model-air>",
      "positivePrompt": "An astronaut floating inside a giant hourglass in space, surrounded by stars and glowing dust, with galaxies swirling faintly above and golden sand below. Dreamy, surreal, cinematic",
      "width": 1024,
      "height": 1024,
      "steps": 30
    }
  ]'
runware run "<model-air>" \
  positivePrompt="An astronaut floating inside a giant hourglass in space, surrounded by stars and glowing dust, with galaxies swirling faintly above and golden sand below. Dreamy, surreal, cinematic" \
  width=1024 \
  height=1024 \
  steps=30
{
  "taskType": "imageInference",
  "taskUUID": "a770f077-f413-47de-9dac-be0b26a35da6",
  "model": "<model-air>",
  "positivePrompt": "An astronaut floating inside a giant hourglass in space, surrounded by stars and glowing dust, with galaxies swirling faintly above and golden sand below. Dreamy, surreal, cinematic",
  "width": 1024,
  "height": 1024,
  "steps": 30
}
Response
{
  "data": [
    {
      "taskType": "imageInference",
      "imageUUID": "ca6b2d39-5f83-47b9-b22b-71f9afc935e8",
      "taskUUID": "a770f077-f413-47de-9dac-be0b26a35da6",
      "seed": 9202427981074766178,
      "imageURL": "https://im.runware.ai/image/os/a14d18/ws/2/ii/ca6b2d39-5f83-47b9-b22b-71f9afc935e8.jpg"
    }
  ]
}

How text-to-image works

Text-to-image generation converts textual descriptions into visual content through a multi-stage process where the model gradually constructs an image based on your prompt. At its core, the process involves three key phases:

  1. Text understanding: The input prompt is processed by a text encoder that converts natural language into a numerical representation called embeddings. These embeddings capture the semantic meaning, conceptual relationships, and stylistic cues present in your text.

  2. Latent space generation: Rather than manipulating raw pixels, modern systems operate in a latent space, which is an abstract, compressed representation of images. Most advanced models use a diffusion process, which begins with random noise and gradually refines it into a meaningful image. This denoising is guided by your text embeddings and carried out by a neural network, typically a U-Net or a Transformer-based architecture like DiT. Some models follow an autoregressive approach generating images token by token.

  3. Image decoding: The final latent representation is converted into a pixel-based image using a decoder, often part of a Variational Autoencoder (VAE). This step handles texture, color, and fine detail, producing the full-resolution image you see.

Together, these phases enable AI to generate images that closely match the meaning and style of your original prompt.

Model selection

The model parameter specifies which model generates the image, and it is the single choice that changes the result most. It sets the aesthetic, how your prompt is read, and which of the parameters below have any effect at all.

Models are grouped into architecture families, and a family decides more than a fine-tune does. Two models in the same family respond to the same steps and CFGScale ranges, while two models in different families often do not share a parameter at all. Each model's API reference lists what it accepts.

Browse the catalog in the model finder, which stays current as models ship.

The same prompt, the same parameters, two different models. Nothing changed except the model field.

You can also search the catalog programmatically with the Model Search API.

Generation parameters

Every parameter in the request controls a different aspect of the generation process. Each one has its own concept page with visual examples and detailed guidance:

ParameterWhat it controlsConcept page
positivePrompt / negativePromptWhat to generate and what to avoidPrompts
width / heightCanvas size and aspect ratioDimensions
stepsNumber of refinement iterationsSteps
CFGScaleHow strictly the model follows your promptCFG Scale
schedulerDenoising algorithm (speed vs quality)Schedulers
seedDeterministic starting point for reproducibilitySeed
vaeVisual decoder for the final imageVAE
clipSkipText encoder layer selectionCLIP Skip

Advanced features

These features extend text-to-image with additional conditioning and control:

FeatureWhat it doesConcept page
LoRAsLightweight style/subject adapters that modify a base modelLoRAs
ControlNetStructural guidance via edge maps, depth maps, and pose detectionControlNet
IP AdaptersReference image conditioning for style transfer and subject consistencyIP Adapters
EmbeddingsCustom text tokens for specialized conceptsEmbeddings
RefinerTwo-stage generation for enhanced detailRefiner