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

# 图片生成（按张计费）

> 同步按张计费的图片生成接口。请求体为 JSON，响应直接返回生成结果和用量。




## OpenAPI

````yaml /openapi/gateway-v1.openapi.yaml post /v3/images/generations
openapi: 3.1.0
info:
  title: WengaoCloud AI Gateway API
  version: 0.1.0
  description: WengaoCloud AI 聚合平台公开 API 契约草案，覆盖 OpenAI 兼容接口、Anthropic 原生接口和平台扩展接口。
servers:
  - url: https://xxx.wengaocloud.com
    description: 问高云 API 网关根域名。OpenAI SDK 的 base_url 使用 https://xxx.wengaocloud.com/v1。
  - url: https://{tenant}.wengaocloud.com
    description: 控制台展示的租户或 OEM API 网关根域名。
    variables:
      tenant:
        default: xxx
security:
  - bearerAuth: []
tags:
  - name: models
    x-group: 模型
  - name: openai-compatible
    x-group: OpenAI 兼容接口
  - name: anthropic-native
    x-group: Anthropic 原生接口
  - name: images-v3
    x-group: 图片（V3 同步）
  - name: volcengine-images
    x-group: 图片（火山直连）
  - name: images
    x-group: 图片（V1 兼容）
  - name: async-images
    x-group: 图片异步任务
  - name: aliwan-images
    x-group: 图片（百炼万相）
  - name: videos
    x-group: 视频
paths:
  /v3/images/generations:
    post:
      tags:
        - images-v3
      summary: 图片生成（按张计费）
      description: |
        同步按张计费的图片生成接口。请求体为 JSON，响应直接返回生成结果和用量。
      operationId: createImageGenerationV3
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageV3GenerationRequest'
            examples:
              basic:
                value:
                  model: gpt-image-2
                  prompt: 一张极简风格的云端工作站海报，蓝白配色
                  'n': 1
                  size: 1024x1024
              withBackground:
                value:
                  model: gpt-image-2
                  prompt: 产品展示图，纯白背景
                  'n': 1
                  size: 1536x1024
                  background: opaque
                  output_format: png
      responses:
        '200':
          description: 图片生成响应，直接返回结果图 URL 和用量统计。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageV3Response'
              examples:
                success:
                  value:
                    created: 1779860032
                    background: opaque
                    output_format: png
                    quality: low
                    size: 1024x1024
                    data:
                      - url: https://cdn.wengaocloud.com/images/ai/example.png
                        revised_prompt: 一张极简风格的云端工作站海报，蓝白配色，科技感，简约设计
                    usage:
                      total_tokens: 800
                      input_tokens: 300
                      output_tokens: 500
                      input_tokens_details:
                        text_tokens: 100
                        image_tokens: 200
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientQuota'
        '403':
          $ref: '#/components/responses/Forbidden'
components:
  schemas:
    ImageV3GenerationRequest:
      type: object
      required:
        - model
        - prompt
      properties:
        model:
          type: string
          description: 模型调用 ID，需要支持 `images_generations_v3` endpoint。
          example: gpt-image-2
        prompt:
          type: string
          description: 图片生成提示词，不能为空。
        'n':
          type: integer
          minimum: 1
          maximum: 10
          default: 1
          description: 一次返回的图片张数，默认 1，范围 1–10。
        size:
          $ref: '#/components/schemas/ImageV3SizeEnum'
          description: 生成图片的尺寸，默认 `1024x1024`。
        background:
          type: string
          enum:
            - transparent
            - opaque
            - auto
          description: 背景模式。`transparent` 需要 `output_format=png` 或 `webp`。
        moderation:
          type: string
          description: 内容安全策略，默认以模型配置为准。
        output_format:
          type: string
          enum:
            - png
            - jpeg
            - webp
          description: 输出图片格式，默认 `png`。
        output_compression:
          type: integer
          minimum: 0
          maximum: 100
          description: JPEG/WebP 压缩质量（0–100），仅对 `jpeg` 和 `webp` 格式生效。
    ImageV3Response:
      type: object
      properties:
        created:
          type: integer
          description: 响应创建时间戳（Unix 秒）。
        background:
          type: string
          description: 生成图像的背景类型。
        output_format:
          type: string
          description: 输出图片格式。
        quality:
          type: string
          description: 实际使用的图像质量等级，当前固定为 `low`。
          example: low
        size:
          type: string
          description: 实际返回的图像尺寸。
        data:
          type: array
          description: 图像结果列表。
          items:
            $ref: '#/components/schemas/ImageV3ResultImage'
        usage:
          $ref: '#/components/schemas/ImageV3Usage'
    ImageV3SizeEnum:
      type: string
      enum:
        - auto
        - 1024x1024
        - 1024x1536
        - 1536x1024
        - 2048x2048
        - 2048x1152
        - 3840x2160
        - 2160x3840
        - 2048x1360
        - 1360x2048
        - 1152x2048
        - 2048x1536
        - 1536x2048
        - 2048x880
        - 880x2048
        - 688x2048
        - 2048x688
        - 2048x1024
      default: 1024x1024
    ImageV3ResultImage:
      type: object
      properties:
        url:
          type: string
          format: uri
          description: 生成图像的访问 URL。
        revised_prompt:
          type: string
          description: 实际用于生成的提示词（平台可能对原始提示词进行优化）。
    ImageV3Usage:
      type: object
      properties:
        total_tokens:
          type: integer
          description: 本次请求消耗的 Token 总数。
        input_tokens:
          type: integer
          description: 输入侧消耗的 Token 数。
        output_tokens:
          type: integer
          description: 输出侧消耗的 Token 数。
        input_tokens_details:
          $ref: '#/components/schemas/ImageV3InputTokensDetails'
      additionalProperties: true
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            type:
              type: string
              example: invalid_request_error
            code:
              type: string
              example: model_endpoint_mismatch
            message:
              type: string
              example: 该模型不支持当前 endpoint。
    ImageV3InputTokensDetails:
      type: object
      properties:
        text_tokens:
          type: integer
          description: 文本 Token 数。
        image_tokens:
          type: integer
          description: 图像 Token 数。
      additionalProperties: true
  responses:
    BadRequest:
      description: 请求参数无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Unauthorized:
      description: API Key 缺失或无效。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    InsufficientQuota:
      description: 余额或额度不足。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    Forbidden:
      description: 模型不可见、API Key 无权限或档位不可用。
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      x-default: sk-your-api-key

````