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

# Create image generation task

> Creates an asynchronous image generation task and returns a task ID.



## OpenAPI

````yaml /openapi.json post /v1/images/generations
openapi: 3.1.0
info:
  title: APIAny.AI Public API
  version: 1.0.0
  description: >-
    Public API for APIAny.AI model aggregation, async media tasks, chat
    completions, billing visibility, and task lookup.
servers:
  - url: https://apiany.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Models
    description: Public model catalog.
  - name: Chat
    description: Text generation and chat-compatible endpoints.
  - name: Images
    description: Image generation and editing endpoints.
  - name: Videos
    description: Video generation endpoints.
  - name: Moderation
    description: Image safety and moderation endpoints.
  - name: Tasks
    description: Async task lookup.
  - name: Account
    description: Account and credit visibility.
  - name: Free APIs
    description: Free utility APIs protected by API key rate limits.
paths:
  /v1/images/generations:
    post:
      tags:
        - Images
      summary: Create image generation task
      description: Creates an asynchronous image generation task and returns a task ID.
      operationId: createImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              textToImage:
                value:
                  model: nano-banana
                  prompt: A clean product hero image for an AI API gateway
                  size: 1k
              gptImage2NativeSize:
                value:
                  model: gpt-image-2
                  prompt: A cinematic landscape product launch visual
                  size: 2048x1152
                  quality: high
                  'n': 1
              withReferences:
                value:
                  model: nano-banana-pro
                  prompt: Create a premium ecommerce hero image using these references
                  size: 2k
                  input_images:
                    - https://example.com/reference-1.png
                    - https://example.com/reference-2.png
      responses:
        '202':
          description: Task created.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AsyncTaskCreateResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
components:
  schemas:
    ImageGenerationRequest:
      oneOf:
        - $ref: '#/components/schemas/GPTImage2GenerationRequest'
        - $ref: '#/components/schemas/GenericImageGenerationRequest'
    AsyncTaskCreateResponse:
      type: object
      properties:
        task_id:
          type: string
          example: task_123
        status:
          type: string
          enum:
            - pending
            - processing
        model:
          type: string
        poll_url:
          type: string
          example: /v1/tasks/task_123
      required:
        - task_id
        - status
        - poll_url
    GPTImage2GenerationRequest:
      type: object
      properties:
        model:
          type: string
          const: gpt-image-2
        prompt:
          type: string
        size:
          type: string
          description: >-
            Accepts auto, a positive WIDTHxHEIGHT target, or ratio shorthand
            such as 16:9. Every non-auto target is mapped to the nearest
            official popular size: 1024x1024, 1536x1024, 1024x1536, 2048x2048,
            2048x1152, 3840x2160, or 2160x3840.
          examples:
            - auto
            - 1024x1024
            - 1280x720
            - '16:9'
        quality:
          type: string
          description: GPT-Image 2 rendering quality.
          enum:
            - auto
            - low
            - medium
            - high
          default: auto
        'n':
          type: integer
          minimum: 1
          maximum: 10
          description: Number of images to generate. Billing scales with the image count.
          default: 1
        aspect_ratio:
          type: string
          description: >-
            Deprecated ratio shorthand. The ratio and compatibility tier are
            mapped to the nearest official popular size.
          deprecated: true
        resolution:
          type: string
          description: >-
            Deprecated compatibility tier used to form the target size before
            nearest-official-size mapping.
          enum:
            - 1K
            - 2K
            - 4K
          deprecated: true
        input_images:
          type: array
          items:
            type: string
            format: uri
        callback_url:
          type: string
          format: uri
      required:
        - model
        - prompt
    GenericImageGenerationRequest:
      type: object
      properties:
        model:
          type: string
          not:
            const: gpt-image-2
          example: nano-banana
        prompt:
          type: string
        size:
          type: string
          description: Model-specific image size or aspect ratio shorthand.
          example: 1k
        input_images:
          type: array
          items:
            type: string
            format: uri
        callback_url:
          type: string
          format: uri
      required:
        - model
        - prompt
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              enum:
                - invalid_request
                - auth_error
                - rate_limit
                - insufficient_quota
                - content_policy
                - timeout
                - network_error
                - service_error
                - billable_error
                - unknown
            message:
              type: string
            param:
              type:
                - string
                - 'null'
            code:
              type:
                - string
                - 'null'
          required:
            - type
            - message
      required:
        - error
  responses:
    BadRequest:
      description: Invalid request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid API key.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API key

````