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

# Generate an image

> Generate an image and return the completed result.




## OpenAPI

````yaml /openapi.yaml post /v2/images/generations
openapi: 3.1.0
info:
  title: getimg.ai API
  version: 2.0.0
  description: |
    The getimg.ai API for image and video generation.

    Authenticate with a bearer token in the format `sk_<secret>`.
servers:
  - url: https://api.getimg.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Images
    description: Endpoints for image generation.
  - name: Models
    description: Endpoints for listing available developer models.
  - name: Videos
    description: Endpoints for video generation.
paths:
  /v2/images/generations:
    post:
      tags:
        - Images
      summary: Generate an image
      description: |
        Generate an image and return the completed result.
      operationId: createImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              basic:
                summary: Basic image generation
                value:
                  model: seedream-5-lite
                  prompt: A cinematic portrait of a cat astronaut
                  aspect_ratio: '1:1'
                  resolution: 2K
                  output_format: jpeg
              with_reference:
                summary: Image generation with references
                value:
                  model: seedream-5-lite
                  prompt: Product photo in warm studio lighting
                  images:
                    - url: https://assets.example.com/reference-1.png
                      role: reference_image
                  aspect_ratio: '16:9'
                  resolution: 2K
                  output_format: webp
      responses:
        '200':
          description: Image generation completed.
          headers:
            X-RateLimit-Limit:
              $ref: '#/components/headers/X-RateLimit-Limit'
            X-RateLimit-Remaining:
              $ref: '#/components/headers/X-RateLimit-Remaining'
            X-RateLimit-Reset:
              $ref: '#/components/headers/X-RateLimit-Reset'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageGenerationResponse'
              examples:
                completed:
                  summary: Completed image generation
                  value:
                    id: req-01HXYZABCD1234
                    status: completed
                    model: seedream-5-lite
                    data:
                      - url: >-
                          https://api.getimg.ai/v2/downloads/req-01HXYZABCD1234/0?exp=1760000000&sig=1d9c2f6f4f7f6c03e5c58a4e6fd8b5b8e2d0c2f5f9e1a4cfe8c0e9d9a8b7c6d5
                        width: 1024
                        height: 1024
                        mime_type: image/png
                        deletes_at: '2026-05-02T12:30:00.000Z'
                    usage:
                      total_cost: 0.04
                      billable_unit: image
                      unit_price: 0.04
                      quantity: 1
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/QuotaExceededError'
        '422':
          $ref: '#/components/responses/ContentPolicyViolationError'
        '429':
          $ref: '#/components/responses/RateLimitError'
        '500':
          $ref: '#/components/responses/ServerError'
      x-codeSamples:
        - lang: javascript
          label: Node.js
          source: |
            import GetimgAI from "getimg-ai";

            const client = new GetimgAI();

            const result = await client.images.generate({
              model: "seedream-5-lite",
              prompt: "A cinematic portrait of a cat astronaut",
              aspect_ratio: "1:1",
              resolution: "2K",
              output_format: "jpeg",
            });
        - lang: python
          label: Python
          source: |
            from getimg import GetimgAI

            client = GetimgAI()

            result = client.images.generate(
                model="seedream-5-lite",
                prompt="A cinematic portrait of a cat astronaut",
                aspect_ratio="1:1",
                resolution="2K",
                output_format="jpeg",
            )
components:
  schemas:
    ImageGenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: >
            AI model ID. See [supported
            models](https://getimg.ai/app/developer/models).
        prompt:
          type: string
          minLength: 1
          maxLength: 4096
          description: |
            Description of the image to generate or an editing instruction.
        images:
          type: array
          maxItems: 8
          items:
            $ref: '#/components/schemas/ImageReference'
        aspect_ratio:
          type: string
          description: >
            Optional output aspect ratio. 

            See [supported values by
            model](https://getimg.ai/app/developer/models).
        resolution:
          type: string
          description: >
            Optional output resolution.

            See [supported values by
            model](https://getimg.ai/app/developer/models).
        output_format:
          type: string
          enum:
            - png
            - jpeg
            - webp
          default: jpeg
          description: |
            Output image format.
    ImageGenerationResponse:
      type: object
      required:
        - id
        - status
        - model
        - data
        - usage
      properties:
        id:
          type: string
          description: The ID of the generation request.
        status:
          type: string
          const: completed
        model:
          type: string
          description: The model used for the generation.
        data:
          type: array
          description: The media items for the generation.
          items:
            $ref: '#/components/schemas/ImageDataItem'
        usage:
          $ref: '#/components/schemas/Usage'
    ImageReference:
      type: object
      required:
        - url
      properties:
        url:
          type: string
          description: |
            Publicly accessible reference image URL.
          minLength: 1
    ImageDataItem:
      type: object
      required:
        - url
        - mime_type
        - deletes_at
      properties:
        url:
          type: string
          description: Signed temporary download URL.
        width:
          anyOf:
            - type: integer
            - type: 'null'
          description: The width of the image in pixels.
        height:
          anyOf:
            - type: integer
            - type: 'null'
          description: The height of the image in pixels.
        mime_type:
          type: string
          description: The MIME type of the image.
        deletes_at:
          type: string
          format: date-time
          description: The date and time the image will be deleted.
    Usage:
      type: object
      required:
        - total_cost
        - billable_unit
        - unit_price
        - quantity
      properties:
        total_cost:
          type: number
          description: Total cost of the generation.
        billable_unit:
          type: string
          description: The unit of the cost.
        unit_price:
          type: number
          description: The price of the unit.
        quantity:
          type: number
          description: The quantity of the generation.
    PublicApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
            - param
            - code
          properties:
            message:
              type: string
            type:
              type: string
              const: invalid_request_error
            param:
              anyOf:
                - type: string
                - type: 'null'
            code:
              type: string
              enum:
                - invalid_api_key
                - parameter_missing
                - invalid_parameter
                - quota_exceeded
                - rate_limit
                - content_policy_violation
                - not_found
                - server_error
            doc_url:
              type: string
              format: uri
  headers:
    X-RateLimit-Limit:
      description: Maximum requests allowed in the current rate-limit window.
      schema:
        type: string
        pattern: ^[0-9]+$
      example: '60'
    X-RateLimit-Remaining:
      description: Remaining requests in the current rate-limit window.
      schema:
        type: string
        pattern: ^[0-9]+$
      example: '59'
    X-RateLimit-Reset:
      description: Unix timestamp (seconds) when the current rate-limit window resets.
      schema:
        type: string
        pattern: ^[0-9]+$
      example: '1760000042'
    Retry-After:
      description: Number of seconds to wait before retrying.
      schema:
        type: string
        pattern: ^[0-9]+$
      example: '42'
  responses:
    BadRequestError:
      description: The request payload or parameters are invalid.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicApiError'
          examples:
            invalid_parameter:
              value:
                error:
                  message: Unsupported resolution '4K' for model 'seedream-5-lite'.
                  type: invalid_request_error
                  param: resolution
                  code: invalid_parameter
            parameter_missing:
              value:
                error:
                  message: Required parameter 'prompt' is missing.
                  type: invalid_request_error
                  param: prompt
                  code: parameter_missing
    UnauthorizedError:
      description: Authentication failed due to a missing or invalid API key.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicApiError'
          examples:
            invalid_api_key:
              value:
                error:
                  message: >-
                    Incorrect API key provided. You can manage your API keys at
                    https:/getimg.ai/developer/api-keys
                  type: invalid_request_error
                  param: null
                  code: invalid_api_key
                  doc_url: https://docs.getimg.ai/#topic-authentication
    QuotaExceededError:
      description: Your account or project quota is insufficient for this request.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicApiError'
          examples:
            quota_exceeded:
              value:
                error:
                  message: Quota exceeded.
                  type: invalid_request_error
                  param: null
                  code: quota_exceeded
    ContentPolicyViolationError:
      description: The prompt or input images failed content policy checks.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicApiError'
          examples:
            moderated:
              value:
                error:
                  message: Image or text contains sensitive content.
                  type: invalid_request_error
                  param: null
                  code: content_policy_violation
    RateLimitError:
      description: A rate or concurrency limit was exceeded.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
        Retry-After:
          $ref: '#/components/headers/Retry-After'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicApiError'
          examples:
            rate_limited:
              value:
                error:
                  message: Too many requests hit the API too quickly.
                  type: invalid_request_error
                  param: null
                  code: rate_limit
    ServerError:
      description: An unexpected server error occurred.
      headers:
        X-RateLimit-Limit:
          $ref: '#/components/headers/X-RateLimit-Limit'
        X-RateLimit-Remaining:
          $ref: '#/components/headers/X-RateLimit-Remaining'
        X-RateLimit-Reset:
          $ref: '#/components/headers/X-RateLimit-Reset'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PublicApiError'
          examples:
            server_error:
              value:
                error:
                  message: Something went wrong on our end.
                  type: invalid_request_error
                  param: null
                  code: server_error
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: |
        Send your API key as a bearer token:
        `Authorization: Bearer sk_<secret>`.

````