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

# 创建图像任务（异步）

> 统一入口，按请求体是否包含 `image` 自动区分：
  - 不传 `image` → 文生图（OpenAI /v1/images/generations）
  - 传入 `image` → 图片编辑（OpenAI /v1/images/edits，JSON 模式：URL 或 base64 data URL）

异步任务：返回 taskId，使用 GET /openai/tasks?taskId=... 轮询至终态。



## OpenAPI

````yaml POST /openai/images
openapi: 3.0.0
info:
  title: Openai AI
  description: API documentation for Openai AI
  version: 1.0.0
  contact: {}
servers:
  - url: https://api.mountsea.ai
    description: API Gateway
security: []
tags:
  - name: openai
    description: ''
  - name: openai-compat
    description: ''
paths:
  /openai/images:
    post:
      tags:
        - openai
      summary: 创建图片任务（异步）
      description: |-
        统一入口，按请求体是否包含 `image` 自动区分：
          - 不传 `image` → 文生图（OpenAI /v1/images/generations）
          - 传入 `image` → 图片编辑（OpenAI /v1/images/edits，JSON 模式：URL 或 base64 data URL）

        异步任务：返回 taskId，使用 GET /openai/tasks?taskId=... 轮询至终态。
      operationId: ApiPublicController_createImageTask
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ImageCreateDto'
      responses:
        '200':
          description: 返回 taskId
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskIdDto'
      security:
        - bearerAuth: []
components:
  schemas:
    ImageCreateDto:
      type: object
      properties:
        prompt:
          type: string
          description: 提示词（prompt）
        model:
          type: string
          enum:
            - gpt-image-2
          description: 模型
          default: gpt-image-2
        size:
          description: >-
            尺寸 / 分辨率。可传 ImageResolution 枚举值，或自定义 `WxH`（如
            `1280x960`）。自定义尺寸须满足以下约束：① 单边 ≤ 3840 px；② 宽、高均为 16 的倍数；③ 长边 : 短边 ≤
            3:1；④ 总像素 ∈ [655 360, 8 294 400]。不满足约束或渠道不支持自定义尺寸时请求将被拒绝。
          oneOf:
            - type: string
              enum:
                - auto
                - 1024x1024
                - 1536x1024
                - 1024x1536
                - 2048x2048
                - 2048x1152
                - 3840x2160
                - 2160x3840
            - type: string
              pattern: ^\d+x\d+$
              example: 1280x960
          default: 1024x1024
        'n':
          type: number
          minimum: 1
          maximum: 1
          description: 生成数量（当前仅支持 1）
          default: 1
        quality:
          enum:
            - auto
            - low
            - medium
            - high
            - standard
          type: string
          description: 质量等级
        background:
          enum:
            - transparent
            - opaque
            - auto
          type: string
          description: 背景透明度
        output_format:
          enum:
            - png
            - jpeg
            - webp
          type: string
          description: 输出文件格式
        output_compression:
          type: number
          minimum: 0
          maximum: 100
          description: JPEG / WebP 的压缩等级 0-100
        moderation:
          enum:
            - auto
            - low
          type: string
          description: 审核强度
        response_format:
          default: url
          enum:
            - url
            - b64_json
          type: string
          description: >-
            响应格式：`url` 返回图片自家 S3 URL；`b64_json` 返回 base64。本服务对所有渠道（含 OpenAI
            gpt-image-* 这种上游强制返 b64 的模型）都会按本字段严格输出，不会两个字段都返回。不传时按 `url` 处理。
        input_fidelity:
          enum:
            - high
            - low
          type: string
          description: 输入图保真度（gpt-image-2 新增，仅 edit 场景生效；generate 可忽略）
        image:
          description: >-
            输入图片，**仅接受 `http(s)://` URL**（异步任务约束，不接 base64 / data
            URL）。提供则走图片编辑；不提供则走文生图。支持单张字符串或数组。如需传 base64，请改用同步接口
            `/openai/v1/images/generations` 或 `/openai/v1/images/edits`。
          oneOf:
            - type: string
              format: uri
            - type: array
              items:
                type: string
                format: uri
        mask:
          type: string
          description: >-
            mask 图片（仅编辑场景，**仅接受 `http(s)://` URL**）；透明区域将被重绘。如需传 base64，请改用同步接口
            `/openai/v1/images/edits`。
          format: uri
      required:
        - prompt
    TaskIdDto:
      type: object
      properties:
        taskId:
          type: string
          description: 任务 ID，用于后续查询结果
      required:
        - taskId
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````