> ## 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

> 使用 GPT Image 2 模型从文本提示生成图像。



## OpenAPI

````yaml zh/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: 通过 AnyFast API 使用 GPT Image 2 生成图像
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security:
  - bearerAuth: []
paths:
  /v1/images/generations:
    post:
      summary: 生成图像
      description: 使用 GPT Image 2 模型从文本提示生成图像。
      operationId: createGptImage2
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - prompt
              properties:
                model:
                  type: string
                  enum:
                    - gpt-image-2
                  description: 模型 ID
                  example: gpt-image-2
                prompt:
                  type: string
                  description: 图像描述文本
                  example: 一座未来城市的日落天际线，天空中有飞行汽车
                'n':
                  type: integer
                  minimum: 1
                  maximum: 10
                  default: 1
                  description: 生成图片数量，支持 `1–10`，默认 `1`。**需在控制台选择 Direct 分组。**
                  example: 1
                size:
                  type: string
                  default: 1024x1024
                  description: >-
                    输出图片尺寸，格式为 `{宽}x{高}`。支持灵活分辨率——边长必须为 16 的倍数，宽高比 ≤ 3:1，总像素数
                    655,360–8,294,400，最大单边 3,840px。
                  example: 1024x1024
                quality:
                  type: string
                  enum:
                    - low
                    - medium
                    - high
                  default: medium
                  description: 图片质量
                  example: high
                output_format:
                  type: string
                  enum:
                    - png
                    - jpeg
                  default: png
                  description: 输出图片格式
                  example: png
                moderation:
                  type: string
                  enum:
                    - auto
                    - low
                  default: auto
                  description: 内容审核级别
                  example: auto
                output_compression:
                  type: integer
                  minimum: 0
                  maximum: 100
                  description: jpeg 格式的压缩级别（0-100%）
                  example: 80
      responses:
        '200':
          description: 图像生成成功。
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    description: 生成的图片数组
                    items:
                      type: object
                      properties:
                        b64_json:
                          type: string
                          description: Base64 编码的图片数据
                        revised_prompt:
                          type: string
                          description: 模型修改后的提示词
        '400':
          description: 请求错误。参数无效。
        '401':
          description: 未授权。API 密钥无效或缺失。
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````