> ## Documentation Index
> Fetch the complete documentation index at: https://docs.routeway.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Image Generation

> Generate and edit images from text prompts using DALL-E and other models.

Routeway provides an OpenAI-compatible image generation endpoint that lets you create and edit images from text prompts.

```
POST https://api.routeway.ai/v1/images/generations
```

<Tip>
  You can also generate images **inside a chat conversation** by appending an image model tag to any text model (e.g. `qwen3.8-max-preview@flux-2-turbo`). See [Server Tools](/guides/chat-completions/server-tools).
</Tip>

## Quick Example

<Tabs>
  <Tab title="Python">
    ```python theme={null}
    import os
    from openai import OpenAI

    client = OpenAI(
        base_url="https://api.routeway.ai/v1",
        api_key=os.getenv("ROUTEWAY_API_KEY"),
    )

    response = client.images.generate(
        model="gpt-image-1",
        prompt="A futuristic cityscape at sunset with flying cars",
        size="1024x1024",
        quality="auto",
        n=1,
    )

    print(response.data[0].url)
    ```
  </Tab>

  <Tab title="Node.js">
    ```javascript theme={null}
    import OpenAI from "openai";

    const client = new OpenAI({
      baseURL: "https://api.routeway.ai/v1",
      apiKey: process.env.ROUTEWAY_API_KEY,
    });

    const response = await client.images.generate({
      model: "gpt-image-1",
      prompt: "A futuristic cityscape at sunset with flying cars",
      size: "1024x1024",
      quality: "auto",
      n: 1,
    });

    console.log(response.data[0].url);
    ```
  </Tab>

  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST https://api.routeway.ai/v1/images/generations \
      -H "Authorization: Bearer $ROUTEWAY_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "gpt-image-1",
        "prompt": "A futuristic cityscape at sunset with flying cars",
        "size": "1024x1024",
        "quality": "auto",
        "n": 1
      }'
    ```
  </Tab>
</Tabs>

## Response

The API returns an array of image objects. Depending on your `response_format`, each object contains either a URL or base64-encoded image data.

```json theme={null}
{
  "created": 1700000000,
  "data": [
    {
      "url": "https://...",
      "b64_json": null
    }
  ]
}
```

## Common Parameters

| Parameter         | Type    | Description                                                    |
| ----------------- | ------- | -------------------------------------------------------------- |
| `model`           | string  | The model to use (e.g. `gpt-image-1`).                         |
| `prompt`          | string  | A text description of the desired image.                       |
| `n`               | integer | Number of images to generate (default: 1).                     |
| `size`            | string  | Image dimensions (e.g. `1024x1024`, `1792x1024`, `1024x1792`). |
| `quality`         | string  | Quality level — `auto`, `low`, `medium`, or `high`.            |
| `response_format` | string  | `url` or `b64_json`.                                           |

## Learn More

<CardGroup cols={2}>
  <Card title="Generating Images" icon="wand-sparkles" href="/guides/image-generation/generating-images">
    Create images from text prompts with full control over size, quality, and format.
  </Card>

  <Card title="Editing Images" icon="pencil" href="/guides/image-generation/editing-images">
    Modify existing images using text prompts and optional masks.
  </Card>
</CardGroup>
