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

# Generate Image

> OpenAI-compatible image generation endpoint.

> **Note:** The image response may not render in GitBook's "Test it" panel.
> To view the generated image, try this endpoint with Postman, curl, or
> another HTTP client.



## OpenAPI

````yaml /api/openapi.json post /v1/images/generations
openapi: 3.1.0
info:
  title: MeshAPI
  description: One key, all AI models.
  version: 0.1.0
servers:
  - url: https://api.meshapi.ai
security:
  - BearerAuth: []
paths:
  /v1/images/generations:
    post:
      tags:
        - Images
      summary: Generate Image
      description: >-
        OpenAI-compatible image generation endpoint.


        > **Note:** The image response may not render in GitBook's "Test it"
        panel.

        > To view the generated image, try this endpoint with Postman, curl, or

        > another HTTP client.
      operationId: generate_image
      parameters:
        - in: header
          name: X-Mesh-Version
          required: false
          schema:
            type: string
            enum:
              - 2026-08
            default: 2026-08
          example: 2026-08
          description: >-
            Dated version of the API contract to pin this request to. Omit it
            and the request is served under `2026-08` — the oldest supported
            version, so an existing integration is never moved by a release. A
            malformed or unsupported value is rejected with `400
            invalid_api_version` rather than falling back silently. The version
            actually served is echoed as `X-Mesh-Version` on every response,
            including errors.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageGenerationRequest'
            examples:
              default:
                summary: Example request
                value:
                  model: openai/gpt-image-1
                  prompt: >-
                    A clean product photo of a stainless steel water bottle on a
                    white table
                  size: 1024x1024
                  response_format: url
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema: {}
              examples:
                default:
                  summary: Example response
                  value:
                    created: 1783001227
                    data:
                      - url: >-
                          https://images.example.com/generations/water-bottle.png
        '401':
          description: Missing or invalid API key
        '402':
          description: Insufficient balance or spend cap reached
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Rate limit exceeded
        '500':
          description: Upstream provider error
        '501':
          description: Provider does not support image generation
      security:
        - BearerAuth: []
components:
  schemas:
    ImageGenerationRequest:
      properties:
        prompt:
          type: string
          title: Prompt
        model:
          anyOf:
            - type: string
            - type: 'null'
          title: Model
        'n':
          type: integer
          maximum: 10
          minimum: 1
          title: 'N'
          default: 1
        quality:
          type: string
          title: Quality
          default: auto
        response_format:
          type: string
          enum:
            - url
            - b64_json
          title: Response Format
          default: url
        size:
          type: string
          title: Size
          default: auto
        aspect_ratio:
          anyOf:
            - type: string
            - type: 'null'
          title: Aspect Ratio
        resolution:
          anyOf:
            - type: string
            - type: 'null'
          title: Resolution
        output_format:
          anyOf:
            - type: string
              enum:
                - png
                - jpeg
                - webp
            - type: 'null'
          title: Output Format
        output_compression:
          anyOf:
            - type: integer
              maximum: 100
              minimum: 0
            - type: 'null'
          title: Output Compression
        background:
          anyOf:
            - type: string
              enum:
                - transparent
                - opaque
                - auto
            - type: 'null'
          title: Background
        moderation:
          anyOf:
            - type: string
              enum:
                - low
                - auto
            - type: 'null'
          title: Moderation
        partial_images:
          anyOf:
            - type: integer
              maximum: 3
              minimum: 0
            - type: 'null'
          title: Partial Images
        image:
          anyOf:
            - type: string
            - items:
                type: string
              type: array
            - type: 'null'
          title: Image
        seed:
          anyOf:
            - type: integer
              maximum: 2147483647
              minimum: -1
            - type: 'null'
          title: Seed
        sequential_image_generation:
          anyOf:
            - type: string
              enum:
                - auto
                - disabled
            - type: 'null'
          title: Sequential Image Generation
        sequential_image_generation_options:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Sequential Image Generation Options
        guidance_scale:
          anyOf:
            - type: number
              maximum: 10
              minimum: 1
            - type: 'null'
          title: Guidance Scale
        watermark:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Watermark
        optimize_prompt:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Optimize Prompt
        optimize_prompt_options:
          anyOf:
            - additionalProperties: true
              type: object
            - type: 'null'
          title: Optimize Prompt Options
        stream:
          type: boolean
          title: Stream
          default: false
      type: object
      required:
        - prompt
      title: ImageGenerationRequest
      example:
        model: openai/gpt-image-1-mini
        prompt: A children drawing of a veterinarian and a baby otter
        response_format: url
        stream: false
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: >-
        Enter your MeshAPI key (`rsk_...`) — sent as `Authorization: Bearer
        <key>`.

````