---
title: "Create an image"
description: "Draws images from a prompt. Follows OpenAI's Images API, and Gemini, Bedrock, MiniMax, Qwen, xAI, Together AI and other providers answer it. A field a provider has no place for is not sent to it. Each call is logged as one `image` row with its cost."
---

<a id="playground-button:docs/apis/gateway/create-image"></a>

**POST** `https://gateway.respan.ai/v1/images/generations`

Draws images from a prompt. Follows OpenAI's Images API, and Gemini, Bedrock, MiniMax, Qwen, xAI, Together AI and other providers answer it. A field a provider has no place for is not sent to it. Each call is logged as one `image` row with its cost.

## Servers

`https://gateway.respan.ai`: Respan gateway

## Authentication

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


## Request body

A request body is required.

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | Additional properties are allowed |
| `model` | `string` | Required in parent | The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one. |
| `prompt` | `string` | Required in parent | What to draw, or how to change the images. |
| `n` | `integer` | Optional | How many images to make. |
| `size` | `string` | Optional | Exact pixels, such as `1024x1024`. `auto` sends none. |
| `aspect_ratio` | `string` | Optional | The shape alone, such as `16:9`. |
| `resolution` | `string` | Optional | The provider's named tier, such as `2K`. |
| `seed` | `integer` | Optional | A number that makes a draw repeat. |
| `negative_prompt` | `string` | Optional | What to leave out. |
| `output_format` | `string` | Optional | The file format of the images, such as `png`. |
| `quality` | `string` | Optional | OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it. |
| `background` | `string` | Optional | OpenAI's own field. MiniMax refuses `transparent` with `400`. |
| `response_format` | `string` | Optional | `b64_json` or `url`, as the provider takes it. Qwen answers URLs only. |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "type": "object",
  "required": [
    "model",
    "prompt"
  ],
  "properties": {
    "model": {
      "type": "string",
      "description": "The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one."
    },
    "prompt": {
      "type": "string",
      "description": "What to draw, or how to change the images."
    },
    "n": {
      "type": "integer",
      "description": "How many images to make."
    },
    "size": {
      "type": "string",
      "description": "Exact pixels, such as `1024x1024`. `auto` sends none."
    },
    "aspect_ratio": {
      "type": "string",
      "description": "The shape alone, such as `16:9`."
    },
    "resolution": {
      "type": "string",
      "description": "The provider's named tier, such as `2K`."
    },
    "seed": {
      "type": "integer",
      "description": "A number that makes a draw repeat."
    },
    "negative_prompt": {
      "type": "string",
      "description": "What to leave out."
    },
    "output_format": {
      "type": "string",
      "description": "The file format of the images, such as `png`."
    },
    "quality": {
      "type": "string",
      "description": "OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it."
    },
    "background": {
      "type": "string",
      "description": "OpenAI's own field. MiniMax refuses `transparent` with `400`."
    },
    "response_format": {
      "type": "string",
      "description": "`b64_json` or `url`, as the provider takes it. Qwen answers URLs only."
    }
  },
  "additionalProperties": true
}
```

</details>

##### OpenAI


```json
{
  "model": "gpt-image-1",
  "prompt": "A lighthouse at dusk, watercolor"
}
```


##### Gemini with shape and tier


```json
{
  "model": "gemini/gemini-3.1-flash-image",
  "prompt": "A lighthouse at dusk, watercolor",
  "aspect_ratio": "16:9",
  "resolution": "2K"
}
```


## Responses

### 200

Images in OpenAI's Images shape. Each item of `data` holds a `b64_json` or a `url`, as the provider returns it.

#### Response headers


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| `X-Respan-Log-Id` | `string` | Optional | ID of the Respan request log for this call. |


#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |
| `created` | `integer` | Optional | - |
| `data` | `array<object>` | Optional | - |
| `data[]` | `object` | Array item | Additional properties are allowed |
| `data[].b64_json` | `string` | Optional | - |
| `data[].url` | `string` | Optional | - |
| `data[].revised_prompt` | `string` | Optional | - |
| `usage` | `object` | Optional | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "created": {
      "type": "integer"
    },
    "data": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "b64_json": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "revised_prompt": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    },
    "usage": {
      "type": "object",
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
```

</details>

### 400

The request is malformed, or a field is one the provider cannot take. Fields refused before the call say which one.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": true
}
```

</details>

### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 429

A rate limit or usage limit was reached. Retry with exponential backoff.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | Additional properties are allowed |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": true
}
```

</details>

## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Create an image",
  "operationId": "createImage",
  "tags": [
    "Gateway"
  ],
  "servers": [
    {
      "url": "https://gateway.respan.ai",
      "description": "Respan gateway"
    }
  ],
  "description": "Draws images from a prompt. Follows OpenAI's Images API, and Gemini, Bedrock, MiniMax, Qwen, xAI, Together AI and other providers answer it. A field a provider has no place for is not sent to it. Each call is logged as one `image` row with its cost.",
  "security": [
    {
      "RespanApiKey": []
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "required": [
            "model",
            "prompt"
          ],
          "properties": {
            "model": {
              "type": "string",
              "description": "The image model, such as `gpt-image-1`. A bare name goes to any provider that serves it; prefix it to pin one."
            },
            "prompt": {
              "type": "string",
              "description": "What to draw, or how to change the images."
            },
            "n": {
              "type": "integer",
              "description": "How many images to make."
            },
            "size": {
              "type": "string",
              "description": "Exact pixels, such as `1024x1024`. `auto` sends none."
            },
            "aspect_ratio": {
              "type": "string",
              "description": "The shape alone, such as `16:9`."
            },
            "resolution": {
              "type": "string",
              "description": "The provider's named tier, such as `2K`."
            },
            "seed": {
              "type": "integer",
              "description": "A number that makes a draw repeat."
            },
            "negative_prompt": {
              "type": "string",
              "description": "What to leave out."
            },
            "output_format": {
              "type": "string",
              "description": "The file format of the images, such as `png`."
            },
            "quality": {
              "type": "string",
              "description": "OpenAI's own field. Providers of OpenAI's format get it as sent; Gemini, Bedrock and Qwen drop it."
            },
            "background": {
              "type": "string",
              "description": "OpenAI's own field. MiniMax refuses `transparent` with `400`."
            },
            "response_format": {
              "type": "string",
              "description": "`b64_json` or `url`, as the provider takes it. Qwen answers URLs only."
            }
          },
          "additionalProperties": true
        },
        "examples": {
          "openai": {
            "summary": "OpenAI",
            "value": {
              "model": "gpt-image-1",
              "prompt": "A lighthouse at dusk, watercolor"
            }
          },
          "gemini": {
            "summary": "Gemini with shape and tier",
            "value": {
              "model": "gemini/gemini-3.1-flash-image",
              "prompt": "A lighthouse at dusk, watercolor",
              "aspect_ratio": "16:9",
              "resolution": "2K"
            }
          }
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Images in OpenAI's Images shape. Each item of `data` holds a `b64_json` or a `url`, as the provider returns it.",
      "headers": {
        "X-Respan-Log-Id": {
          "description": "ID of the Respan request log for this call.",
          "schema": {
            "type": "string"
          }
        }
      },
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "created": {
                "type": "integer"
              },
              "data": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "b64_json": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "revised_prompt": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              },
              "usage": {
                "type": "object",
                "additionalProperties": true
              }
            },
            "additionalProperties": true
          }
        }
      }
    },
    "400": {
      "description": "The request is malformed, or a field is one the provider cannot take. Fields refused before the call say which one.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "429": {
      "description": "A rate limit or usage limit was reached. Retry with exponential backoff.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": true
          }
        }
      }
    }
  }
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
