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

# Generate images

> Generates images from a text prompt. Supports models from OpenAI (gpt-image-1, gpt-image-2)
and Google Gemini (Gemini image models).

OpenAI models accept size values like `1024x1024`, `1536x1024`, `1024x1536`, or `auto`.
Gemini models accept aspect ratio values like `1:1`, `2:3`, `16:9`, etc.



## OpenAPI

````yaml /spec/ai-image-generation.yaml post /api/{workspaceID}/v1/images/generations
openapi: 3.0.1
info:
  title: AI - Image Generation
  description: >-
    Generate and edit images using AI models. Supports OpenAI and Google Gemini
    providers.


    Parameters:

    - `workspaceID`: The ID of the workspace to use for billing

    - `teamID`: To access services in a team (query param or `x-teamid` header)


    Authentication: API Key (Bearer token) sent via the `Authorization` header.
  termsOfService: '#'
  contact:
    email: info@liara.ir
  version: 1.0.0
servers:
  - url: https://ai.liara.ir
security:
  - apiKey: []
tags:
  - name: Image Generations
    description: Generate images from text prompts
  - name: Image Edits
    description: Edit existing images with prompts
externalDocs:
  description: Find out more about Liara AI
  url: https://liara.ir
paths:
  /api/{workspaceID}/v1/images/generations:
    post:
      tags:
        - Image Generations
      summary: Generate images
      description: >-
        Generates images from a text prompt. Supports models from OpenAI
        (gpt-image-1, gpt-image-2)

        and Google Gemini (Gemini image models).


        OpenAI models accept size values like `1024x1024`, `1536x1024`,
        `1024x1536`, or `auto`.

        Gemini models accept aspect ratio values like `1:1`, `2:3`, `16:9`, etc.
      operationId: generateImage
      parameters:
        - name: workspaceID
          in: path
          required: true
          description: The workspace ID
          schema:
            type: string
            pattern: ^[a-f0-9]{24}$
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationsRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
        '400':
          description: Bad request
          content: {}
        '401':
          description: Missing authentication
          content: {}
        '402':
          description: Payment required - insufficient balance
          content: {}
        '503':
          description: Service unavailable (feature disabled)
          content: {}
components:
  schemas:
    ImageGenerationsRequest:
      type: object
      required:
        - prompt
        - model
      properties:
        prompt:
          type: string
          description: Text description of the desired image
        model:
          type: string
          description: |-
            Image generation model ID. Supported models:
            - `google/gemini-2.5-flash-image`
            - `google/gemini-3-pro-image-preview`
            - `openai/gpt-image-2`
            - `openai/gpt-image-1.5`
            - `openai/gpt-image-1`
            - `openai/gpt-image-1-mini`
          default: openai/gpt-image-1
        'n':
          type: number
          description: Number of images to generate (1-10)
        size:
          type: string
          description: |-
            Image size. OpenAI: `auto`, `1024x1024`, `1536x1024`, `1024x1536`.
            Gemini: aspect ratios like `1:1`, `2:3`, `16:9`.
        quality:
          type: string
          description: |-
            Image quality. OpenAI: `auto`, `low`, `medium`, `high`.
            Gemini: `1K`, `2K`, `4K`.
        background:
          type: string
          description: Background setting
        moderation:
          type: string
          description: Content moderation level
        output_format:
          type: string
          enum:
            - png
            - jpeg
            - webp
          description: Output image format
        output_compression:
          type: number
          description: Compression level for jpeg/webp
        partial_images:
          type: number
          description: Number of partial images for progressive loading
        response_format:
          type: string
          description: Response format (url or b64_json)
        stream:
          type: boolean
          description: Enable streaming
        style:
          type: string
          description: Image style
        user:
          type: string
          description: End-user identifier
    ImageResponse:
      type: object
      properties:
        id:
          type: string
          description: Log ID
        created:
          type: integer
          format: unix-timestamp
        data:
          type: array
          items:
            type: object
            properties:
              url:
                type: string
                format: uri
                description: Image URL (when response_format is url)
              b64_json:
                type: string
                description: Base64-encoded image data (when response_format is b64_json)
              revised_prompt:
                type: string
                description: Revised prompt used by the model
        usage:
          type: object
          properties:
            total_cost:
              type: number
              description: Total cost in USD
            total_cost_toman:
              type: number
              description: Total cost in Tomans
  securitySchemes:
    apiKey:
      type: apiKey
      description: >-
        Enter the API key with the `Bearer: ` prefix, e.g. "Bearer
        <your-api-key>"
      name: Authorization
      in: header

````