---
title: "Generate an image"
description: "Generate images from text. Drop-in replacement for OpenAI /v1/images/generations.\n\nSupported models: openai/gpt-image-1.5, openai/dall-e-3,\ngoogle/gemini-3.1-flash-image, google/gemini-3.1-flash-lite-image,\ngoogle/gemini-2.5-flash-image, google/gemini-3-pro-image."
---

> Documentation Index
> Fetch the complete documentation index at: https://truememory-docs.mvstg.com/llms.txt
> Use this file to discover all available pages before exploring further.

Path: AI Gateway API › Chat

`POST /v1/images/generations`

Generate images from text. Drop-in replacement for OpenAI /v1/images/generations.

Supported models: openai/gpt-image-1.5, openai/dall-e-3,
google/gemini-3.1-flash-image, google/gemini-3.1-flash-lite-image,
google/gemini-2.5-flash-image, google/gemini-3-pro-image.

## Authentication

- `HTTPBearer`, http, header `Authorization`

## Header parameters

- `X-On-Behalf-Of` (`create_image.header.X-On-Behalf-Of`; any of, optional)
  - any of: `string`, `null`
- `X-External-User-Id` (`create_image.header.X-External-User-Id`; any of, optional)
  - any of: `string`, `null`
- `X-App-Id` (`create_image.header.X-App-Id`; any of, optional)
  - any of: `string`, `null`

## Request body

_Required._

- `model` (`create_image.model`; string, required) — Model to use, e.g. 'openai/gpt-image-1.5' or 'google/gemini-3.1-flash-image'
- `prompt` (`create_image.prompt`; string, required) — Text description of the desired image
- `n` (`create_image.n`; integer, optional)
  - min 1; max 10; default `1`
- `size` (`create_image.size`; any of, optional) — Image size, e.g. '1024x1024'
  - any of: `string`, `null`
- `quality` (`create_image.quality`; any of, optional) — Image quality, e.g. 'auto', 'hd'
  - any of: `string`, `null`
- `response_format` (`create_image.response_format`; string, optional) — Response format. Google models always return b64_json.
  - one of `"url"`, `"b64_json"`; default `"b64_json"`
- `style` (`create_image.style`; any of, optional) — Image style (dall-e-3 only)
  - any of: `string`, `null`

## Example request

```json
{
  "model": "string",
  "prompt": "string",
  "n": 1,
  "size": "string",
  "quality": "string",
  "response_format": "url",
  "style": "string"
}
```

## Code samples

### cURL

```bash
curl --request POST \
  --url https://truememory-api.mvstg.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "string",
  "prompt": "string",
  "n": 1,
  "size": "string",
  "quality": "string",
  "response_format": "url",
  "style": "string"
}
'
```

### TypeScript

```typescript
const url = 'https://truememory-api.mvstg.com/v1/images/generations';
const options = {
  method: 'POST',
  headers: {'Content-Type': 'application/json', Authorization: 'Bearer <token>'},
  body: JSON.stringify({
    model: 'string',
    prompt: 'string',
    n: 1,
    size: 'string',
    quality: 'string',
    response_format: 'url',
    style: 'string'
  })
};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://truememory-api.mvstg.com/v1/images/generations"

payload = {
    "model": "string",
    "prompt": "string",
    "n": 1,
    "size": "string",
    "quality": "string",
    "response_format": "url",
    "style": "string"
}
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
```

## Responses

### 200

Successful Response

#### Example

```json
{
  "created": 0,
  "data": [
    {
      "b64_json": "string",
      "url": "string",
      "revised_prompt": "string"
    }
  ]
}
```

- `created` (`create_image.response.200.created`; integer, required)
- `data` (`create_image.response.200.data`; array<object>, required)
  - `b64_json` (`create_image.response.200.data.b64_json`; any of, optional)
    - any of: `string`, `null`
  - `url` (`create_image.response.200.data.url`; any of, optional)
    - any of: `string`, `null`
  - `revised_prompt` (`create_image.response.200.data.revised_prompt`; any of, optional)
    - any of: `string`, `null`

### 422

Validation Error

#### Example

```json
{
  "detail": [
    {
      "loc": [
        "string"
      ],
      "msg": "string",
      "type": "string",
      "input": null,
      "ctx": {}
    }
  ]
}
```

- `detail` (`create_image.response.422.detail`; array<object>, optional)
  - `loc` (`create_image.response.422.detail.loc`; array<any of>, required)
    - any of: `string`, `integer`
  - `msg` (`create_image.response.422.detail.msg`; string, required)
  - `type` (`create_image.response.422.detail.type`; string, required)
  - `input` (`create_image.response.422.detail.input`; unknown, optional)
  - `ctx` (`create_image.response.422.detail.ctx`; object, optional)


Source: https://truememory-docs.mvstg.com/api/images/generations/index.md
