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

# gpt-image-2

> Generate images from text prompts using the GPT Image 2 model.



## OpenAPI

````yaml api-reference/model-api/openai/openapi/gpt-image-2/openapi.yaml POST /v1/images/generations
openapi: 3.1.0
info:
  title: GPT Image 2
  description: Generate images using GPT Image 2 via AnyFast API
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      summary: Generate Images
      description: Generate images from text prompts using the GPT Image 2 model.
      operationId: createGptImage2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  enum:
                    - gpt-image-2
                  description: Model ID.
                  example: gpt-image-2
                prompt:
                  type: string
                  description: Text description of the desired image.
                  example: A futuristic city skyline at sunset with flying cars
                'n':
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
                  description: >-
                    Number of images to generate. Supports `1–10`. Default: `1`.
                    **Requires selecting the Direct group** in the console.
                  example: 1
                size:
                  type: string
                  default: 1024x1024
                  description: >-
                    Output image size in `{width}x{height}` format. Supports
                    flexible resolutions — both edges must be multiples of 16,
                    aspect ratio ≤ 3:1, total pixels between 655,360 and
                    8,294,400, max edge 3,840px.
                  example: 1024x1024
                quality:
                  type: string
                  enum:
                    - low
                    - medium
                    - high
                  default: medium
                  description: Image quality.
                  example: high
                output_format:
                  type: string
                  enum:
                    - png
                    - jpeg
                  default: png
                  description: Output image format.
                  example: png
                moderation:
                  type: string
                  enum:
                    - auto
                    - low
                  default: auto
                  description: Content moderation level.
                  example: auto
                output_compression:
                  type: integer
                  minimum: 0
                  maximum: 100
                  description: Compression level for jpeg format (0-100%).
                  example: 80
      responses:
        '200':
          description: Images generated successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: Array of generated images.
                    items:
                      type: object
                      properties:
                        b64_json:
                          type: string
                          description: Base64-encoded image data.
                        revised_prompt:
                          type: string
                          description: The revised prompt used.
        '400':
          description: Bad request. Invalid parameters.
        '401':
          description: Unauthorized. Invalid or missing API key.
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````