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

# Create Image

> Generate images from a text prompt using image generation models

Generate images from a text prompt using OpenAI-compatible image generation models through Requesty's routing.

## Base URL

```
https://router.requesty.ai/v1/images/generations
```

## Authentication

Include your Requesty API key in the request headers:

```bash theme={"dark"}
Authorization: Bearer YOUR_REQUESTY_API_KEY
```

## Example Request

```bash theme={"dark"}
curl https://router.requesty.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_REQUESTY_API_KEY" \
  -d '{
    "model": "azure/openai/gpt-image-1",
    "prompt": "A watercolor painting of a Japanese garden in autumn",
    "n": 1,
    "size": "1024x1024",
    "quality": "auto"
  }'
```

## Supported Models

* `azure/openai/gpt-image-1` -- OpenAI's GPT Image 1 model via Azure
* `azure/openai/gpt-image-1.5` -- OpenAI's GPT Image 1.5 model via Azure

## Transparent Backgrounds

Use the `background` parameter to generate images with transparent backgrounds (useful for logos, icons, and design assets):

```bash theme={"dark"}
curl https://router.requesty.ai/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_REQUESTY_API_KEY" \
  -d '{
    "model": "azure/openai/gpt-image-1",
    "prompt": "A simple icon of a rocket ship",
    "background": "transparent",
    "output_format": "png"
  }'
```

## Error Handling

The API returns standard HTTP status codes:

* `200` - Success
* `400` - Bad Request (invalid parameters)
* `401` - Unauthorized (invalid API key)
* `429` - Rate Limited
* `500` - Internal Server Error

<Info>
  This endpoint is fully compatible with the OpenAI Images API. You can use the OpenAI SDK's `client.images.generate()` method directly.
</Info>

<Tip>
  To edit or extend an existing image instead of generating a new one, use the [Edit Image endpoint](/api-reference/endpoint/images-edits-create). For models that generate images as part of a conversational response (e.g., Gemini), use the [Chat Completions endpoint](/api-reference/endpoint/chat-completions-create) instead. See the [Image Generation feature guide](/features/image-generation) for a full comparison.
</Tip>


## OpenAPI

````yaml POST /v1/images/generations
openapi: 3.0.3
info:
  title: Requesty API
  description: Requesty API for AI model routing and key management
  version: 1.0.0
servers:
  - url: https://api-v2.requesty.ai
    description: Management API endpoint
  - url: https://router.requesty.ai
    description: Inference router endpoint
security:
  - BearerAuth: []
paths:
  /v1/images/generations:
    servers:
      - url: https://router.requesty.ai
        description: Inference router endpoint
    post:
      summary: Create image
      description: Generate images from a text prompt using image generation models
      operationId: createImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
      responses:
        '200':
          description: Image generation response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
        '400':
          description: Bad request - malformed payload or invalid parameters.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or empty Authorization header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '402':
          description: Payment required - organization balance exhausted.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - invalid token or model not in access list.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Not found - provider/model not supported.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded. Retry after the Retry-After header value.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Bad gateway - upstream provider returned an invalid response.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ImageGenerationRequest:
      type: object
      required:
        - prompt
        - model
      properties:
        model:
          type: string
          description: The model to use for image generation
          example: azure/openai/gpt-image-1
        prompt:
          type: string
          description: A text description of the desired image
          example: A watercolor painting of a Japanese garden in autumn
        'n':
          type: integer
          description: The number of images to generate
          default: 1
          minimum: 1
          example: 1
        size:
          type: string
          description: The size of the generated images
          enum:
            - 1024x1024
            - 1536x1024
            - 1024x1536
          default: 1024x1024
          example: 1024x1024
        quality:
          type: string
          description: The quality of the generated image
          enum:
            - auto
            - high
            - medium
            - low
          default: auto
          example: auto
        response_format:
          type: string
          description: The format in which the generated images are returned
          enum:
            - url
            - b64_json
          default: url
          example: url
        background:
          type: string
          description: The background type for the generated image
          enum:
            - auto
            - transparent
            - opaque
          default: auto
          example: auto
        output_format:
          type: string
          description: The file format of the generated image
          enum:
            - png
            - jpeg
            - webp
          default: png
          example: png
    ImageGenerationResponse:
      type: object
      required:
        - created
        - data
      properties:
        created:
          type: integer
          description: The Unix timestamp of when the image was created
          example: 1719000000
        data:
          type: array
          items:
            $ref: '#/components/schemas/ImageData'
          description: The list of generated images
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - origin
            - message
          properties:
            origin:
              type: string
              enum:
                - router
                - provider
              description: >-
                Whether the error originated from Requesty's router or an
                upstream provider.
            message:
              type: string
              description: Human-readable error description.
    ImageData:
      type: object
      properties:
        url:
          type: string
          description: The URL of the generated image (when response_format is url)
        b64_json:
          type: string
          description: >-
            The base64-encoded JSON of the generated image (when response_format
            is b64_json)
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````