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

# Image-01 文生图

> 适用于 `image-01` 模型的文生图能力。

公开字段：`model`、`prompt`、`aspect_ratio`、`width`、`height`、`response_format`、`seed`、`n`、`prompt_optimizer`。



## OpenAPI

````yaml api-reference/zh-Hans/zmodelImage/minimax/image01-text-to-image.json POST /v1/images/generations
openapi: 3.0.1
info:
  title: Image-01 文生图
  version: 1.0.0
  description: Image-01 文生图能力文档。公开统一入口为 `/v1/images/generations`，用于根据文本提示词生成图片。
  license:
    name: Project License
    url: https://github.com/QuantumNous/new-api/blob/main/LICENSE
servers:
  - url: https://api.powertokens.ai
    description: Baze API 服务地址
security: []
tags:
  - name: Image Generation
    description: Image-01 图像生成能力
paths:
  /v1/images/generations:
    post:
      tags:
        - Image Generation
      summary: Image-01 文生图
      description: >-
        适用于 `image-01` 模型的文生图能力。


        公开字段：`model`、`prompt`、`aspect_ratio`、`width`、`height`、`response_format`、`seed`、`n`、`prompt_optimizer`。
      operationId: minimaxTextToImage
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MiniMaxTextToImageRequest'
            examples:
              basic_request:
                summary: 基础请求
                value:
                  model: image-01
                  prompt: A cinematic sunrise over a calm harbor
                  aspect_ratio: '16:9'
                  response_format: base64
                  seed: 0
                  'n': 1
                  prompt_optimizer: false
      responses:
        '200':
          description: 调用成功，返回统一图像响应结构。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MiniMaxImageResponse'
        '400':
          description: 请求参数不合法。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                invalid_request:
                  summary: 参数错误
                  value:
                    error:
                      message: 请求体格式错误或字段取值非法
                      type: invalid_request_error
                      code: bad_request_body
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                unauthorized:
                  summary: 未授权
                  value:
                    error:
                      message: 无效的令牌
                      type: api_error
                      code: access_denied
          description: 鉴权失败，例如未提供令牌或令牌无效。
        '413':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                request_too_large:
                  summary: 请求体过大
                  value:
                    error:
                      message: 请求体过大，请缩小输入后重试
                      type: api_error
                      code: read_request_body_failed
          description: 请求体过大。
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                quota_exceeded:
                  summary: 额度不足或速率受限
                  value:
                    error:
                      message: 当前账户额度不足，请稍后重试
                      type: api_error
                      code: insufficient_user_quota
          description: 触发速率限制或账户额度不足。
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                internal_error:
                  summary: 内部处理失败
                  value:
                    error:
                      message: 服务内部处理失败，请稍后重试
                      type: api_error
                      code: gen_relay_info_failed
          description: 服务端处理请求时发生内部错误。
        '502':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                bad_gateway:
                  summary: 上游响应异常
                  value:
                    error:
                      message: 上游服务返回了无效响应
                      type: api_error
                      code: bad_response_status_code
          description: 上游服务返回异常响应。
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              examples:
                service_unavailable:
                  summary: 服务暂不可用
                  value:
                    error:
                      message: 当前模型暂时无可用渠道，请稍后重试
                      type: api_error
                      code: get_channel_failed
          description: 上游服务暂不可用，或当前模型暂无可用渠道。
      security:
        - BearerAuth: []
components:
  schemas:
    MiniMaxTextToImageRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          enum:
            - image-01
          description: 模型名称。可选值：`image-01`
        prompt:
          type: string
          description: 图像的文本描述，最长 1500 字符
          maxLength: 1500
        aspect_ratio:
          type: string
          description: |-
            图像宽高比，默认为 1:1。可选值：
            - `1:1` (1024x1024)
            - `16:9` (1280x720)
            - `4:3` (1152x864)
            - `3:2` (1248x832)
            - `2:3` (832x1248)
            - `3:4` (864x1152)
            - `9:16` (720x1280)
            - `21:9` (1344x576) (仅适用于`image-01`)
          enum:
            - '1:1'
            - '16:9'
            - '4:3'
            - '3:2'
            - '2:3'
            - '3:4'
            - '9:16'
            - '21:9'
        width:
          type: integer
          description: |-
            生成图片的宽度（像素）。仅当 model 为 `image-01` 时生效。注意：`width` 和 `height`
            需同时设置，取值范围[512, 2048]，且必须是 8 的倍数。若与 `aspect_ratio` 同时设置，则优先使用
            `aspect_ratio`
          minimum: 512
          maximum: 2048
          multipleOf: 8
        height:
          type: integer
          description: |-
            生成图片的高度（像素）。仅当 model 为 `image-01` 时生效。注意：`width` 和 `height`
            需同时设置，取值范围[512, 2048]，且必须是 8 的倍数。若与 `aspect_ratio` 同时设置，则优先使用
            `aspect_ratio`
          minimum: 512
          maximum: 2048
          multipleOf: 8
        response_format:
          type: string
          enum:
            - url
            - base64
          description: |-
            返回图片的形式，默认为 url。可选值：url, base64。
            ⚠️ 注意：url 的有效期为 24 小时
        seed:
          type: integer
          format: int64
          description: 随机种子。使用相同的 seed 和参数，可以生成内容相近的图片，用于复现结果。如未提供，算法会对 n 张图单独生成随机种子
        'n':
          type: integer
          minimum: 1
          maximum: 9
          description: 单次请求生成的图片数量，取值范围[1, 9]，默认为 1
        prompt_optimizer:
          type: boolean
          description: 是否开启 prompt 自动优化，默认为 `false`.
    MiniMaxImageResponse:
      type: object
      properties:
        created:
          type: integer
          format: int64
        data:
          type: array
          items:
            $ref: '#/components/schemas/MiniMaxImageData'
        metadata:
          $ref: '#/components/schemas/MiniMaxImageMetadata'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
              description: 错误类型，例如 `invalid_request_error`、`api_error` 或上游兼容错误类型。
            code:
              type: string
    MiniMaxImageData:
      type: object
      properties:
        url:
          type: string
          description: 当 `response_format` 为 `url` 时返回的图片临时下载地址，链接有效期 24 小时
        b64_json:
          type: string
          description: 当 `response_format` 为 `base64` 时返回的图片 Base64 编码内容
    MiniMaxImageMetadata:
      type: object
      properties:
        provider_request_id:
          type: string
          description: 模型服务返回的请求追踪 ID。
        provider_status_code:
          type: integer
          description: 模型服务返回的状态码。
        provider_status_msg:
          type: string
          description: 模型服务返回的状态说明。
        success_count:
          type: integer
          description: 成功生成的图片数量
        failed_count:
          type: integer
          description: 因内容安全检查被拦截的图片数量
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: '在请求头中传入 `Authorization: Bearer <token>`。'

````