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

# Generate image

> Generate a new image from a text prompt. Unsupported fields are rejected.



## OpenAPI

````yaml POST /images/generations
openapi: 3.1.0
info:
  title: LLM7 Image API
  description: Generate and edit images through the LLM7 gateway.
  version: 1.0.0
servers:
  - url: https://api.llm7.io/v1
security:
  - bearerAuth: []
paths:
  /images/generations:
    post:
      summary: Generate image
      description: >-
        Generate a new image from a text prompt. Unsupported fields are
        rejected.
      operationId: createImageGeneration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              productPhoto:
                summary: Product photo
                value:
                  model: gpt-image-2
                  prompt: >-
                    A clean product photo of a matte black desk lamp on a white
                    desk
                  size: 1024x1024
                  'n': 1
      responses:
        '200':
          description: Generated image response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientBalance'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          $ref: '#/components/responses/RateLimited'
        '502':
          $ref: '#/components/responses/UpstreamInvalidResponse'
        '503':
          $ref: '#/components/responses/UpstreamUnavailable'
components:
  schemas:
    ImageGenerationRequest:
      type: object
      additionalProperties: false
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: Image model ID.
          example: gpt-image-2
        prompt:
          type: string
          description: Text instruction for the image.
        size:
          type: string
          description: Requested output size. Support depends on the selected model.
          example: 1024x1024
        'n':
          type: integer
          description: Number of images to generate. Only 1 is supported.
          enum:
            - 1
          default: 1
    ImageResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: array
          minItems: 1
          maxItems: 1
          items:
            $ref: '#/components/schemas/ImageData'
        usage:
          $ref: '#/components/schemas/ImageUsage'
    ImageData:
      type: object
      required:
        - b64_json
      properties:
        b64_json:
          type: string
          description: Generated or edited image bytes encoded as base64.
    ImageUsage:
      type: object
      properties:
        cost_usd:
          type: string
          description: Decimal USD string for the billed request when cost is available.
          example: '0.01200000'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          $ref: '#/components/schemas/ErrorObject'
    ErrorObject:
      type: object
      required:
        - message
        - type
        - code
      properties:
        message:
          type: string
        type:
          type: string
        param:
          type:
            - string
            - 'null'
        code:
          type: string
  responses:
    BadRequest:
      description: Invalid gateway request or upstream rejected the request.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: Missing or invalid LLM7 token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InsufficientBalance:
      description: No available balance or allowance.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    PayloadTooLarge:
      description: Request body or reference image is too large.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    RateLimited:
      description: Gateway or upstream rate limit.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UpstreamInvalidResponse:
      description: Upstream success response did not match the image contract.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UpstreamUnavailable:
      description: Upstream provider is temporarily unavailable.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````