{
  "openapi": "3.1.0",
  "info": {
    "title": "BeefTV 云端 API OpenAPI 规范",
    "version": "2026.11",
    "summary": "BeefTV 云端统一媒体、文本、联网工具、目录估价与人民币用量对账接口规范。",
    "description": "本规范面向 https://beeftv.app 与中国大陆直连域名 https://beeftv.cn 云端接入，所有计费与对账均以人民币（CNY）结算。\n\n- **推荐媒体入口**：生图、参考图编辑、视频生成、超分增强、视频擦除与音频合成统一走 `POST /v1/media/tasks` + `GET /v1/media/tasks/{task_ref}`。\n- **请求追踪与对账**：每个响应都会返回 `X-Oneapi-Request-Id` 响应头；同步图片带 `Idempotency-Key` 重放时，以 `X-Image-Request-Id` 对应原结算记录。用该 ID 调 `GET /v1/usage/requests?request_id=...` 可直接获取权威人民币实扣 `amount`。\n- **像素分档图片（Seedream 5.5 / 5.0 Pro）**：原始 JSON 响应已返回每张图的 `data[].size`（或统一媒体接口的 `outputs[].metadata.size`），格式为 `宽x高`。"
  },
  "servers": [
    {
      "url": "https://beeftv.cn",
      "description": "BeefTV 中国大陆直连生产环境（人民币账户余额，回源超时 600 秒，推荐中国大陆与长耗时同步生图/拆层调用）"
    },
    {
      "url": "https://beeftv.app",
      "description": "BeefTV 云端生产环境（全球域名，人民币账户余额）"
    }
  ],
  "security": [
    {
      "BeefTVAPIKeyBearer": []
    }
  ],
  "tags": [
    {
      "name": "统一媒体任务",
      "description": "推荐入口：一套协议覆盖图像、视频、超分增强、视频擦除与音频合成。"
    },
    {
      "name": "素材上传",
      "description": "本地图片、视频、音频三步预签名直传广州 COS。"
    },
    {
      "name": "目录与估价",
      "description": "实时模型目录、能力声明与生成前权威人民币估价。"
    },
    {
      "name": "用量与对账",
      "description": "按当前API Key 查询人民币汇总与按 Request ID 查询单笔实扣明细。"
    },
    {
      "name": "文本对话",
      "description": "OpenAI Chat Completions、Responses 与 Anthropic Messages 标准协议。"
    },
    {
      "name": "图像兼容接口",
      "description": "OpenAI 兼容文生图与参考图编辑接口（含 Seedream 像素尺寸与图层拆解字段）。"
    },
    {
      "name": "视频兼容接口",
      "description": "OpenAI 兼容异步视频提交、查询与结果下载接口。"
    },
    {
      "name": "音频兼容接口",
      "description": "同步语音合成/音乐生成与语音识别转写接口。"
    },
    {
      "name": "联网工具",
      "description": "托管联网搜索与网页正文提取接口，按次人民币计费，失败或空结果自动全额退费。"
    }
  ],
  "paths": {
    "/v1/media/tasks": {
      "post": {
        "operationId": "createMediaTask",
        "tags": [
          "统一媒体任务"
        ],
        "summary": "提交统一媒体任务",
        "description": "统一提交图像生成/编辑（`image`）、视频生成与擦除（`video`）、超分画质增强（`upscale`）及语音/音乐合成（`audio`）任务。\n\n- **统一异步与短等待自动转异步（所有生图渠道通用）**：所有媒体类型统一返回 HTTP `202`，请以响应体中的 `status` 为准：\n  - 传入 `async: true` 或配置了 `webhook` 时，生图任务在受理后**立即返回** HTTP `202`（`status: \"in_progress\"`），后台完成生图、云存储转存（或官链直出）并触发回调，不占长连接；\n  - 默认不传 `async` 且未配置 `webhook` 时，原生异步生图通道（如 GPT Image 2.x、Midjourney 等）提交上游后立即返回 `in_progress`；同步生图通道（如 Seedream 系列、混元等）会在服务端最多等待约 15 秒——若 15 秒内出图则直接返回 `status: \"completed\"` 和 `outputs`，超过 15 秒则自动返回 `status: \"in_progress\"` 并在后台继续完成，避免触发长连接超时；\n  - 返回 `queued` 或 `in_progress` 时，按同一个 `task_ref` 轮询 `GET /v1/media/tasks/{task_ref}` 或等待 `webhook` 推送即可。\n- **可选生图官链直出（`options.delivery: \"direct\"` 或请求头 `X-Beeftv-Image-Delivery: direct`）**：仅适用于 `media_type: \"image\"`（非图片媒体类型携带 `X-Beeftv-Image-Delivery: direct` 返回 `400 invalid_image_delivery`，传 `options.delivery` 返回 `400 invalid_media_request`）。对 `GET /v1/models` 中 `image_capabilities.directDelivery.supported === true` 的型号（当前覆盖全部 Seedream 系列，含多图层拆解），服务端跳过广州 COS 转存，在完成后的 `GET /v1/media/tasks/{task_ref}` 与 Webhook 回调中直接返回上游官方临时 HTTPS 链接（有效期约 24 小时），并在任务顶层附带 `metadata.delivery: \"direct\"`；非 Seedream 型号自动安全回退广州 COS 交付（不带 `metadata.delivery: \"direct\"`）。同一 `task_ref` 重试时须保持请求体与交付方式不变（否则返回 `409 idempotency_conflict`）。\n- **统一签名异步回调（`webhook`）**：适用于全部 4 类媒体（含全部同步与异步 `image`、`video`、`upscale`、`audio`）。仅允许公网 HTTPS（443 端口、禁止 3xx 重定向、禁止私网/回环/元数据地址），任务进入终态（`media.task.completed`、`media.task.failed`、`media.task.unknown`）后由服务端 POST 回调，请求头携带 `X-Webhook-Id`、`X-Webhook-Event`、`X-Webhook-Timestamp`、`X-Webhook-Attempt` 与 `X-Webhook-Signature: v1=<hex(HMAC-SHA256(secret, timestamp + \".\" + raw_body))>`。回调遇 `408`/`429`/`5xx`/网络错误按指数退避最多重试 5 次（保持相同 `X-Webhook-Id` 便于幂等去重，且每次重试重新签发有效成片链接），终态完成后服务端立即清除密钥。\n- 响应中的 `quota` / `reserved_quota` / `charged_quota` / `adjustment_quota` 为平台内部额度整数（`500,000 = ¥1.00`），**不是人民币金额**；外部财务结算与向终端用户扣费请以 `GET /v1/usage/requests` 返回的人民币字符串 `amount` 为准。",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "可选幂等键（1–255 个可见非空白 ASCII 字符（0x21–0x7E，不含空格））。省略 `task_ref` 时会优先采用此值；若与请求体 `task_ref` 同时传入则必须一致。",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          {
            "name": "X-Beeftv-Image-Delivery",
            "in": "header",
            "required": false,
            "description": "可选生图交付方式（仅适用于 `media_type: \"image\"`，等价于请求体 `options.delivery`，两者同时传入时须一致）。省略或传 `managed` 走默认广州 COS 转存；传 `direct` 时对支持官链直出的型号（Seedream 系列）跳过 COS 转存并直接返回上游官方临时 HTTPS 链接（有效期约 24 小时，完成态返回 `metadata.delivery: \"direct\"`），其他型号自动回退广州 COS 交付；对 `video`/`upscale`/`audio` 传 `direct` 返回 `400 invalid_image_delivery`。",
            "schema": {
              "type": "string",
              "enum": [
                "managed",
                "direct"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaTaskRequest"
              },
              "examples": {
                "image_seedream55": {
                  "summary": "Seedream 5.5 文生图（含透明底 PNG 参数）",
                  "value": {
                    "task_ref": "img-shot-01",
                    "media_type": "image",
                    "model": "dola-seedream-5-5-261028",
                    "operation": "generate",
                    "async": true,
                    "input": {
                      "prompt": "一只国风青瓷小茶杯贴纸，居中构图，干净边缘"
                    },
                    "options": {
                      "size": "1K",
                      "output_format": "png",
                      "background": "transparent"
                    }
                  }
                },
                "image_seedream55_async_direct": {
                  "summary": "Seedream 5.5 异步文生图 + 官链直出（高并发推荐）",
                  "value": {
                    "task_ref": "img-direct-01",
                    "media_type": "image",
                    "model": "dola-seedream-5-5-261028",
                    "operation": "generate",
                    "async": true,
                    "input": {
                      "prompt": "一只橙色小猫坐在窗台上，阳光洒落"
                    },
                    "options": {
                      "size": "2K",
                      "delivery": "direct"
                    }
                  }
                },
                "image_birefnet_matting": {
                  "summary": "BiRefNet 单图精准抠图（真透明 RGBA PNG）",
                  "value": {
                    "task_ref": "birefnet-cutout-01",
                    "media_type": "image",
                    "model": "birefnet-beeftv",
                    "operation": "edit",
                    "async": true,
                    "input": {
                      "references": [
                        {
                          "kind": "image",
                          "role": "reference",
                          "url": "https://example.com/subject.png"
                        }
                      ]
                    }
                  }
                },
                "image_gpt26_gif": {
                  "summary": "GPT Image 2.6 动画 GIF（限 1K）",
                  "value": {
                    "task_ref": "gpt26-gif-01",
                    "media_type": "image",
                    "model": "gpt-image-2.6",
                    "operation": "generate",
                    "async": true,
                    "input": {
                      "prompt": "像素风暖黄灯笼在细雨中轻轻摇晃的循环小动画"
                    },
                    "options": {
                      "size": "1K",
                      "quality": "medium",
                      "output_format": "gif",
                      "complexity": "medium",
                      "frame_count": 8,
                      "frame_duration_ms": 150
                    }
                  }
                },
                "video_seedance25": {
                  "summary": "Seedance 2.5 多模态参考生视频",
                  "value": {
                    "task_ref": "seedance25-ref-01",
                    "media_type": "video",
                    "model": "seedance-2.5",
                    "operation": "reference_to_video",
                    "input": {
                      "prompt": "保持参考图角色形象，跟着参考音频节奏在雨夜茶廊转身微笑",
                      "references": [
                        {
                          "kind": "image",
                          "role": "reference",
                          "url": "https://example.com/role.png"
                        },
                        {
                          "kind": "audio",
                          "role": "reference",
                          "url": "https://example.com/bgm.mp3"
                        }
                      ]
                    },
                    "options": {
                      "resolution": "720p",
                      "ratio": "16:9",
                      "duration": 8,
                      "generate_audio": true
                    }
                  }
                },
                "video_magi2": {
                  "summary": "MAGI-2 首尾帧图生视频",
                  "value": {
                    "task_ref": "magi2-shot-01",
                    "media_type": "video",
                    "model": "magi-2",
                    "operation": "image_to_video",
                    "input": {
                      "prompt": "镜头平稳推进，窗外微风吹动窗帘",
                      "references": [
                        {
                          "kind": "image",
                          "role": "first_frame",
                          "url": "https://example.com/start.png"
                        },
                        {
                          "kind": "image",
                          "role": "last_frame",
                          "url": "https://example.com/end.png"
                        }
                      ]
                    },
                    "options": {
                      "seconds": 5,
                      "resolution": "1080p",
                      "aspect_ratio": "16:9",
                      "generate_audio": true
                    }
                  }
                },
                "audio_tts": {
                  "summary": "MiniMax Speech 2.8 语音合成（TTS）",
                  "value": {
                    "task_ref": "tts-shot-01",
                    "media_type": "audio",
                    "model": "minimax-speech-2.8-turbo",
                    "operation": "synthesize",
                    "input": {
                      "prompt": "大家好，欢迎来到今天的发布会。"
                    },
                    "options": {
                      "voice": "male-qn-qingse",
                      "speed": 1
                    }
                  }
                },
                "audio_qwen3_clone": {
                  "summary": "Qwen3 TTS 三秒零样本音色克隆",
                  "value": {
                    "task_ref": "qwen3-clone-01",
                    "media_type": "audio",
                    "model": "qwen3-tts-beeftv",
                    "operation": "synthesize",
                    "input": {
                      "prompt": "欢迎来到 BeefTV 云端工作台。",
                      "references": [
                        {
                          "kind": "audio",
                          "role": "reference",
                          "url": "https://example.com/voice-3s.mp3"
                        }
                      ]
                    },
                    "options": {
                      "voice": "auto",
                      "speed": 1
                    }
                  }
                },
                "video_translation_seed15": {
                  "summary": "Seed Audio 1.5 视频多语种翻译（media_type 为 video）",
                  "value": {
                    "task_ref": "seed-translate-01",
                    "media_type": "video",
                    "model": "seed-audio-1.5-video-translation",
                    "operation": "video_translation",
                    "input": {
                      "references": [
                        {
                          "kind": "video",
                          "role": "source",
                          "url": "https://example.com/clip.mp4"
                        }
                      ]
                    },
                    "options": {
                      "target_language": "en",
                      "dialogue_enhancement": "medium",
                      "glossaries": [
                        {
                          "source": "牛肉粉",
                          "target": "BeefTV"
                        }
                      ]
                    }
                  }
                },
                "upscale_seedvr2": {
                  "summary": "SeedVR2 图片超分（2x PNG）",
                  "value": {
                    "task_ref": "seedvr2-01",
                    "media_type": "upscale",
                    "model": "seedvr2-beeftv",
                    "operation": "upscale",
                    "input": {
                      "references": [
                        {
                          "kind": "image",
                          "role": "source",
                          "url": "https://example.com/frame.png"
                        }
                      ]
                    },
                    "options": {
                      "upscale_factor": 2,
                      "output_format": "png"
                    }
                  }
                },
                "erase_subtitle_ocr": {
                  "summary": "视频去字幕 + OCR 提取并翻译英文字幕",
                  "value": {
                    "task_ref": "sub-erase-01",
                    "media_type": "video",
                    "model": "video-subtitle-erase",
                    "operation": "subtitle_erase",
                    "input": {
                      "references": [
                        {
                          "kind": "video",
                          "role": "source",
                          "url": "https://example.com/shot.mp4"
                        }
                      ]
                    },
                    "options": {
                      "erase_method": "auto",
                      "subtitle_model": "standard",
                      "ocr_extract": true,
                      "subtitle_lang": "zh_en",
                      "subtitle_format": "srt",
                      "translate": true,
                      "translate_dst_lang": "en"
                    }
                  }
                },
                "video_with_webhook": {
                  "summary": "Seedance 2.0 带签名 Webhook 异步回调",
                  "value": {
                    "task_ref": "seedance-wh-01",
                    "media_type": "video",
                    "model": "seedance-2.0-mini",
                    "operation": "text_to_video",
                    "input": {
                      "prompt": "清晨薄雾笼罩江南古桥，乌篷船缓缓划过水面"
                    },
                    "options": {
                      "seconds": 5,
                      "resolution": "720p",
                      "aspect_ratio": "16:9",
                      "generate_audio": true
                    },
                    "webhook": {
                      "url": "https://hooks.example.com/media/callback",
                      "secret": "whsec_replace_with_16_to_256_ascii"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "任务已受理（同步生图可能已在本次响应内直接返回 `status: \"completed\"` 与 `outputs`）。",
            "headers": {
              "Location": {
                "$ref": "#/components/headers/TaskLocation"
              },
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-Image-Request-Id": {
                "$ref": "#/components/headers/ImageRequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaTaskProjection"
                },
                "examples": {
                  "image_completed": {
                    "summary": "同步生图直接完成（含 outputs[].metadata.size 与 usage）",
                    "value": {
                      "task_ref": "mtask_b4c4873fe05349b0b26d6eaac00902fb",
                      "media_type": "image",
                      "status": "completed",
                      "task_id": "task_d3hTi0as92KRCuPdZenV5GaDAocRNMp2",
                      "outputs": [
                        {
                          "kind": "image",
                          "url": "https://beeftv.app/v1/images/proxy?t=example_token",
                          "metadata": {
                            "size": "1024x1024",
                            "output_format": "png",
                            "background": "opaque"
                          }
                        }
                      ],
                      "metadata": {
                        "created": 1795668015,
                        "model": "dola-seedream-5-5-261028"
                      },
                      "usage": {
                        "input_images": 0,
                        "generated_images": 1,
                        "output_tokens": 4096,
                        "total_tokens": 4096
                      },
                      "billing_state": "settled",
                      "quota": 6781,
                      "reserved_quota": 6781,
                      "charged_quota": 6781,
                      "adjustment_quota": 0,
                      "usage_state": "completed"
                    }
                  },
                  "video_queued": {
                    "summary": "异步视频/音频/超分任务排队受理",
                    "value": {
                      "task_ref": "shot-01-video",
                      "media_type": "video",
                      "status": "queued",
                      "task_id": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz",
                      "outputs": [],
                      "quota": 125000,
                      "reserved_quota": 125000,
                      "charged_quota": 125000,
                      "adjustment_quota": 0,
                      "usage_state": "pending"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "外层请求 JSON、必填字段、交付模式、媒体协议头或 `Idempotency-Key` / `task_ref` 校验未通过（`invalid_media_request` / `invalid_image_delivery` / `invalid_idempotency_key`）。任务一旦受理，下游模型参数、参考素材或余额失败将返回 HTTP `202` 且 `status: \"failed\"`。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "409": {
            "description": "相同 `task_ref` / `Idempotency-Key` 对应了不同的请求体，或原图片请求仍在执行中/结果待确认。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "idempotency_conflict",
                    "category": "input",
                    "message": "This key belongs to a different image request.",
                    "request_id": "202611260438303668669388268d9d6QYKPi9MG"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/media/tasks/{task_ref}": {
      "get": {
        "operationId": "getMediaTask",
        "tags": [
          "统一媒体任务"
        ],
        "summary": "查询统一媒体任务",
        "description": "按提交时保存的 `task_ref`（或服务端自动生成的 `mtask_...`）只读查询任务当前状态、成片链接、上游元数据、用量与错误信息。\n\n- 通常无需传 `?media_type=`，服务端会自动识别任务类型；仅当同一个 Key 下把同一个 `task_ref` 同时用于图片与视频任务时，会返回 `409 ambiguous_media_type`，此时补传 `media_type` 即可。\n- 即使 API Key 额度耗尽，仍可查询此前已提交任务的状态与结果。",
        "parameters": [
          {
            "name": "task_ref",
            "in": "path",
            "required": true,
            "description": "提交 `POST /v1/media/tasks` 时传入或服务端返回的 `task_ref`。",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            },
            "example": "mtask_b4c4873fe05349b0b26d6eaac00902fb"
          },
          {
            "name": "media_type",
            "in": "query",
            "required": false,
            "description": "可选任务大类；仅在返回 `409 ambiguous_media_type` 时需要显式指定。",
            "schema": {
              "type": "string",
              "enum": [
                "image",
                "video",
                "upscale",
                "audio"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "返回与提交同构的任务状态对象。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaTaskProjection"
                },
                "examples": {
                  "video_completed": {
                    "summary": "按 Token 计费视频已完成（Seedance 含 usage.total_tokens 与 COS 链接）",
                    "value": {
                      "task_ref": "shot-01-video",
                      "media_type": "video",
                      "status": "completed",
                      "task_id": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz",
                      "outputs": [
                        {
                          "kind": "video",
                          "url": "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/video/v1/cos/example?X-Amz-Signature=example"
                        }
                      ],
                      "usage": {
                        "billing_mode": "video_tokens",
                        "resolution": "720p",
                        "output_seconds": 5,
                        "completion_tokens": 108900,
                        "total_tokens": 108900
                      },
                      "billing_state": "settled",
                      "quota": 125000,
                      "reserved_quota": 125000,
                      "charged_quota": 125000,
                      "adjustment_quota": 0,
                      "usage_state": "completed"
                    }
                  },
                  "video_seconds_completed": {
                    "summary": "按秒计费视频已完成（MAGI-2 / 万相 3.0 含 usage.total_seconds）",
                    "value": {
                      "task_ref": "magi2-shot-01",
                      "media_type": "video",
                      "status": "completed",
                      "task_id": "task_example_magi2",
                      "outputs": [
                        {
                          "kind": "video",
                          "url": "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/video/v1/cos/example?X-Amz-Signature=example"
                        }
                      ],
                      "usage": {
                        "billing_mode": "video_seconds",
                        "resolution": "1080p",
                        "output_seconds": 5,
                        "total_seconds": 5
                      },
                      "billing_state": "settled",
                      "quota": 1500000,
                      "reserved_quota": 1500000,
                      "charged_quota": 1500000,
                      "adjustment_quota": 0,
                      "usage_state": "completed"
                    }
                  },
                  "audio_settled_with_refund": {
                    "summary": "音频任务已完成并自动退回多余预扣",
                    "value": {
                      "task_ref": "tts-shot-01",
                      "media_type": "audio",
                      "status": "completed",
                      "task_id": "task_Tq3Bvpm0tfFuXcvVq3iGHWi24gkg1Zef",
                      "outputs": [
                        {
                          "kind": "audio",
                          "url": "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/video/v1/cos/example?response-content-type=audio%2Fmpeg&X-Amz-Signature=example"
                        }
                      ],
                      "billing_state": "settled",
                      "quota": 1800,
                      "reserved_quota": 152400,
                      "charged_quota": 1800,
                      "adjustment_quota": -150600,
                      "usage_state": "completed"
                    }
                  },
                  "failed": {
                    "summary": "任务执行失败（已自动退回预扣）",
                    "value": {
                      "task_ref": "shot-failed-01",
                      "media_type": "video",
                      "status": "failed",
                      "task_id": "task_example_failed",
                      "outputs": [],
                      "billing_state": "refunded",
                      "quota": 0,
                      "reserved_quota": 125000,
                      "charged_quota": 0,
                      "adjustment_quota": -125000,
                      "usage_state": "failed",
                      "error": {
                        "code": "media_generation_failed",
                        "category": "upstream",
                        "message": "第 1 张参考图分辨率低于模型最小要求，请更换更高分辨率素材后重试。",
                        "reason": "video_provider_constraint",
                        "user_message": "第 1 张参考图分辨率低于模型最小要求，请更换更高分辨率素材后重试。",
                        "request_id": "202611260440596642076898268d9d6Fp7Xm05e"
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或来源 IP 不在白名单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "404": {
            "description": "当前 Key 下未查到该 `task_ref`。切勿凭 404 自动重新提交高价任务，请核对 Key、域名和原 `task_ref`。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "media_task_not_found",
                    "category": "unknown",
                    "message": "This query did not establish the original attempt. Keep its reference; do not resubmit."
                  }
                }
              }
            }
          },
          "409": {
            "description": "同一个 `task_ref` 同时存在于多个媒体类型任务中，需要补传 `?media_type=image|video|upscale|audio`。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "ambiguous_media_type",
                    "category": "input",
                    "message": "Multiple media tasks share this task_ref. Specify media_type=image, video, upscale, or audio."
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/media/uploads": {
      "post": {
        "operationId": "createMediaUpload",
        "tags": [
          "素材上传"
        ],
        "summary": "申请素材预签名直传地址",
        "description": "为本地参考图、参考视频或参考音频申请腾讯云广州 COS 预签名直传票据（上传流量直连 COS，不经过 API 网关且不产生生成费用）。\n\n流程：1) 调用本接口拿到 `upload_url`、`required_headers` 与 `ticket`（30 分钟有效）；2) 使用 `PUT` 将原始文件字节按 `required_headers` 上传到 `upload_url`（**不要携带 `Authorization` 头**）；3) 调用 `POST /v1/media/uploads/complete` 换取 73 小时有效期的读取链接 `url`。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaUploadRequest"
              },
              "example": {
                "kind": "image",
                "bytes": 3961,
                "sha256": "b33654334e561511dbf73d20550443ce75ea5c56e647a6a18ae9e008cccf4656",
                "mime": "image/png"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回预签名上传地址、必需请求头与 30 分钟有效期票据。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaUploadSession"
                },
                "example": {
                  "upload_url": "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/image/v1/cos-object/example?X-Amz-Expires=1800&X-Amz-Signature=example",
                  "upload_method": "PUT",
                  "required_headers": {
                    "Content-Length": "3961",
                    "Content-Type": "image/png"
                  },
                  "ticket": "example_signed_ticket_token",
                  "upload_expires_at": "2026-11-26T05:08:04Z",
                  "expires_at": "2026-11-26T05:08:04Z"
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或来源 IP 不在白名单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/media/uploads/complete": {
      "post": {
        "operationId": "completeMediaUpload",
        "tags": [
          "素材上传"
        ],
        "summary": "确认素材上传完成并换取读取链接",
        "description": "在完成 `PUT <upload_url>` 之后调用，服务端校验对象完整性与 MIME 类型后返回有效期 73 小时的广州 COS 签名读取 URL，可直接传入 `/v1/media/tasks`、`/v1/images/edits` 或 `/v1/videos`。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MediaUploadCompleteRequest"
              },
              "example": {
                "ticket": "example_signed_ticket_token"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "上传确认成功，返回可用于媒体生成的 HTTPS 临时链接。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MediaUploadCompleteResult"
                },
                "example": {
                  "url": "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/image/v1/cos-object/example?X-Amz-Expires=262800&X-Amz-Signature=example",
                  "kind": "image",
                  "mime": "image/png",
                  "bytes": 3961,
                  "sha256": "b33654334e561511dbf73d20550443ce75ea5c56e647a6a18ae9e008cccf4656",
                  "expires_at": "2026-11-29T05:38:08Z"
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或来源 IP 不在白名单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "tags": [
          "目录与估价"
        ],
        "summary": "查询实时模型目录与能力声明",
        "description": "返回当前API Key 可调用的精确模型 ID（`data[].id`）、支持的接口类型（`supported_endpoint_types`）、动态能力声明（`image_capabilities` / `video_capabilities` / `media_capabilities`）、内联实时人民币报价（`pricing`）以及顶层统一媒体协议声明（`media_protocol`）。\n\n支持通过 `ETag` / `If-None-Match` 做增量缓存校验；单模型查询可调用 `GET /v1/models/{model}`。",
        "responses": {
          "200": {
            "description": "返回当前 Key 的实时模型列表与协议能力。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "ETag": {
                "$ref": "#/components/headers/CatalogETag"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelListResponse"
                },
                "example": {
                  "object": "list",
                  "media_protocol": {
                    "version": "managed-media-v1",
                    "supported_media_types": [
                      "image",
                      "video",
                      "upscale",
                      "audio"
                    ],
                    "task_submit_url": "/v1/media/tasks",
                    "task_query_url_template": "/v1/media/tasks/{task_ref}",
                    "uploads_url": "/v1/media/uploads",
                    "async_supported": true,
                    "sync_compat_endpoints": [
                      "/v1/images/generations",
                      "/v1/images/edits"
                    ]
                  },
                  "data": [
                    {
                      "id": "dola-seedream-5-5-261028",
                      "display_name": "Seedream 5.5",
                      "object": "model",
                      "created": 1626777600,
                      "owned_by": "beeftv",
                      "supported_endpoint_types": [
                        "image-generation"
                      ],
                      "image_capabilities": {
                        "size": {
                          "parameter": "size",
                          "values": [
                            "1K",
                            "1.5K",
                            "2K"
                          ],
                          "default": "2K",
                          "allowCustom": true,
                          "tiers": [
                            "1K",
                            "1.5K",
                            "2K"
                          ],
                          "minPixels": 921600,
                          "maxPixels": 4624220
                        },
                        "references": {
                          "maxImages": 10,
                          "maskSupported": false
                        },
                        "transparentBackground": {
                          "supported": true,
                          "default": false
                        },
                        "background": {
                          "supported": true,
                          "values": [
                            "auto",
                            "transparent",
                            "opaque"
                          ],
                          "default": "auto"
                        },
                        "outputFormat": {
                          "supported": true,
                          "values": [
                            "png",
                            "jpeg"
                          ],
                          "default": "png"
                        },
                        "directDelivery": {
                          "supported": true
                        },
                        "controls": {
                          "layer_decomposition": {
                            "type": "boolean",
                            "default": false
                          },
                          "layer_decomposition_options.max_images": {
                            "type": "integer",
                            "min": 2,
                            "max": 100,
                            "step": 1,
                            "default": 30,
                            "visible_when": {
                              "layer_decomposition": true
                            }
                          },
                          "layer_decomposition_options.text_recognition": {
                            "type": "boolean",
                            "default": true,
                            "visible_when": {
                              "layer_decomposition": true
                            }
                          },
                          "optimize_prompt_options.mode": {
                            "type": "string",
                            "enum": [
                              "standard"
                            ],
                            "default": "standard"
                          },
                          "watermark": {
                            "type": "boolean",
                            "default": false
                          }
                        },
                        "maxOutputs": 1
                      },
                      "pricing": {
                        "model_name": "dola-seedream-5-5-261028",
                        "mode": "per_request",
                        "per_request_cny": 0.0237349,
                        "display_kind": "image",
                        "image_price_table": {
                          "pricebook_id": "enterprise_cny_v1",
                          "currency": "CNY",
                          "output": {
                            "standard": {
                              "1K": 0.0135628,
                              "2K": 0.0237349
                            },
                            "layers": {
                              "1K": 0.0135628,
                              "2K": 0.0237349
                            }
                          },
                          "reference": 0.00542512,
                          "free_reference_images": 0,
                          "low_tier_max_pixels": 2601123,
                          "default_quality": "standard",
                          "default_size": "2K"
                        }
                      }
                    }
                  ],
                  "success": true
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或来源 IP 不在白名单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/pricing/estimate": {
      "post": {
        "operationId": "estimatePricing",
        "tags": [
          "目录与估价"
        ],
        "summary": "生成前权威人民币价格预估",
        "description": "只读接口（不建任务、不扣费），按当前API Key 生效的人民币价格簿批量试算 1–2000 个图像、视频或音频计划项的预估费用。\n\n- 适合下游平台在用户点击生成前展示透明价格与做余额预检。\n- 对于生成前张数未知（如图层拆分 `layers: true`）或按实际 Token/账单后结的型号，`items[].amount` 会返回 `null` 并标明 `variable: true` 或 `approx: true`，**绝不把未知价当 0 计入合计**；最终扣费请以调用后 `GET /v1/usage/requests` 返回的实扣 `amount` 为准。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PricingEstimateRequest"
              },
              "example": {
                "targets": [
                  {
                    "model": "dola-seedream-5-5-261028",
                    "kind": "image",
                    "size": "1K",
                    "count": 1
                  },
                  {
                    "model": "dola-seedream-5-5-261028",
                    "kind": "image",
                    "size": "2K",
                    "count": 1,
                    "referenceImages": 2
                  },
                  {
                    "model": "dola-seedream-5-5-261028",
                    "kind": "image",
                    "size": "2K",
                    "layers": true,
                    "count": 4,
                    "referenceImages": 1
                  },
                  {
                    "model": "magi-2",
                    "kind": "video",
                    "resolution": "1080p",
                    "seconds": 5
                  },
                  {
                    "model": "minimax-speech-2.8-turbo",
                    "kind": "audio",
                    "characters": 100
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回逐项人民币预估与汇总。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PricingEstimateResponse"
                },
                "example": {
                  "items": [
                    {
                      "amount": 0.0136,
                      "label": "预计 ¥0.0136",
                      "basis": "1K ¥0.0136/张 × 1 张",
                      "text": "预计 ¥0.0136（1K ¥0.0136/张 × 1 张）"
                    },
                    {
                      "amount": 0.0346,
                      "label": "预计 ¥0.0346",
                      "basis": "2K ¥0.0237/张 × 1 张 + 参考图 2 张 × ¥0.0054",
                      "text": "预计 ¥0.0346（2K ¥0.0237/张 × 1 张 + 参考图 2 张 × ¥0.0054）"
                    },
                    {
                      "amount": null,
                      "label": "每层 ¥0.0237",
                      "variable": true,
                      "basis": "图层拆分按实际拆出的图层数计费，每层 ¥0.0237 + 参考图 1 张 × ¥0.0054",
                      "text": "图层拆分按实际拆出的图层数计费，每层 ¥0.0237 + 参考图 1 张 × ¥0.0054"
                    },
                    {
                      "amount": 3,
                      "label": "预计 ¥3",
                      "basis": "1080p ¥0.6/秒 × 5 秒",
                      "text": "预计 ¥3（1080p ¥0.6/秒 × 5 秒）"
                    },
                    {
                      "amount": 0.02,
                      "approx": true,
                      "label": "约 ¥0.02",
                      "basis": "100 字 × ¥200/百万字",
                      "text": "约 ¥0.02（100 字 × ¥200/百万字）"
                    }
                  ],
                  "summary": {
                    "amount": 3.0682,
                    "priced": 4,
                    "unknown": 1,
                    "approx": true,
                    "text": "预计费用：已知部分约 ¥3.07，另有 1 项暂无价格"
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或来源 IP 不在白名单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/balance": {
      "get": {
        "operationId": "getBalance",
        "tags": [
          "用量与对账"
        ],
        "summary": "查询账户钱包余额与当前 Key 额度",
        "description": "只读查询当前认证 API Key 所属账户在当前站点的钱包余额（`wallet`）以及该 Key 自身的额度与状态（`key`），适合下游平台对接余额低水位告警（例如低于 ¥500 自动发飞书/钉钉通知）。\n\n- **额度耗尽或过期后仍可调用**：与 `GET /v1/usage` 相同，即使账户余额归零、Key 额度用尽、过期或停用，只要密钥归属当前站点、通过 IP 白名单且所属用户未被封禁，即可正常查回余额状态。\n- 响应永远不会返回 API Key 明文，且始终携带 `Cache-Control: no-store`。\n- `available_amount` / `used_amount` / `remaining_amount` 为 6 位小数人民币字符串（`currency: \"CNY\"`）；`available_quota` / `used_quota` / `remaining_quota` 为对应的内部整数额度（`500,000 = ¥1.00`）。",
        "responses": {
          "200": {
            "description": "返回当前站点的账户钱包余额与当前 API Key 额度状态。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyBalanceSummary"
                },
                "example": {
                  "currency": "CNY",
                  "market": "enterprise",
                  "wallet": {
                    "available_amount": "1250.500000",
                    "used_amount": "342.185000",
                    "available_quota": 625250000,
                    "used_quota": 171092500,
                    "request_count": 4820
                  },
                  "key": {
                    "id": 1024,
                    "name": "production-backend",
                    "status": "enabled",
                    "unlimited_quota": false,
                    "remaining_amount": "500.000000",
                    "used_amount": "120.500000",
                    "remaining_quota": 250000000,
                    "used_quota": 60250000,
                    "expires_at": null
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效或已被删除（余额为 0、Key 额度用尽、已停用或已过期的有效 Key 仍返回 200）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "无效的令牌"
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、来源 IP 不在白名单，或所属账户已被封禁。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "该 API Key 不属于当前站点",
                  "code": "key_site_mismatch"
                }
              }
            }
          },
          "429": {
            "description": "触发查询限流，请按 Retry-After 响应头等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              }
            }
          },
          "503": {
            "description": "服务端暂不可用，请有限退避重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "getUsage",
        "tags": [
          "用量与对账"
        ],
        "summary": "查询当前 Key 人民币用量汇总",
        "description": "返回当前认证API Key 在指定时间区间（最多 31 天，默认最近 30 天）内的人民币消费汇总、按模型分桶（`by_model`）与按日分桶（`daily`）。\n\n- 所有金额为 6 位小数十进制字符串（单位 `CNY`），请使用十进制定点库解析。\n- `settled_amount` 已体现净结算投影，**不要再用 `settled_amount - refunded_amount` 二次相减**。\n\n与 `GET /v1/balance` 一致，本接口采用只读鉴权：即使账户余额归零或 API Key 额度耗尽、过期、停用仍可正常返回 `200`；鉴权失败返回 `{\"success\": false, \"message\": \"...\"}`。",
        "parameters": [
          {
            "name": "start_time",
            "in": "query",
            "required": false,
            "description": "起始 Unix 秒（包含），默认 `end_time - 30 天`。",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "end_time",
            "in": "query",
            "required": false,
            "description": "结束 Unix 秒（不包含），与 `start_time` 跨度不超过 31 天。",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "description": "按精确模型 ID 筛选。",
            "schema": {
              "type": "string",
              "maxLength": 191
            }
          }
        ],
        "responses": {
          "200": {
            "description": "返回人民币汇总与分桶统计。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyUsageSummary"
                },
                "example": {
                  "currency": "CNY",
                  "start_time": 1793076169,
                  "end_time": 1795668169,
                  "settled_amount": "1.473844",
                  "pending_amount": "0.000000",
                  "refunded_amount": "0.301200",
                  "records": 16,
                  "unknown_records": 0,
                  "by_model": [
                    {
                      "model": "dola-seedream-5-5-261028",
                      "settled_amount": "0.102396",
                      "pending_amount": "0.000000",
                      "refunded_amount": "0.000000",
                      "records": 5,
                      "unknown_records": 0
                    }
                  ],
                  "daily": [
                    {
                      "date": "2026-11-26",
                      "settled_amount": "1.473844",
                      "pending_amount": "0.000000",
                      "refunded_amount": "0.301200",
                      "records": 16,
                      "unknown_records": 0
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效或已被删除（余额为 0、Key 额度用尽、已停用或已过期的有效 Key 仍返回 200）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "无效的令牌"
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、来源 IP 不在白名单，或所属账户已被封禁。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "该 API Key 不属于当前站点",
                  "code": "key_site_mismatch"
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage/requests": {
      "get": {
        "operationId": "getUsageRequests",
        "tags": [
          "用量与对账"
        ],
        "summary": "按 Request ID 或分页查询单笔结算明细",
        "description": "下游平台给终端用户扣费和财务对账的**权威金额来源**。\n\n- **如何取 `request_id`**：保存每次 API 响应头中的 **`X-Oneapi-Request-Id`**；若同步图片请求命中 `Idempotency-Replayed: true`，请使用响应头里的 **`X-Image-Request-Id`**（原计费请求 ID）。\n- 单次调用如触发站内自动重试，同一 `request_id` 下可能返回多条记录（例如失败尝试 `billing_status: \"unknown\", amount: null` 与成功结算 `billing_status: \"settled\", amount: \"0.013562\"`），请按 `billing_status == \"settled\"` 或 `refunded` 汇总真实扣费，切勿假设永远只有 1 行。\n\n与 `GET /v1/balance` 一致，本接口采用只读鉴权：即使账户余额归零或 API Key 额度耗尽、过期、停用仍可正常返回 `200`；鉴权失败返回 `{\"success\": false, \"message\": \"...\"}`。",
        "parameters": [
          {
            "name": "request_id",
            "in": "query",
            "required": false,
            "description": "从响应头 `X-Oneapi-Request-Id`（或图片重放时的 `X-Image-Request-Id`）获取的请求 ID。",
            "schema": {
              "type": "string",
              "maxLength": 64
            },
            "example": "202611260438099607140728268d9d6BUOCtxHt"
          },
          {
            "name": "model",
            "in": "query",
            "required": false,
            "description": "按精确模型 ID 筛选。",
            "schema": {
              "type": "string",
              "maxLength": 191
            }
          },
          {
            "name": "start_time",
            "in": "query",
            "required": false,
            "description": "起始 Unix 秒（包含）。",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "end_time",
            "in": "query",
            "required": false,
            "description": "结束 Unix 秒（不包含），跨度 ≤ 31 天。",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "每页记录数，默认 50，最大 100。",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 100,
              "default": 50
            }
          },
          {
            "name": "before",
            "in": "query",
            "required": false,
            "description": "上一页返回的 `next_cursor`（纯数字字符串，非 `usage_` 前缀 ID）。",
            "schema": {
              "type": "integer",
              "minimum": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "返回按时间倒序排列的结算明细列表。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/KeyUsagePage"
                },
                "examples": {
                  "seedream_settled": {
                    "summary": "Seedream 5.5 单笔实扣查询（含精确人民币 amount）",
                    "value": {
                      "currency": "CNY",
                      "start_time": 1793076171,
                      "end_time": 1795668171,
                      "data": [
                        {
                          "id": "usage_2633576",
                          "request_id": "202611260438099607140728268d9d6BUOCtxHt",
                          "created_at": 1795667907,
                          "model": "dola-seedream-5-5-261028",
                          "result": "unknown",
                          "billing_status": "settled",
                          "amount": "0.013562",
                          "reserved_amount": null,
                          "refunded_amount": null,
                          "input_tokens": 1,
                          "output_tokens": 4096,
                          "cache_read_tokens": 0,
                          "cache_write_tokens": null,
                          "usage_estimated": false,
                          "pricebook_id": "enterprise_cny_v1",
                          "pricing_version": "sha256:example"
                        }
                      ],
                      "next_cursor": "",
                      "has_more": false
                    }
                  },
                  "async_settled_with_refund": {
                    "summary": "异步媒体任务多退少补结算记录",
                    "value": {
                      "currency": "CNY",
                      "start_time": 1793076171,
                      "end_time": 1795668171,
                      "data": [
                        {
                          "id": "usage_2633607",
                          "request_id": "202611260440244639945528268d9d6kXytkWZH",
                          "created_at": 1795668024,
                          "model": "minimax-speech-2.8-turbo",
                          "result": "completed",
                          "billing_status": "settled",
                          "amount": "0.003600",
                          "reserved_amount": "0.304800",
                          "refunded_amount": "0.301200",
                          "input_tokens": 0,
                          "output_tokens": 0,
                          "cache_read_tokens": null,
                          "cache_write_tokens": null,
                          "usage_estimated": false,
                          "pricebook_id": "enterprise_cny_v1",
                          "pricing_version": "sha256:example"
                        }
                      ],
                      "next_cursor": "",
                      "has_more": false
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效或已被删除（余额为 0、Key 额度用尽、已停用或已过期的有效 Key 仍返回 200）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "无效的令牌"
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、来源 IP 不在白名单，或所属账户已被封禁。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "success",
                    "message"
                  ],
                  "properties": {
                    "success": {
                      "type": "boolean"
                    },
                    "message": {
                      "type": "string"
                    },
                    "code": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "success": false,
                  "message": "该 API Key 不属于当前站点",
                  "code": "key_site_mismatch"
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "tags": [
          "文本对话"
        ],
        "summary": "Chat Completions 对话补全",
        "description": "OpenAI 兼容对话接口，支持纯文本、多模态视觉理解（`image_url`）、工具调用与 SSE 流式输出（`stream: true`）。支持推理的模型会在 `message.reasoning_content` 与 `usage.completion_tokens_details.reasoning_tokens` 中返回思考过程和推理 Token。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              },
              "example": {
                "model": "deepseek-v4.1-flash",
                "messages": [
                  {
                    "role": "user",
                    "content": "用一句话介绍你自己"
                  }
                ],
                "max_tokens": 128,
                "stream": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "非流式返回完整 JSON；`stream: true` 时返回 `text/event-stream`，末尾为 `data: [DONE]`。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                },
                "example": {
                  "id": "chatcmpl_example",
                  "object": "chat.completion",
                  "created": 1795668062,
                  "model": "deepseek-v4-1-flash-261017",
                  "choices": [
                    {
                      "index": 0,
                      "finish_reason": "stop",
                      "message": {
                        "role": "assistant",
                        "content": "OK",
                        "reasoning_content": "We need to answer only OK."
                      }
                    }
                  ],
                  "usage": {
                    "prompt_tokens": 33,
                    "completion_tokens": 11,
                    "total_tokens": 44,
                    "prompt_tokens_details": {
                      "cached_tokens": 0
                    },
                    "completion_tokens_details": {
                      "reasoning_tokens": 9
                    }
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "每行 `data: <JSON>` 的增量块（`object: \"chat.completion.chunk\"`），结束行为 `data: [DONE]`。"
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "operationId": "createResponse",
        "tags": [
          "文本对话"
        ],
        "summary": "Responses 响应接口",
        "description": "面向支持 Responses 协议的文本模型（如 `gpt-5.6-sol`、`gpt-6-sol`）。响应 `output` 数组可包含文本消息、推理项与工具调用等多种元素，请遍历处理。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ResponsesRequest"
              },
              "example": {
                "model": "gpt-5.6-sol",
                "input": "用一句话解释异步任务轮询。",
                "max_output_tokens": 128
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回 Responses 对象（或 `stream: true` 时返回 SSE 事件流，直至 `response.completed`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponsesObject"
                },
                "example": {
                  "id": "resp_example",
                  "object": "response",
                  "created_at": 1795668068,
                  "completed_at": 1795668068,
                  "status": "completed",
                  "model": "gpt-5.6-sol",
                  "output": [
                    {
                      "type": "message",
                      "id": "msg_example",
                      "role": "assistant",
                      "status": "completed",
                      "content": [
                        {
                          "type": "output_text",
                          "text": "OK",
                          "annotations": []
                        }
                      ]
                    }
                  ],
                  "usage": {
                    "input_tokens": 9,
                    "input_tokens_details": {
                      "cached_tokens": 0,
                      "cache_write_tokens": 0
                    },
                    "output_tokens": 5,
                    "output_tokens_details": {
                      "reasoning_tokens": 0
                    },
                    "total_tokens": 14
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "当 `stream: true` 时返回标准 Responses SSE 事件流。"
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "operationId": "createMessage",
        "tags": [
          "文本对话"
        ],
        "summary": "Anthropic Messages 对话接口",
        "description": "Anthropic Messages 协议接口（如 `claude-sonnet-4-6`、`claude-opus-5`）。支持可选 `anthropic-version` 请求头（省略时默认 `2023-06-01`）与 `max_tokens`。\n\n> **错误格式说明**：本接口中继错误遵循 Anthropic 协议格式 `{\"type\": \"error\", \"error\": {\"type\": \"...\", \"message\": \"...\"}}`。",
        "parameters": [
          {
            "name": "anthropic-version",
            "in": "header",
            "required": false,
            "description": "Anthropic 协议版本头，建议传入 `2023-06-01`。",
            "schema": {
              "type": "string",
              "default": "2023-06-01"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicMessageRequest"
              },
              "example": {
                "model": "claude-sonnet-4-6",
                "max_tokens": 128,
                "messages": [
                  {
                    "role": "user",
                    "content": "用一句话介绍缓存计费"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回 Messages 对象与含缓存明细的 `usage`。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicMessageResponse"
                },
                "example": {
                  "id": "msg_example",
                  "type": "message",
                  "role": "assistant",
                  "model": "claude-sonnet-4-6",
                  "content": [
                    {
                      "type": "text",
                      "text": "OK"
                    }
                  ],
                  "stop_reason": "end_turn",
                  "stop_sequence": null,
                  "usage": {
                    "input_tokens": 10,
                    "output_tokens": 3,
                    "cache_creation_input_tokens": 0,
                    "cache_read_input_tokens": 0,
                    "cache_creation": {
                      "ephemeral_5m_input_tokens": 0,
                      "ephemeral_1h_input_tokens": 0
                    }
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "当 `stream: true` 时返回 Anthropic Messages SSE 事件流。"
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/images/generations": {
      "post": {
        "operationId": "generateImage",
        "tags": [
          "图像兼容接口"
        ],
        "summary": "图像生成（兼容接口）",
        "description": "OpenAI 兼容同步生图入口（**仅支持同步调用，不支持 `async: true` 或异步轮询**；如需异步提交、防超时或 Webhook 回调，请改用 `POST /v1/media/tasks`）。\n\n- **端点与参数说明**：纯文生图无需传入 `image`；为兼容火山方舟 / BytePlus Seedream 原生单端点约定，Seedream 型号也支持直接在本接口传入 `image`（参考图生图）或 `layer_decomposition: true`（图层拆解），效果与 `POST /v1/images/edits` 等价。\n- **图层拆解型号差异**：`dola-seedream-5-5-261028`（5.5）、`dola-seedream-5-0-pro-260628`（5.0 Pro）、`dola-seedream-5-0-flash-260915`（5.0 Flash）支持 `layer_decomposition: true`（须恰好 1 张输入图，`size` 仅支持省略/`auto`/`1K`/`1.5K`/`2K`，不支持自定义 `宽x高` 与 `background`）；**`layer_decomposition_options` 仅 Seedream 5.5 支持**，5.0 Pro / 5.0 Flash 请省略该字段（默认最多 17 层，传入会返回 `400`）。各型号实际支持的参数清单以 `GET /v1/models` 的 `image_capabilities.controls` 为准。\n- **何时返回图层字段**：仅当开启 `layer_decomposition: true` 时，`data[]` 才会返回多图层结果及 `z_index`、`bounding_box`、`name`、`description`（以及 5.5 开启 `text_recognition` 时的文字识别结构）；普通文生图只返回 `url`、`size`、`output_format`、`background`。\n- **长耗时防超时**：Seedream 多图层拆解等长耗时同步请求，建议使用 `https://beeftv.cn`（回源超时 600 秒）或改用异步 `POST /v1/media/tasks`（`\"async\": true`），避免海外 CDN 代理层在约 100 秒断开并返回 HTML 超时页。\n- **返回每张图的实际像素尺寸**：Seedream 5.5（`dola-seedream-5-5-261028`）与 Seedream 5.0 Pro（`dola-seedream-5-0-pro-260628`）在原始 HTTP JSON 响应中必返回 **`data[].size`**（格式 `\"宽x高\"`，如 `\"1024x1024\"`、`\"2496x1664\"`）及顶层 **`usage`**（`input_images`、`generated_images`、`output_tokens`、`total_tokens`）。\n- **按像素算价**：解析 `data[i].size` 计算 `宽 × 高`：Seedream 5.5 以 `≤ 2,601,123` 像素（260.11 万像素）划分低/高像素档，5.0 Pro 以 `≤ 2,610,000` 像素（261 万像素）划分两档；图层拆解时每一层各自带 `size` 逐张计费。\n- **OpenAI SDK 注意**：官方 SDK 的强类型 `Image` 类未声明 `size`，Python SDK 请读 `item.model_extra[\"size\"]` 或 `resp.to_dict()`，强类型语言建议直接解析原始 HTTP JSON，或直接用响应头 `X-Oneapi-Request-Id`（重放时用 `X-Image-Request-Id`）调 `GET /v1/usage/requests` 获取实扣人民币 `amount`。",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "推荐每次独立生图传入唯一幂等键（1–255 个可见非空白 ASCII 字符（0x21–0x7E，不含空格））。断线重发同一 Key 与同一请求体返回原结果，不重复生图或二次扣费；响应保存 24 小时。",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          {
            "name": "X-Beeftv-Image-Delivery",
            "in": "header",
            "required": false,
            "description": "可选图片交付方式（默认省略或 `managed` 走广州 COS 转存，不影响存量客户端）。传 `direct` 时，对支持官方直链的型号（当前为 Seedream 系列，可通过 `GET /v1/models` 的 `image_capabilities.directDelivery.supported` 查询）跳过 COS 转存并直接返回上游 BytePlus 官方临时 HTTPS 链接（有效期约 24 小时）；非 Seedream 型号自动回退 `managed` 广州 COS 交付，并在响应头返回实际生效值。异步接口 `POST /v1/media/tasks`（`media_type: \"image\"`）同样支持此请求头或 `options.delivery: \"direct\"`；切换 `managed`/`direct` 须更换新的 `Idempotency-Key` / `task_ref`。",
            "schema": {
              "type": "string",
              "enum": [
                "managed",
                "direct"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageGenerationRequest"
              },
              "examples": {
                "seedream55_2k": {
                  "summary": "Seedream 5.5 文生图（2K）",
                  "value": {
                    "model": "dola-seedream-5-5-261028",
                    "prompt": "一只橙色小猫坐在窗台上，阳光洒落",
                    "size": "2K",
                    "output_format": "png",
                    "background": "opaque"
                  }
                },
                "seedream55_transparent_png": {
                  "summary": "Seedream 5.5 透明底 PNG（background + output_format）",
                  "value": {
                    "model": "dola-seedream-5-5-261028",
                    "prompt": "一只国风青瓷小茶杯贴纸，居中构图，干净边缘",
                    "size": "1K",
                    "output_format": "png",
                    "background": "transparent"
                  }
                },
                "seedream55_layers": {
                  "summary": "Seedream 5.5 图层拆解与文字识别（支持 layer_decomposition_options）",
                  "value": {
                    "model": "dola-seedream-5-5-261028",
                    "image": "https://example.com/poster.png",
                    "layer_decomposition": true,
                    "layer_decomposition_options": {
                      "max_images": 10,
                      "text_recognition": true
                    }
                  }
                },
                "seedream50_pro_layers": {
                  "summary": "Seedream 5.0 Pro / Flash 图层拆解（勿传 layer_decomposition_options）",
                  "value": {
                    "model": "dola-seedream-5-0-pro-260628",
                    "image": "https://example.com/poster.png",
                    "size": "1K",
                    "layer_decomposition": true
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回生成的图片数组；Seedream 型号完整透传每张图的 `size`、`output_format`、`background`、拆层元信息及 `usage`。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-Image-Request-Id": {
                "$ref": "#/components/headers/ImageRequestId"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              },
              "X-Beeftv-Image-Delivery": {
                "$ref": "#/components/headers/ImageDelivery"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageResponse"
                },
                "examples": {
                  "seedream55_2k": {
                    "summary": "Seedream 5.5 2K 文生图真实返回结构（含 data[].size 与 usage）",
                    "value": {
                      "model": "dola-seedream-5-5-261028",
                      "created": 1795667922,
                      "data": [
                        {
                          "url": "https://beeftv.app/v1/images/proxy?t=example_token",
                          "size": "2496x1664",
                          "output_format": "png",
                          "background": "opaque"
                        }
                      ],
                      "usage": {
                        "input_images": 0,
                        "generated_images": 1,
                        "output_tokens": 16224,
                        "total_tokens": 16224
                      }
                    }
                  },
                  "seedream55_layers": {
                    "summary": "Seedream 5.5 图层拆解真实返回结构（每层各自含 size 与 bounding_box）",
                    "value": {
                      "model": "dola-seedream-5-5-261028",
                      "created": 1795667980,
                      "data": [
                        {
                          "url": "https://beeftv.app/v1/images/proxy?t=example_base",
                          "size": "1024x1024",
                          "output_format": "png",
                          "z_index": 0,
                          "background": "opaque"
                        },
                        {
                          "url": "https://beeftv.app/v1/images/proxy?t=example_layer_1",
                          "size": "1024x1024",
                          "output_format": "png",
                          "z_index": 1,
                          "bounding_box": {
                            "absolute": [
                              140,
                              140,
                              882,
                              882
                            ],
                            "normalized": [
                              137,
                              137,
                              861,
                              861
                            ]
                          },
                          "name": "Centered solid orange square patch",
                          "description": "A centered solid orange filled square color block.",
                          "background": "transparent"
                        }
                      ],
                      "usage": {
                        "input_images": 1,
                        "generated_images": 2,
                        "output_tokens": 8192,
                        "total_tokens": 8192
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "409": {
            "description": "幂等键冲突（`idempotency_conflict`）、原请求仍在执行（`image_submission_pending`）或结果待人工核查（`image_result_unknown`）。切勿自动换新 Key 重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "category": "input",
                    "code": "idempotency_conflict",
                    "message": "此幂等键已用于不同的图片请求，请用原请求查询结果。",
                    "request_id": "202611260438303668669388268d9d6QYKPi9MG"
                  }
                }
              }
            }
          },
          "410": {
            "description": "该 `Idempotency-Key` 保存的响应体已超过 24 小时有效期，不会重新触发生成。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "category": "input",
                    "code": "image_result_expired",
                    "message": "The saved response has expired. This key will not generate another image.",
                    "request_id": "202611260438303668669388268d9d6example"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/images/edits": {
      "post": {
        "operationId": "editImage",
        "tags": [
          "图像兼容接口"
        ],
        "summary": "图像编辑与图层拆解（兼容接口）",
        "description": "**仅支持同步调用，不支持 `async: true` 或异步轮询**；如需异步提交或 Webhook 回调请改用 `POST /v1/media/tasks`。\n\n基于 1 张或多张参考图编辑图像，或对单张参考图执行 Seedream 图层拆解（`layer_decomposition: true`）。推荐先通过 `POST /v1/media/uploads` 直传广州 COS 拿到临时链接，再以 JSON 传入 `image`（不建议传大体积 Base64）。\n\n- **图层拆解说明**：`dola-seedream-5-5-261028`、`dola-seedream-5-0-pro-260628`、`dola-seedream-5-0-flash-260915` 开启 `layer_decomposition: true` 时须传入恰好 1 张 `image`，此时 **`prompt` 可省略**，`size` 仅支持省略（默认 `auto`）或 `auto`/`1K`/`1.5K`/`2K`（不支持自定义 `宽x高` 与 `background`）；**`layer_decomposition_options` 仅 Seedream 5.5 支持**，5.0 Pro / 5.0 Flash 须省略该字段（默认最多 17 层，传入会返回 `400`）。仅开启拆层时 `data[]` 才会返回多图层结构及 `z_index`、`bounding_box`、`name`、`description`（以及 Seedream 5.5 开启 `text_recognition` 时的文字识别结构）。Seedream 同时兼容本接口与 `POST /v1/images/generations`，各型号支持的参数清单可在 `GET /v1/models` 的 `image_capabilities.controls` 查询。\n- **长耗时防超时**：多图层拆解同步耗时会随图层数增加，建议使用 `https://beeftv.cn`（回源超时 600 秒）或改用异步 `POST /v1/media/tasks`（`\"async\": true`），避免海外 CDN 代理层在约 100 秒超时并返回 HTML 错误页。\n- **计费口径**：Seedream 5.5 从第 1 张参考图起按张另计（单次请求只计一次），Seedream 5.0 Pro 首张参考图免费、第 2 张起按张计费，响应同样返回 `data[].size` 与 `usage.input_images`。",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "可选幂等键（1–255 个可见非空白 ASCII 字符（0x21–0x7E，不含空格）），防超时重扣。",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          },
          {
            "name": "X-Beeftv-Image-Delivery",
            "in": "header",
            "required": false,
            "description": "可选图片交付方式（默认省略或 `managed` 走广州 COS 转存）。传 `direct` 时，对支持官方直链的型号（当前为 Seedream 系列，可在 `GET /v1/models` 的 `image_capabilities.directDelivery.supported` 查询）跳过 COS 转存并直接返回 BytePlus 官方临时 HTTPS 链接（有效期约 24 小时），可进一步缩短多图层拆解耗时；非 Seedream 型号自动回退 `managed` 广州 COS 交付，并在响应头返回实际生效值。异步接口 `POST /v1/media/tasks`（`media_type: \"image\"`）同样支持此请求头或 `options.delivery: \"direct\"`；切换 `managed`/`direct` 须更换新的 `Idempotency-Key` / `task_ref`。",
            "schema": {
              "type": "string",
              "enum": [
                "managed",
                "direct"
              ]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageEditRequest"
              },
              "examples": {
                "seedream55_edit": {
                  "summary": "Seedream 5.5 参考图编辑",
                  "value": {
                    "model": "dola-seedream-5-5-261028",
                    "prompt": "把画面中的橙色方块改成金色五角星，保持背景不变",
                    "image": [
                      "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/image/v1/cos-object/example"
                    ],
                    "size": "1K"
                  }
                },
                "seedream55_layers": {
                  "summary": "Seedream 5.5 图层拆解与文字识别（无需 prompt，支持 layer_decomposition_options）",
                  "value": {
                    "model": "dola-seedream-5-5-261028",
                    "image": [
                      "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/image/v1/cos-object/example"
                    ],
                    "size": "1K",
                    "layer_decomposition": true,
                    "layer_decomposition_options": {
                      "max_images": 10,
                      "text_recognition": true
                    }
                  }
                },
                "seedream50_pro_layers": {
                  "summary": "Seedream 5.0 Pro / Flash 图层拆解（无需 prompt，勿传 layer_decomposition_options）",
                  "value": {
                    "model": "dola-seedream-5-0-pro-260628",
                    "image": [
                      "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/image/v1/cos-object/example"
                    ],
                    "size": "1K",
                    "layer_decomposition": true
                  }
                },
                "birefnet_matting": {
                  "summary": "BiRefNet 单图精准抠图（输出真透明 RGBA PNG，勿传 size）",
                  "value": {
                    "model": "birefnet-beeftv",
                    "image": [
                      "https://<bucket>.cos.ap-guangzhou.myqcloud.com/transient/image/v1/cos-object/example"
                    ]
                  }
                }
              }
            },
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt",
                  "image"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "精确图片模型 ID，如 `gpt-image-2.5`、`dola-seedream-5-5-261028`。"
                  },
                  "prompt": {
                    "type": "string",
                    "description": "编辑指令。"
                  },
                  "image": {
                    "type": "string",
                    "format": "binary",
                    "description": "参考图片二进制文件（PNG/JPEG/WebP）。"
                  },
                  "mask": {
                    "type": "string",
                    "format": "binary",
                    "description": "可选局部蒙版（仅支持蒙版的型号有效；Seedream 系列不支持蒙版）。"
                  },
                  "size": {
                    "type": "string",
                    "description": "输出尺寸档位或 `宽x高`。"
                  },
                  "quality": {
                    "type": "string",
                    "description": "画质档位（仅 `gpt-image-*` 系列使用）。"
                  },
                  "image[]": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    },
                    "description": "多张参考图片文件数组（与 `image` 字段二选一或配合传入）。"
                  },
                  "n": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 128,
                    "description": "生成张数。"
                  },
                  "response_format": {
                    "type": "string",
                    "enum": [
                      "url",
                      "b64_json"
                    ],
                    "description": "返回格式（默认 `url`）。"
                  },
                  "background": {
                    "type": "string",
                    "enum": [
                      "auto",
                      "transparent",
                      "opaque"
                    ],
                    "description": "背景模式。"
                  },
                  "output_format": {
                    "type": "string",
                    "enum": [
                      "png",
                      "jpeg"
                    ],
                    "description": "输出图片格式。"
                  },
                  "watermark": {
                    "type": "boolean",
                    "description": "是否添加水印（Seedream 默认 `false`）。"
                  },
                  "input_fidelity": {
                    "type": "string",
                    "description": "输入保真度控制（支持型号生效）。"
                  }
                },
                "description": "支持表单上传图片文件编辑（Seedream 图层拆解 `layer_decomposition*` 与 `safety_identifier` 仅支持 `application/json`，请勿走表单上传）。"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回编辑后的图片及实际输出尺寸与用量。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "X-Image-Request-Id": {
                "$ref": "#/components/headers/ImageRequestId"
              },
              "Idempotency-Replayed": {
                "$ref": "#/components/headers/IdempotencyReplayed"
              },
              "X-Beeftv-Image-Delivery": {
                "$ref": "#/components/headers/ImageDelivery"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageResponse"
                },
                "examples": {
                  "seedream55_edit": {
                    "summary": "Seedream 5.5 参考图编辑返回结构",
                    "value": {
                      "model": "dola-seedream-5-5-261028",
                      "created": 1795667965,
                      "data": [
                        {
                          "url": "https://beeftv.app/v1/images/proxy?t=example_token",
                          "size": "1024x1024",
                          "output_format": "png",
                          "background": "opaque"
                        }
                      ],
                      "usage": {
                        "input_images": 1,
                        "generated_images": 1,
                        "output_tokens": 4096,
                        "total_tokens": 4096
                      }
                    }
                  },
                  "seedream55_layers": {
                    "summary": "Seedream 5.5 图层拆解返回结构（开启 layer_decomposition: true 时返回）",
                    "value": {
                      "model": "dola-seedream-5-5-261028",
                      "created": 1795667980,
                      "data": [
                        {
                          "url": "https://beeftv.app/v1/images/proxy?t=example_base",
                          "size": "1024x1024",
                          "output_format": "png",
                          "z_index": 0,
                          "background": "opaque"
                        },
                        {
                          "url": "https://beeftv.app/v1/images/proxy?t=example_layer_1",
                          "size": "1024x1024",
                          "output_format": "png",
                          "z_index": 1,
                          "bounding_box": {
                            "absolute": [
                              140,
                              140,
                              882,
                              882
                            ],
                            "normalized": [
                              137,
                              137,
                              861,
                              861
                            ]
                          },
                          "name": "前景主体图层",
                          "description": "居中前景元素",
                          "background": "transparent"
                        }
                      ],
                      "usage": {
                        "input_images": 1,
                        "generated_images": 2,
                        "output_tokens": 8192,
                        "total_tokens": 8192
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "409": {
            "description": "幂等键冲突或原编辑请求仍在处理中。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "category": "input",
                    "code": "idempotency_conflict",
                    "message": "此幂等键已用于不同的图片请求，请用原请求查询结果。",
                    "request_id": "202611260438303668669388268d9d6QYKPi9MG"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/videos": {
      "post": {
        "operationId": "createVideo",
        "tags": [
          "视频兼容接口"
        ],
        "summary": "创建异步视频任务（兼容接口）",
        "description": "异步视频提交兼容入口（新接入推荐优先使用 `POST /v1/media/tasks`）。提交成功返回任务 `id`（初始状态通常为 `queued`），请立即保存该 `id` 并轮询 `GET /v1/videos/{task_id}`。\n\n支持 `magi-2`、`seedance-2.0` / `2.0-fast` / `2.0-mini` / `2.5`、`minimax-h3` 系列、`kling-video-v3`、`wan3.0-video`；不要传 `stream: true`。\n\n> **错误格式提示**：参数与任务提交校验错误返回扁平 JSON `{\"code\": \"...\", \"message\": \"...\", \"data\": null}`（不包在 `error` 对象内）。",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "推荐传入唯一幂等键，防止网络超时重提造成重复建单。",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 255
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoCreateRequest"
              },
              "examples": {
                "seedance": {
                  "summary": "Seedance 2.0 Mini 文生视频",
                  "value": {
                    "model": "seedance-2.0-mini",
                    "prompt": "阳光穿过树叶，镜头缓慢推近",
                    "seconds": "5",
                    "metadata": {
                      "resolution": "720p",
                      "ratio": "16:9",
                      "generate_audio": false
                    }
                  }
                },
                "magi2": {
                  "summary": "MAGI-2 图生视频",
                  "value": {
                    "model": "magi-2",
                    "prompt": "江南雨夜木窗灯火微摇，镜头平稳推进",
                    "operation": "image_to_video",
                    "duration": 5,
                    "resolution": "1080p",
                    "aspect_ratio": "16:9",
                    "generate_audio": true,
                    "content": [
                      {
                        "type": "image_url",
                        "role": "first_frame",
                        "image_url": {
                          "url": "https://example.com/start.png"
                        }
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "视频任务已创建，返回任务对象。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Location": {
                "description": "新建视频任务的查询路径（`/v1/videos/{task_id}`）。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoTask"
                },
                "example": {
                  "id": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz",
                  "task_id": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz",
                  "object": "video",
                  "model": "seedance-2.0-mini",
                  "status": "queued",
                  "progress": 0,
                  "created_at": 1795668059
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/videos/{task_id}": {
      "get": {
        "operationId": "getVideo",
        "tags": [
          "视频兼容接口"
        ],
        "summary": "查询视频任务状态（兼容接口）",
        "description": "轮询视频任务执行进度与最终结果（建议每 5 秒轮询一次）。当 `status` 为 `completed` 时调用 `GET /v1/videos/{task_id}/content` 下载 MP4。",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "description": "创建视频任务或统一媒体任务返回的 `task_id`（`task_...`）。请勿填入 Request ID。",
            "schema": {
              "type": "string"
            },
            "example": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz"
          }
        ],
        "responses": {
          "200": {
            "description": "返回视频任务状态、元数据、扩展提示词与用量。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "description": "任务仍在排队、生成或交付收尾时建议的下次轮询等待秒数。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VideoTask"
                },
                "examples": {
                  "seedance_completed": {
                    "summary": "Seedance 2.0 已完成（含 metadata.usage 视频 Token 用量）",
                    "value": {
                      "id": "task_example_seedance",
                      "task_id": "task_example_seedance",
                      "object": "video",
                      "model": "seedance-2.0-mini",
                      "status": "completed",
                      "progress": 100,
                      "created_at": 1795668059,
                      "completed_at": 1795668158,
                      "video_url": "https://beeftv.app/v1/videos/task_example_seedance/content",
                      "metadata": {
                        "url": "https://beeftv.app/v1/videos/task_example_seedance/content",
                        "delivery_status": "ready",
                        "resolution": "720p",
                        "ratio": "16:9",
                        "duration": 5,
                        "usage": {
                          "completion_tokens": 108900,
                          "total_tokens": 108900
                        }
                      }
                    }
                  },
                  "minimax_h3_completed": {
                    "summary": "MiniMax H3 已完成（含 expanded_prompt）",
                    "value": {
                      "id": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz",
                      "task_id": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz",
                      "object": "video",
                      "model": "minimax-h3-beeftv",
                      "status": "completed",
                      "progress": 100,
                      "created_at": 1795668059,
                      "completed_at": 1795668158,
                      "video_url": "https://beeftv.app/v1/videos/task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz/content",
                      "metadata": {
                        "url": "https://beeftv.app/v1/videos/task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz/content",
                        "delivery_status": "ready",
                        "expanded_prompt": "Wide cinematic shot of calm ocean waves at sunrise..."
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "任务编号不存在或不属于当前站点（扁平 JSON：`{\"code\": \"task_not_exist\", \"message\": \"...\", \"data\": null}`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "code": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "null"
                    }
                  }
                },
                "example": {
                  "code": "task_not_exist",
                  "message": "任务不存在",
                  "data": null
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或来源 IP 不在白名单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "404": {
            "description": "当前 API Key 无权访问该 Seedance 视频任务。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "not_found",
                    "message": "视频任务不存在或不属于当前 API Key。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/videos/{task_id}/content": {
      "get": {
        "operationId": "downloadVideo",
        "tags": [
          "视频兼容接口"
        ],
        "summary": "下载视频成片（兼容接口）",
        "description": "下载已完成视频的 MP4 文件。启用广州 COS 交付时返回 `302` / `307` 重定向至短期签名地址（请使用 `curl --location`，**切勿使用 `--location-trusted`**，避免把 `Authorization` 头转发给对象存储）。\n\n若任务刚完成、云存储转存尚在收尾，接口会返回 `503 video_delivery_pending` 与 `Retry-After` 响应头，等待对应秒数后重试即可。",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "description": "已完成视频任务的 `task_id`。",
            "schema": {
              "type": "string"
            },
            "example": "task_7yBr8tHUC9E9KGNeNW1wSEZgkAqqgmgz"
          }
        ],
        "responses": {
          "200": {
            "description": "直接返回 MP4 二进制流（未启用 302 交付模式时）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "video/mp4": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "302": {
            "description": "重定向至腾讯云广州 COS 短期签名地址（15 分钟有效）下载 `video/mp4`。",
            "headers": {
              "Location": {
                "description": "腾讯云广州 COS 短期签名下载链接。",
                "schema": {
                  "type": "string",
                  "format": "uri"
                }
              },
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或来源 IP 不在白名单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "404": {
            "description": "任务不存在、尚未产出可下载成片或无权访问。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "409": {
            "description": "当传入超分或擦除任务 `task_id` 且成片仍在转存收尾时返回 `409`（`error.code: \"upscale_delivery_pending\"` 或 `\"subtitle_erase_delivery_pending\"`）；普通视频任务转存收尾返回 `503`（`error.type: \"video_delivery_pending\"`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              },
              "Retry-After": {
                "description": "建议等待秒数后重试下载。",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "code": "upscale_delivery_pending",
                    "message": "成片正在转存云存储，请稍后重试下载。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "502": {
            "description": "上游已出片但保存成片失败（`error.type: \"video_delivery_failed\"`），请保留 `task_id` 联系支持，勿重复下单。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "video_delivery_failed",
                    "message": "Video generated but could not be saved; contact support"
                  }
                }
              }
            }
          },
          "503": {
            "description": "成片正在转存至云存储（下载接口在 `error.type` 返回 `video_delivery_pending`，无 `error.code`），请按 `Retry-After` 稍后重试同一 GET 请求。",
            "headers": {
              "Retry-After": {
                "$ref": "#/components/headers/RetryAfter"
              },
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "video_delivery_pending",
                    "message": "Video is being saved; retry later"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/audio/speech": {
      "post": {
        "operationId": "createSpeech",
        "tags": [
          "音频兼容接口"
        ],
        "summary": "语音合成与音乐生成（兼容接口）",
        "description": "同步语音合成（如 `minimax-speech-2.8-turbo`、`minimax-speech-2.8-hd`、`seed-audio-1.0`）与音乐生成（如 `minimax-music-v3.0`、`mureka-music-v8`）。新接入推荐优先使用 `POST /v1/media/tasks`（`media_type: \"audio\"`）。\n\n语音合成直接返回 `audio/mpeg` 音频字节；音乐生成可能返回音频字节或 `302` 重定向，建议统一跟随重定向保存。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AudioSpeechRequest"
              },
              "examples": {
                "tts": {
                  "summary": "语音合成（MiniMax Speech 2.8 Turbo）",
                  "value": {
                    "model": "minimax-speech-2.8-turbo",
                    "input": "你好世界，欢迎使用BeefTV 语音合成。",
                    "voice": "male-qn-qingse",
                    "speed": 1,
                    "metadata": {
                      "emotion": "calm"
                    }
                  }
                },
                "music": {
                  "summary": "音乐生成（歌词放在 metadata.lyrics）",
                  "value": {
                    "model": "minimax-music-v3.0",
                    "input": "轻快民谣吉他，温暖清晨氛围",
                    "metadata": {
                      "lyrics": "[verse]\n清晨微风吹过窗台\n[chorus]\n阳光洒满整条街道",
                      "audio_setting": {
                        "sample_rate": 44100
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回合成后的音频二进制流（默认 `audio/mpeg`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "302": {
            "description": "音乐生成结果就绪后重定向至临时音频下载地址。",
            "headers": {
              "Location": {
                "description": "临时音频下载链接。",
                "schema": {
                  "type": "string",
                  "format": "uri"
                }
              },
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/audio/transcriptions": {
      "post": {
        "operationId": "createTranscription",
        "tags": [
          "音频兼容接口"
        ],
        "summary": "语音识别与字幕转写",
        "description": "通过 `multipart/form-data` 上传音频文件转写为文本或字幕（`hy-asr-3.0-preview` 支持 `.mp3` / `.wav` / `.ogg` / `.oga` / `.opus` / `.pcm`；当前忽略 `language` 参数；`response_format` 为 `text` / `srt` / `vtt` 时返回 `text/plain`）。",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "file"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "精确语音识别模型 ID，如 `hy-asr-3.0-preview`。",
                    "example": "hy-asr-3.0-preview"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "待转写的音频文件（`hy-asr-3.0-preview` 支持 `.mp3` / `.wav` / `.ogg` / `.oga` / `.opus` / `.pcm`）。"
                  },
                  "language": {
                    "type": "string",
                    "description": "兼容保留字段（`hy-asr-3.0-preview` 当前忽略该字段，自动识别语种）。"
                  },
                  "response_format": {
                    "type": "string",
                    "enum": [
                      "json",
                      "text",
                      "srt",
                      "verbose_json",
                      "vtt"
                    ],
                    "default": "json",
                    "description": "返回格式，默认 `json`。"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回识别文本 JSON（或所选字幕格式文本）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AudioTranscriptionResponse"
                },
                "example": {
                  "text": "你好，世界！"
                }
              },
              "text/plain": {
                "schema": {
                  "type": "string",
                  "description": "当 `response_format` 为 `text`、`srt` 或 `vtt` 时返回的纯文本或字幕内容。"
                }
              }
            }
          },
          "400": {
            "description": "请求参数不合法、所选型号不支持该参数或操作，或素材校验未通过。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "请求参数不合法，请检查必填字段与模型能力范围。"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌 (request id: 202611260438035879074858268d9d6YwUKKwoU)"
                  }
                }
              }
            }
          },
          "402": {
            "description": "API Key 额度已用尽，或异步媒体预扣时账户人民币余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "insufficient_user_quota",
                    "message": "当前额度不足，请前往账户中心充值或调整 API Key 额度上限。"
                  }
                }
              }
            }
          },
          "403": {
            "description": "API Key 无权访问当前站点、分组或所选模型，来源 IP 不在白名单，或同步接口扣费时账户余额不足（`insufficient_user_quota`）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "key_site_mismatch",
                    "message": "当前 API Key 不属于当前站点或无权调用该模型。"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发频率或并发限制，请降低并发并按 Retry-After（如有）等待后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "rate_limit_exceeded",
                    "message": "请求过于频繁，请稍后重试。"
                  }
                }
              }
            }
          },
          "503": {
            "description": "服务或上游通道暂时不可用。查询类接口可有限退避重试；生成类接口请先核对原 task_ref 或请求记录，避免重复提交。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "server_error",
                    "code": "service_unavailable",
                    "message": "上游服务暂时不可用，请稍后重试。"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tools/search": {
      "post": {
        "operationId": "webSearch",
        "tags": [
          "联网工具"
        ],
        "summary": "联网搜索",
        "description": "使用 BeefTV API Key 发起托管实时网页搜索，按次人民币计费（计费模型 ID：`beeftv-web-search`，默认 `¥0.20 / 次`）。\n\n- 请求体 JSON 上限为 `64 KiB`。\n- 当参数校验失败、余额不足、上游限流/故障，或搜索返回空结果（`results: []`）时，**不扣费**（已预扣额度自动全额退回）。\n- 若 API Key 开启了模型白名单，须勾选 `beeftv-web-search`。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebToolSearchRequest"
              },
              "example": {
                "query": "2026 AI 视频生成工作流最佳实践",
                "count": 5,
                "need_content": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "返回按相关性排序的网页结果列表；未检索到结果时返回空数组且不扣费。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebToolSearchResponse"
                },
                "example": {
                  "results": [
                    {
                      "title": "2026 AI 视频创作与分镜工作流实践指南",
                      "url": "https://example.com/guides/video-workflow",
                      "snippet": "从剧本拆镜、首尾帧参考图到音画对齐的完整制作流程...",
                      "summary": "本文介绍如何结合多模态参考图、关键帧控制与后期画质增强完成短片制作。",
                      "content": "",
                      "date": "2026-11-20",
                      "site": "example.com",
                      "rerank_score": 0.92,
                      "score": 0.92
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "请求体为空、非法 JSON、体积超过 64 KiB、缺少 query 或 mode 不在 0–2 范围内（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_request",
                    "message": "query is required"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌"
                  }
                }
              }
            }
          },
          "402": {
            "description": "账户人民币余额或当前 API Key 可用额度不足（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "billing_error",
                    "code": "insufficient_user_quota",
                    "message": "账户余额不足，请先充值后再使用"
                  }
                }
              }
            }
          },
          "403": {
            "description": "当前 API Key 跨站使用（`key_site_mismatch`）或模型白名单未开放 `beeftv-web-search`（`model_not_allowed`），不扣费。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "permission_error",
                    "code": "model_not_allowed",
                    "message": "当前 API Key 未开放联网搜索权限"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发上游频率限制；预扣费用已自动退回，请降低并发后退避重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "web_search_rate_limited",
                    "message": "联网搜索请求过于频繁，未扣除费用，请稍后重试"
                  }
                }
              }
            }
          },
          "502": {
            "description": "上游搜索暂时不可用；预扣费用已自动退回，请稍后重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "upstream_error",
                    "code": "web_search_upstream_failed",
                    "message": "联网搜索上游暂时不可用，未扣除费用，请稍后重试"
                  }
                }
              }
            }
          },
          "503": {
            "description": "联网搜索服务暂未启用或维护中（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "service_unavailable",
                    "code": "web_search_not_configured",
                    "message": "联网搜索服务尚未配置，请稍后再试"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/tools/fetch": {
      "post": {
        "operationId": "webFetch",
        "tags": [
          "联网工具"
        ],
        "summary": "网页正文读取",
        "description": "传入公网可访问的 `http://` 或 `https://` 网页地址，由云端抓取并清洗提取为纯文本 / Markdown 正文（单次上限 `1 MiB` UTF-8），按次人民币计费（计费模型 ID：`beeftv-web-fetch`，默认 `¥0.05 / 次`）。\n\n- 请求体 JSON 上限为 `64 KiB`。\n- 拒绝非 `http`/`https` 协议、含用户名密码的 URL、`localhost` / `.localhost` / `.local` / `.internal` 及私网/回环/保留 IP 地址（返回 `400 invalid_fetch_url`，不扣费）。\n- 抓取失败、返回空内容或触发限流时自动全额退费。\n- 若 API Key 开启了模型白名单，须勾选 `beeftv-web-fetch`。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebToolFetchRequest"
              },
              "example": {
                "url": "https://example.com/guides/video-workflow"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "成功返回网页标题与清洗后的正文内容。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/WebToolFetchResponse"
                },
                "example": {
                  "url": "https://example.com/guides/video-workflow",
                  "title": "2026 AI 视频创作与分镜工作流实践指南",
                  "content": "# 2026 AI 视频创作与分镜工作流实践指南\n\n从剧本拆镜、首尾帧参考图到音画对齐的完整制作流程..."
                }
              }
            }
          },
          "400": {
            "description": "请求体不合法，或目标 URL 格式无效、指向内网/回环/保留地址（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "invalid_request_error",
                    "code": "invalid_fetch_url",
                    "message": "目标链接无效或不允许访问内网地址"
                  }
                }
              }
            }
          },
          "401": {
            "description": "缺少 API Key、密钥无效、已停用或已过期（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "new_api_error",
                    "code": "",
                    "message": "无效的令牌"
                  }
                }
              }
            }
          },
          "402": {
            "description": "账户人民币余额或当前 API Key 可用额度不足（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "billing_error",
                    "code": "insufficient_user_quota",
                    "message": "账户余额不足，请先充值后再使用"
                  }
                }
              }
            }
          },
          "403": {
            "description": "当前 API Key 跨站使用（`key_site_mismatch`）或模型白名单未开放 `beeftv-web-fetch`（`model_not_allowed`），不扣费。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "permission_error",
                    "code": "model_not_allowed",
                    "message": "当前 API Key 未开放网页读取权限"
                  }
                }
              }
            }
          },
          "429": {
            "description": "触发上游频率限制；预扣费用已自动退回，请降低并发后退避重试。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "rate_limit_error",
                    "code": "web_fetch_rate_limited",
                    "message": "网页读取请求过于频繁，未扣除费用，请稍后重试"
                  }
                }
              }
            }
          },
          "502": {
            "description": "目标网页读取失败或未提取到正文；预扣费用已自动退回。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "upstream_error",
                    "code": "web_fetch_upstream_failed",
                    "message": "网页读取失败，未扣除费用，请稍后重试"
                  }
                }
              }
            }
          },
          "503": {
            "description": "网页读取服务暂未启用或维护中（不扣费）。",
            "headers": {
              "X-Oneapi-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": {
                    "type": "service_unavailable",
                    "code": "web_fetch_not_configured",
                    "message": "网页读取服务尚未配置，请稍后再试"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BeefTVAPIKeyBearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "在请求头中携带 `Authorization: Bearer $BEEFTV_API_KEY`。"
      }
    },
    "headers": {
      "RequestId": {
        "description": "服务端生成的唯一 HTTP 请求 ID。用于 `GET /v1/usage/requests?request_id=...` 精确查询本笔人民币实扣金额及工单排查。",
        "schema": {
          "type": "string"
        },
        "example": "202611260438099607140728268d9d6BUOCtxHt"
      },
      "ImageRequestId": {
        "description": "带 `Idempotency-Key` 提交或重放图片请求时返回的**原始计费请求 ID**。重放命中时请用此 ID（而非新请求的 `X-Oneapi-Request-Id`）查询账单。",
        "schema": {
          "type": "string"
        },
        "example": "202611260438099607140728268d9d6BUOCtxHt"
      },
      "IdempotencyReplayed": {
        "description": "值为 `true` 时表示本次响应直接读取了之前已保存的幂等回执，未再次触发生成或扣费。",
        "schema": {
          "type": "string",
          "enum": [
            "true"
          ]
        }
      },
      "ImageDelivery": {
        "description": "当请求携带 `X-Beeftv-Image-Delivery` 头时返回本次实际生效的图片交付方式：`direct` 表示直接返回上游官方临时链接（当前仅 Seedream 型号支持，有效期约 24 小时），`managed` 表示走默认广州 COS 转存交付。",
        "schema": {
          "type": "string",
          "enum": [
            "managed",
            "direct"
          ]
        }
      },
      "TaskLocation": {
        "description": "该统一媒体任务对应的轮询路径（如 `/v1/media/tasks/mtask_...?media_type=image`）。",
        "schema": {
          "type": "string"
        }
      },
      "RetryAfter": {
        "description": "建议客户端在多少秒后重试同一查询或下载请求。",
        "schema": {
          "type": "integer"
        }
      },
      "CatalogETag": {
        "description": "模型目录与报价快照版本标签，可用于 `If-None-Match` 条件请求。",
        "schema": {
          "type": "string"
        }
      }
    },
    "schemas": {
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "message"
            ],
            "properties": {
              "type": {
                "type": "string",
                "description": "错误大类或专用状态标识（如 `invalid_request_error`、`new_api_error`、`rate_limit_error`、`server_error`；视频 `/content` 下载接口在 `type` 中返回 `video_delivery_pending` / `video_delivery_failed`）。"
              },
              "code": {
                "type": "string",
                "description": "机器可读业务错误码（如 `idempotency_conflict`、`media_task_not_found`、`invalid_video_parameters`）。"
              },
              "category": {
                "type": "string",
                "enum": [
                  "input",
                  "authorization",
                  "rate_limit",
                  "quota_user",
                  "upstream",
                  "delivery",
                  "availability",
                  "unknown"
                ],
                "description": "统一媒体/幂等错误分类。"
              },
              "message": {
                "type": "string",
                "description": "面向开发者或用户的具体错误原因（含上游校验原因及参考素材序号定位）。"
              },
              "param": {
                "type": "string",
                "description": "触发校验失败的参数名（如有）。"
              },
              "request_id": {
                "type": "string",
                "description": "本次或原始请求的 Request ID，便于对账与排查。"
              }
            }
          }
        }
      },
      "MediaReference": {
        "type": "object",
        "required": [
          "kind",
          "role",
          "url"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "audio",
              "subtitle"
            ],
            "description": "素材类型（视频多语种翻译可附带 `subtitle` 字幕文件）。"
          },
          "role": {
            "type": "string",
            "description": "素材角色，如 `reference`、`mask`、`source`、`subtitle`、`first_frame`、`last_frame`、`middle_frame`、`reference_image`、`reference_video`、`reference_audio`。"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "公网可访问 HTTPS 链接，或经 `POST /v1/media/uploads/complete` 换取的广州 COS 临时链接。（注意：`POST /v1/media/tasks` 不接受直接回传站内 `/v1/images/proxy?t=...` 代理短链；Topaz 超分须先经 `/v1/media/uploads` 上传至广州 COS。）"
          }
        }
      },
      "MediaTaskWebhook": {
        "type": "object",
        "required": [
          "url",
          "secret"
        ],
        "description": "可选终态异步回调配置（支持 `image`、`video`、`upscale`、`audio` 全部 4 类媒体任务）。",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "maxLength": 2048,
            "description": "公网可访问的 HTTPS 回调地址（仅允许 443 端口、禁止私网/回环/元数据地址、禁止 3xx 重定向）。"
          },
          "secret": {
            "type": "string",
            "minLength": 16,
            "maxLength": 256,
            "description": "16–256 位可见 ASCII 密钥，用于计算 `X-Webhook-Signature: v1=<hex(HMAC-SHA256(secret, timestamp + \".\" + raw_body))>`。任务进入终态完成投递后服务端自动清除。"
          }
        }
      },
      "MediaTaskWebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "event",
          "created_at",
          "task_ref",
          "media_type",
          "data"
        ],
        "description": "任务进入终态后服务端向 `webhook.url` POST 的 JSON 回调体。",
        "properties": {
          "id": {
            "type": "string",
            "description": "唯一回调事件 ID（`evt_...`），同一任务重发回调时保持不变，与 `X-Webhook-Id` 一致，供接收端幂等去重。"
          },
          "event": {
            "type": "string",
            "enum": [
              "media.task.completed",
              "media.task.failed",
              "media.task.unknown"
            ],
            "description": "终态事件类型。"
          },
          "created_at": {
            "type": "integer",
            "description": "本次投递生成的 Unix 秒时间戳，与 `X-Webhook-Timestamp` 一致。"
          },
          "task_ref": {
            "type": "string",
            "description": "原任务引用编号。"
          },
          "media_type": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "upscale",
              "audio"
            ],
            "description": "任务媒体大类。"
          },
          "data": {
            "$ref": "#/components/schemas/MediaTaskProjection",
            "description": "与 `GET /v1/media/tasks/{task_ref}` 完全同构的终态任务投影（重试时会重新签发有效下载链接）。"
          }
        }
      },
      "MediaTaskInput": {
        "type": "object",
        "properties": {
          "prompt": {
            "type": "string",
            "description": "文本提示词或待合成台词；图层拆解、超分、去字幕、去水印等纯处理任务可省略。"
          },
          "references": {
            "type": "array",
            "description": "参考素材数组；不同型号的数量、分辨率与时长上限见 `GET /v1/models`。",
            "items": {
              "$ref": "#/components/schemas/MediaReference"
            }
          }
        }
      },
      "MediaTaskRequest": {
        "type": "object",
        "required": [
          "media_type",
          "model",
          "operation",
          "input"
        ],
        "properties": {
          "task_ref": {
            "type": "string",
            "minLength": 1,
            "maxLength": 255,
            "description": "可选客户端幂等任务编号（1–255 个可见非空白 ASCII 字符（0x21–0x7E，不含空格））。生产环境建议提交前生成 UUID 并落库保存；省略时回退到 `Idempotency-Key` 头或由服务端自动生成 `mtask_...`。"
          },
          "media_type": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "upscale",
              "audio"
            ],
            "description": "媒体任务大类。"
          },
          "model": {
            "type": "string",
            "description": "从 `GET /v1/models` 读取的精确模型 ID（如 `dola-seedream-5-5-261028`、`magi-2`、`minimax-speech-2.8-turbo`）。"
          },
          "operation": {
            "type": "string",
            "enum": [
              "generate",
              "edit",
              "text_to_video",
              "image_to_video",
              "reference_to_video",
              "audio_to_video",
              "extend",
              "inpaint",
              "replace_element",
              "style_transfer",
              "draft_to_final",
              "upscale",
              "subtitle_erase",
              "watermark_erase",
              "privacy_protect",
              "smart_erase",
              "synthesize",
              "stem_separation",
              "video_dubbing",
              "video_translation"
            ],
            "description": "具体操作类型，须属于所选模型支持的操作集。"
          },
          "input": {
            "$ref": "#/components/schemas/MediaTaskInput"
          },
          "options": {
            "type": "object",
            "additionalProperties": true,
            "description": "型号业务参数（如生图的 `size`/`delivery`（可选 `managed` 或 `direct`，仅 Seedream 系列触发官链直出）/`output_format`/`background`/`layer_decomposition`，视频的 `seconds`/`resolution`/`aspect_ratio`/`generate_audio`/`seed`，超分的 `upscale_factor`，音频的 `voice`/`speed`/`lyrics`）。完整清单见模型参数对照表与 `GET /v1/models`。"
          },
          "async": {
            "type": "boolean",
            "default": false,
            "description": "可选异步返回开关（默认 `false`）。设为 `true` 时，生图任务在受理后立即返回 HTTP `202`（`status: \"in_progress\"`）并在后台执行，不占用长连接；省略或为 `false` 且未传 `webhook` 时，原生异步生图立即返回 `in_progress`，同步生图最多短等待约 15 秒后自动转为 `in_progress` 后台完成。`video`/`upscale`/`audio` 始终为异步受理。"
          },
          "webhook": {
            "$ref": "#/components/schemas/MediaTaskWebhook"
          }
        }
      },
      "MediaTaskOutput": {
        "type": "object",
        "required": [
          "kind",
          "url"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "audio"
            ],
            "description": "产物媒体类型。"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "默认为腾讯云广州 COS 短期签名地址或 `/v1/images/proxy?t=...` 跳转短链；当生图任务显式启用 `delivery: \"direct\"` 且命中支持型号（Seedream 系列）时，直接返回上游官方临时 HTTPS 链接（有效期约 24 小时，同时顶层附带 `metadata.delivery: \"direct\"`）。请尽快下载并转存至自有存储。"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "单条产物的上游元数据。生图时包含 **`size`**（如 `\"1024x1024\"`、`\"2496x1664\"`）、`output_format`、`background`、`revised_prompt`；Seedream 图层拆解时还包含 `z_index`、`bounding_box`、`name`、`description`、`text_recognition`。"
          }
        }
      },
      "MediaTaskError": {
        "type": "object",
        "required": [
          "code",
          "category",
          "message"
        ],
        "properties": {
          "code": {
            "type": "string",
            "description": "机器可读任务错误码（如 `media_generation_failed`、`media_delivery_pending`、`media_result_unknown`、`media_task_not_found`）。"
          },
          "category": {
            "type": "string",
            "enum": [
              "input",
              "authorization",
              "rate_limit",
              "quota_user",
              "upstream",
              "delivery",
              "availability",
              "unknown"
            ],
            "description": "错误分类，决定应修改参数、限流退避、补充余额、稍后轮询还是人工核查。"
          },
          "message": {
            "type": "string",
            "description": "面向开发者的错误说明。"
          },
          "reason": {
            "type": "string",
            "description": "原始拒绝或失败细分类原因码（如有）。"
          },
          "user_message": {
            "type": "string",
            "description": "已洗敏、可直接展示给终端用户的具体中文原因（如指出第几张参考图不合格）。"
          },
          "request_id": {
            "type": "string",
            "description": "原始提交请求的 Request ID。"
          }
        }
      },
      "MediaResultReceipt": {
        "type": "object",
        "required": [
          "format",
          "url",
          "expires_at"
        ],
        "properties": {
          "format": {
            "type": "string",
            "description": "大体积历史回执格式（如 `openai-image-response`）。"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "短期签名回执下载地址。"
          },
          "expires_at": {
            "type": "integer",
            "description": "链接过期 Unix 秒。"
          }
        }
      },
      "MediaTaskProjection": {
        "type": "object",
        "required": [
          "task_ref",
          "media_type",
          "status",
          "outputs"
        ],
        "properties": {
          "task_ref": {
            "type": "string",
            "description": "幂等任务引用编号，后续轮询 `GET /v1/media/tasks/{task_ref}` 使用此值。"
          },
          "media_type": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "upscale",
              "audio"
            ],
            "description": "任务媒体大类。"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "in_progress",
              "completed",
              "failed",
              "unknown"
            ],
            "description": "任务生命周期状态。只有 `completed` 时成片可下载；`unknown` 时不可自动重提。"
          },
          "reconcile_deadline": {
            "type": "integer",
            "description": "可选，异步任务对账截止 Unix 秒。"
          },
          "task_id": {
            "type": "string",
            "description": "平台内部持久化任务 ID（`task_...`），也可用于兼容查询路由。"
          },
          "outputs": {
            "type": "array",
            "description": "已完成时返回的产物列表；未完成或失败时为空数组。",
            "items": {
              "$ref": "#/components/schemas/MediaTaskOutput"
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "任务级扩展元数据（如生图的 `created`/`model`，命中生图官链直出时返回 `delivery: \"direct\"`，视频去字幕返回 `subtitles`）。"
          },
          "usage": {
            "type": "object",
            "additionalProperties": true,
            "description": "已完成并结算任务的用量对象（仅在成片交付完成后返回）：生图包含 `input_images`/`generated_images`/`output_tokens`/`total_tokens`；按 Token 计费视频（如 Seedance、WAND Vega Pro）包含 `billing_mode: \"video_tokens\"`、`total_tokens`、`resolution`、`output_seconds`（未计入参考视频输入秒数时同时返回 `completion_tokens`，含参考视频时返回 `input_video_seconds`）；按秒计费视频/增强（如 MAGI-2、万相 3.0、MPS）包含 `billing_mode: \"video_seconds\"`、`total_seconds`、`output_seconds`、`resolution`（及可选 `input_video_seconds`）；托管音频包含 `billing_mode: \"audio_tokens\"` 与 `total_tokens`。失败、退款、未结算或仍在交付中的任务省略此字段。"
          },
          "billing_state": {
            "type": "string",
            "enum": [
              "reserved",
              "settled",
              "refunded"
            ],
            "description": "任务计费状态；`settled` 表示已最终结算，`refunded` 表示预扣已退回。"
          },
          "quota": {
            "type": "integer",
            "description": "平台内部额度整数（`500,000 = ¥1.00`），表示当前净消耗额度。**不是人民币金额**，外部计费请以 `GET /v1/usage/requests` 的人民币 `amount` 为准。"
          },
          "reserved_quota": {
            "type": "integer",
            "description": "提交时冻结的平台内部额度整数（`500,000 = ¥1.00`）。"
          },
          "charged_quota": {
            "type": "integer",
            "description": "最终结算的平台内部额度整数（`500,000 = ¥1.00`）。"
          },
          "adjustment_quota": {
            "type": "integer",
            "description": "多退少补调整的平台内部额度整数（负数表示退回多余预扣）。"
          },
          "usage_state": {
            "type": "string",
            "enum": [
              "pending",
              "completed",
              "failed"
            ],
            "description": "任务账单投影状态。"
          },
          "result_receipt": {
            "$ref": "#/components/schemas/MediaResultReceipt"
          },
          "error": {
            "$ref": "#/components/schemas/MediaTaskError"
          }
        }
      },
      "MediaUploadRequest": {
        "type": "object",
        "required": [
          "kind",
          "bytes",
          "sha256",
          "mime"
        ],
        "properties": {
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "audio"
            ],
            "description": "上传文件大类。"
          },
          "purpose": {
            "type": "string",
            "enum": [
              "media_tool"
            ],
            "description": "可选业务用途标识：仅在 `kind: \"video\"` 用于视频超分/擦除大文件时传入 `\"media_tool\"`（单文件上限放宽至 1 GiB）；省略时按普通参考素材上限校验（参考视频 200 MiB）。"
          },
          "bytes": {
            "type": "integer",
            "minimum": 1,
            "description": "文件精确字节数，须与后续 PUT 请求体一致。"
          },
          "sha256": {
            "type": "string",
            "minLength": 64,
            "maxLength": 64,
            "description": "文件原始字节的 64 位小写十六进制 SHA-256 摘要。"
          },
          "mime": {
            "type": "string",
            "description": "文件 MIME 类型（图片：`image/png`、`image/jpeg`、`image/webp`、`image/gif`、`image/bmp`、`image/tiff`；视频：`video/mp4`、`video/quicktime`；音频：`audio/mpeg`、`audio/wav`）。"
          },
          "resumable": {
            "type": "boolean",
            "default": false,
            "description": "大文件是否启用分片续传计划。"
          }
        }
      },
      "MediaUploadSession": {
        "type": "object",
        "required": [
          "upload_url",
          "upload_method",
          "required_headers",
          "ticket",
          "upload_expires_at",
          "expires_at"
        ],
        "properties": {
          "upload_url": {
            "type": "string",
            "description": "单次整文件直传时为腾讯云广州 COS 预签名上传地址（30 分钟有效）；当 `resumable: true` 且触发大文件分片计划时为空字符串（改用 `multipart` 中的分片地址）。"
          },
          "upload_method": {
            "type": "string",
            "enum": [
              "PUT",
              ""
            ],
            "description": "整文件上传时固定为 `PUT`；分片上传模式时为空字符串。"
          },
          "required_headers": {
            "type": [
              "object",
              "null"
            ],
            "additionalProperties": {
              "type": "string"
            },
            "description": "执行整文件 PUT 时必须原样附带的请求头（如 `Content-Length`、`Content-Type`；切勿附带 API Key `Authorization` 头）；分片模式时可为 `null`。"
          },
          "ticket": {
            "type": "string",
            "description": "上传会话签名票据，PUT 完成后原样提交给 `POST /v1/media/uploads/complete`。"
          },
          "upload_expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "预签名上传截止时间（ISO 8601 UTC）。"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "票据有效期截止时间（ISO 8601 UTC）。"
          },
          "multipart": {
            "type": "object",
            "additionalProperties": true,
            "description": "启用 `resumable: true` 且文件需要分片上传时返回的分片计划。"
          }
        }
      },
      "MediaUploadCompleteRequest": {
        "type": "object",
        "required": [
          "ticket"
        ],
        "properties": {
          "ticket": {
            "type": "string",
            "description": "`POST /v1/media/uploads` 返回的 `ticket`。"
          }
        }
      },
      "MediaUploadCompleteResult": {
        "type": "object",
        "required": [
          "url",
          "kind",
          "mime",
          "bytes",
          "sha256",
          "expires_at"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "73 小时有效期的广州 COS 签名读取链接，可直接作为媒体接口的参考素材地址。"
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "audio"
            ],
            "description": "经服务端校验确认后的素材类型。"
          },
          "mime": {
            "type": "string",
            "description": "确认后的 MIME 类型。"
          },
          "bytes": {
            "type": "integer",
            "description": "文件字节数。"
          },
          "sha256": {
            "type": "string",
            "description": "校验通过的 SHA-256。"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time",
            "description": "读取链接过期时间（ISO 8601 UTC，约 73 小时）。"
          }
        }
      },
      "ModelListResponse": {
        "type": "object",
        "required": [
          "object",
          "data"
        ],
        "properties": {
          "object": {
            "type": "string",
            "enum": [
              "list"
            ]
          },
          "media_protocol": {
            "type": "object",
            "description": "统一媒体协议发现元数据。",
            "properties": {
              "version": {
                "type": "string",
                "example": "managed-media-v1"
              },
              "supported_media_types": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "task_submit_url": {
                "type": "string"
              },
              "task_query_url_template": {
                "type": "string"
              },
              "uploads_url": {
                "type": "string"
              },
              "async_supported": {
                "type": "boolean",
                "description": "统一媒体入口（`/v1/media/tasks`）是否支持 `async: true` 显式异步与轮询（全部生图与多模态型号均支持）。"
              },
              "sync_compat_endpoints": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "仅支持同步调用的兼容生图端点列表（不支持传 `async: true` 或异步轮询，异步请改用 `task_submit_url`）。"
              }
            }
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "object"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "精确模型 ID，调用时原样传入 `model`。"
                },
                "display_name": {
                  "type": "string",
                  "description": "可选友好展示名称（与控制台「模型与价格」页面一致，如 Seedream 5.0 Lite；仅作展示，调用时仍须传 id）。"
                },
                "object": {
                  "type": "string",
                  "enum": [
                    "model"
                  ]
                },
                "created": {
                  "type": "integer"
                },
                "owned_by": {
                  "type": "string"
                },
                "supported_endpoint_types": {
                  "type": "array",
                  "items": {
                    "type": "string"
                  },
                  "description": "该模型支持的协议类型（如 `openai`、`anthropic`、`image-generation`、`openai-video`、`audio.speech`）。"
                },
                "image_capabilities": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "图片型号的尺寸与分辨率档位（`size.tiers` 如 `[\"1K\",\"2K\",\"4K\"]`、`size.minPixels`/`size.maxPixels` 自定义像素上下限、预设与默认值）、参考图上限、透明底、输出格式、是否支持直出官链（`directDelivery.supported`），以及按模型动态声明的可传高级参数表（`controls`，含 `type`/`enum`/`min`/`max`/`default`/`visible_when`）。"
                },
                "video_capabilities": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "视频型号的操作类型、分辨率、画幅、时长与素材约束。"
                },
                "media_capabilities": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "音频、超分与擦除型号支持的操作与控制参数。"
                },
                "video_pricing": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "视频型号的精简人民币费率摘要。"
                },
                "pricing": {
                  "type": "object",
                  "additionalProperties": true,
                  "description": "实时人民币单价行（图片含 `image_price_table` 与 `low_tier_max_pixels`）。"
                }
              }
            }
          }
        }
      },
      "PricingEstimateTarget": {
        "type": "object",
        "required": [
          "model",
          "kind"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "精确模型 ID。"
          },
          "kind": {
            "type": "string",
            "enum": [
              "image",
              "video",
              "audio"
            ],
            "description": "试算媒体类别。"
          },
          "size": {
            "type": "string",
            "description": "图片尺寸档位（如 `1K`/`1.5K`/`2K`）或精确像素（如 `2000x1300`）。"
          },
          "quality": {
            "type": "string",
            "description": "图片画质档位（`gpt-image-*` 系列：`low`/`medium`/`high`/`xhigh`/`max`/`auto`）。"
          },
          "layers": {
            "type": "boolean",
            "default": false,
            "description": "是否为 Seedream 图层拆解请求。"
          },
          "count": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000,
            "description": "生成张数，默认按 1 计。"
          },
          "referenceImages": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000,
            "description": "输入参考图张数（按各型号免费张数规则自动扣减）。"
          },
          "referenceVideos": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000,
            "description": "输入参考视频条数。"
          },
          "resolution": {
            "type": "string",
            "description": "视频分辨率（如 `480p`/`720p`/`768p`/`1080p`/`2k`/`4k`）。"
          },
          "seconds": {
            "type": "number",
            "minimum": 0,
            "maximum": 86400,
            "description": "视频生成秒数。"
          },
          "characters": {
            "type": "integer",
            "minimum": 0,
            "maximum": 10000000,
            "description": "语音合成字符数。"
          }
        }
      },
      "PricingEstimateRequest": {
        "type": "object",
        "required": [
          "targets"
        ],
        "properties": {
          "targets": {
            "type": "array",
            "minItems": 1,
            "maxItems": 2000,
            "description": "待试算的目标列表（1–2000 项）。",
            "items": {
              "$ref": "#/components/schemas/PricingEstimateTarget"
            }
          }
        }
      },
      "PricingEstimateItem": {
        "type": "object",
        "required": [
          "amount",
          "basis",
          "text"
        ],
        "properties": {
          "amount": {
            "type": [
              "number",
              "null"
            ],
            "description": "预估人民币金额（元）；未知或变动计费项为 `null`，不按 0 计。"
          },
          "approx": {
            "type": "boolean",
            "description": "为 `true` 时表示按 Token 或字符折算的近似估价。"
          },
          "label": {
            "type": "string",
            "description": "可直接用于 UI 展示的紧凑金额标签（如 `预计 ¥0.0136`、`每层 ¥0.0237`）。"
          },
          "variable": {
            "type": "boolean",
            "description": "为 `true` 时表示最终费用取决于实际产出量（如图层数或上游账单）。"
          },
          "basis": {
            "type": "string",
            "description": "清晰可读的算价公式依据。"
          },
          "text": {
            "type": "string",
            "description": "完整中文预估说明。"
          },
          "reserve": {
            "type": [
              "number",
              "null"
            ],
            "description": "按账单后结型号在提交时需先冻结的人民币上限（不计入 `summary.amount`）。"
          }
        }
      },
      "PricingEstimateSummary": {
        "type": "object",
        "required": [
          "amount",
          "priced",
          "unknown",
          "text"
        ],
        "properties": {
          "amount": {
            "type": "number",
            "description": "所有已定价项的人民币合计金额。"
          },
          "priced": {
            "type": "integer",
            "description": "已成功定价的条目数。"
          },
          "unknown": {
            "type": "integer",
            "description": "无法提前确定总价的条目数。"
          },
          "approx": {
            "type": "boolean",
            "description": "合计中是否包含近似折算项。"
          },
          "text": {
            "type": "string",
            "description": "中文合计文案。"
          }
        }
      },
      "PricingEstimateResponse": {
        "type": "object",
        "required": [
          "items",
          "summary"
        ],
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PricingEstimateItem"
            }
          },
          "summary": {
            "$ref": "#/components/schemas/PricingEstimateSummary"
          }
        }
      },
      "KeyBalanceWallet": {
        "type": "object",
        "required": [
          "available_amount",
          "used_amount",
          "available_quota",
          "used_quota",
          "request_count"
        ],
        "description": "当前账户在当前站点的钱包余额快照。",
        "properties": {
          "available_amount": {
            "type": "string",
            "description": "钱包当前可用人民币余额（6 位小数字符串）。"
          },
          "used_amount": {
            "type": "string",
            "description": "钱包累计已消耗人民币金额（6 位小数字符串）。"
          },
          "available_quota": {
            "type": "integer",
            "description": "钱包当前可用内部额度整数（`500,000 = ¥1.00`）。"
          },
          "used_quota": {
            "type": "integer",
            "description": "钱包累计已消耗内部额度整数。"
          },
          "request_count": {
            "type": "integer",
            "description": "钱包累计计费请求次数。"
          }
        }
      },
      "KeyBalanceToken": {
        "type": "object",
        "required": [
          "id",
          "name",
          "status",
          "unlimited_quota",
          "remaining_amount",
          "used_amount",
          "remaining_quota",
          "used_quota",
          "expires_at"
        ],
        "description": "当前认证 API Key 的额度与状态（永不返回密钥明文）。",
        "properties": {
          "id": {
            "type": "integer",
            "description": "API Key 数字 ID。"
          },
          "name": {
            "type": "string",
            "description": "API Key 名称。"
          },
          "status": {
            "type": "string",
            "enum": [
              "enabled",
              "expired",
              "exhausted",
              "disabled"
            ],
            "description": "Key 当前生效状态。"
          },
          "unlimited_quota": {
            "type": "boolean",
            "description": "是否不限 Key 自身额度（`true` 时直接受账户钱包余额约束，`remaining_amount` / `remaining_quota` 为 `null`）。"
          },
          "remaining_amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "Key 剩余可用人民币额度（6 位小数字符串；不限额 Key 为 `null`）。"
          },
          "used_amount": {
            "type": "string",
            "description": "该 Key 累计已消耗人民币金额（6 位小数字符串）。"
          },
          "remaining_quota": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Key 剩余内部额度整数；不限额 Key 为 `null`。"
          },
          "used_quota": {
            "type": "integer",
            "description": "该 Key 累计已消耗内部额度整数。"
          },
          "expires_at": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Key 过期时间 Unix 秒；永不过期时为 `null`。"
          }
        }
      },
      "KeyBalanceSummary": {
        "type": "object",
        "required": [
          "currency",
          "market",
          "wallet",
          "key"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "CNY"
            ],
            "description": "货币单位，当前站点固定为 `CNY`。"
          },
          "market": {
            "type": "string",
            "description": "当前站点标识。"
          },
          "wallet": {
            "$ref": "#/components/schemas/KeyBalanceWallet"
          },
          "key": {
            "$ref": "#/components/schemas/KeyBalanceToken"
          }
        }
      },
      "KeyUsageTotals": {
        "type": "object",
        "required": [
          "settled_amount",
          "pending_amount",
          "refunded_amount",
          "records",
          "unknown_records"
        ],
        "properties": {
          "settled_amount": {
            "type": "string",
            "description": "已结算人民币净额（6 位小数字符串，已含退回调整）。"
          },
          "pending_amount": {
            "type": "string",
            "description": "待结算预留人民币总额（6 位小数字符串）。"
          },
          "refunded_amount": {
            "type": "string",
            "description": "已记录退回人民币总额（仅供参考，勿从 `settled_amount` 再次相减）。"
          },
          "records": {
            "type": "integer",
            "description": "纳入统计的账务记录条数。"
          },
          "unknown_records": {
            "type": "integer",
            "description": "账务状态尚为 `unknown` 的记录条数。"
          }
        }
      },
      "KeyUsageBucket": {
        "allOf": [
          {
            "$ref": "#/components/schemas/KeyUsageTotals"
          },
          {
            "type": "object",
            "properties": {
              "model": {
                "type": "string",
                "description": "按模型分桶时的模型 ID。"
              },
              "date": {
                "type": "string",
                "description": "按日分桶时的 UTC 日期（`YYYY-MM-DD`）。"
              }
            }
          }
        ]
      },
      "KeyUsageSummary": {
        "allOf": [
          {
            "$ref": "#/components/schemas/KeyUsageTotals"
          },
          {
            "type": "object",
            "required": [
              "currency",
              "start_time",
              "end_time",
              "by_model",
              "daily"
            ],
            "properties": {
              "currency": {
                "type": "string",
                "enum": [
                  "CNY"
                ],
                "description": "货币单位，BeefTV 云端固定为 `CNY`。"
              },
              "start_time": {
                "type": "integer",
                "description": "查询窗口起始 Unix 秒。"
              },
              "end_time": {
                "type": "integer",
                "description": "查询窗口结束 Unix 秒。"
              },
              "by_model": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/KeyUsageBucket"
                }
              },
              "daily": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/KeyUsageBucket"
                }
              }
            }
          }
        ]
      },
      "KeyUsageRecord": {
        "type": "object",
        "required": [
          "id",
          "request_id",
          "created_at",
          "model",
          "result",
          "billing_status",
          "amount",
          "reserved_amount",
          "refunded_amount",
          "input_tokens",
          "output_tokens",
          "cache_read_tokens",
          "cache_write_tokens",
          "usage_estimated"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "账务记录唯一 ID（`usage_<数字>`）。"
          },
          "request_id": {
            "type": "string",
            "description": "对应 API 响应头 `X-Oneapi-Request-Id`（图片重放时对应 `X-Image-Request-Id`）。"
          },
          "created_at": {
            "type": "integer",
            "description": "入账 Unix 秒。"
          },
          "model": {
            "type": "string",
            "description": "结算模型 ID。"
          },
          "result": {
            "type": "string",
            "enum": [
              "completed",
              "failed",
              "unknown"
            ],
            "description": "任务执行状态；同步请求无异步任务行时通常为 `unknown`，以 `billing_status` 与 `amount` 为结算依据。"
          },
          "billing_status": {
            "type": "string",
            "enum": [
              "pending",
              "settled",
              "refunded",
              "unknown"
            ],
            "description": "账务状态：`settled` 看 `amount`，`pending` 看 `reserved_amount`，`refunded` 结合 `amount` 与 `refunded_amount`，`unknown` 表示尚无确定金额而非免费。"
          },
          "amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "权威人民币实扣金额（6 位小数十进制字符串，独立退款记录可为负数，`null` 表示未确定金额）。"
          },
          "reserved_amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "异步任务提交时的预留人民币金额。"
          },
          "refunded_amount": {
            "type": [
              "string",
              "null"
            ],
            "description": "已退回的人民币金额。"
          },
          "input_tokens": {
            "type": "integer",
            "description": "输入 Token 数（图片按次/像素计费模型中仅作日志记录，不替代 `amount`）。"
          },
          "output_tokens": {
            "type": "integer",
            "description": "输出 Token 数；按 Token 计费的已结算视频任务（如 Seedance、WAND Vega Pro）同样在此返回实际结算的视频 Token 总数。"
          },
          "cache_read_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "description": "缓存命中 Token 数，`null` 表示不适用或未提供。"
          },
          "cache_write_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "description": "缓存写入 Token 数，`null` 表示不适用或未提供。"
          },
          "usage_estimated": {
            "type": "boolean",
            "description": "该条记录是否含估算用量。"
          },
          "pricebook_id": {
            "type": "string",
            "description": "命中的价格簿标识（如 `enterprise_cny_v1`）。"
          },
          "pricing_version": {
            "type": "string",
            "description": "计价时刻锁定的价格簿版本摘要。"
          }
        }
      },
      "KeyUsagePage": {
        "type": "object",
        "required": [
          "currency",
          "start_time",
          "end_time",
          "data",
          "next_cursor",
          "has_more"
        ],
        "properties": {
          "currency": {
            "type": "string",
            "enum": [
              "CNY"
            ]
          },
          "start_time": {
            "type": "integer"
          },
          "end_time": {
            "type": "integer"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/KeyUsageRecord"
            }
          },
          "next_cursor": {
            "type": "string",
            "description": "下一页游标（纯数字字符串），传给下一次请求的 `before` 参数。"
          },
          "has_more": {
            "type": "boolean",
            "description": "是否还有更早记录。"
          }
        }
      },
      "ImageGenerationRequest": {
        "type": "object",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "精确图片模型 ID，如 `dola-seedream-5-5-261028`、`dola-seedream-5-0-pro-260628`、`gpt-image-2.5`、`hy-image-v3`、`midjourney-v8.2`。"
          },
          "prompt": {
            "type": "string",
            "description": "图片描述提示词（普通文生图与图像编辑必填；Seedream 开启 `layer_decomposition: true` 图层拆解时可省略）。"
          },
          "size": {
            "type": "string",
            "description": "尺寸档位（Seedream 5.5/Pro/Flash 普通模式支持 `1K`/`1.5K`/`2K` 及自定义 `宽x高`，默认 `2K`；开启 `layer_decomposition: true` 拆层时默认 `auto`，仅支持 `auto`/`1K`/`1.5K`/`2K`，不支持自定义 `宽x高`）。"
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 128,
            "description": "生成张数。Seedream 与 `hy-image-v3` 省略或传 `1`；`midjourney-v8.2` 固定输出 4 张，须省略或传 `4`。"
          },
          "quality": {
            "type": "string",
            "description": "画质档位（仅 `gpt-image-*` 系列使用；Seedream 勿传非 `standard` 值）。"
          },
          "response_format": {
            "type": "string",
            "enum": [
              "url",
              "b64_json"
            ],
            "default": "url",
            "description": "推荐默认 `url`（返回广州 COS 代理短链，避免大体积 Base64）。"
          },
          "output_format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "gif",
              "svg"
            ],
            "description": "输出图片格式（Seedream 与 `gpt-image-2.5` 支持 `png`/`jpeg`；`gpt-image-2.6` 另支持 `gif`（限 1K）与 `svg`；透明底须用 `png`）。"
          },
          "background": {
            "type": "string",
            "enum": [
              "auto",
              "transparent",
              "opaque"
            ],
            "description": "背景模式（Seedream 5.5 支持三者；5.0 Pro/Flash 支持 `transparent`/`opaque`；开启 `layer_decomposition: true` 拆层模式时不支持传入）。"
          },
          "image": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ],
            "description": "可选参考图 URL 或 URL 数组（纯文生图不传；Seedream 兼容单端点传图与拆层，5.5/Pro/Flash 最多 10 张，开启图层拆解须传恰好 1 张）。"
          },
          "layer_decomposition": {
            "type": "boolean",
            "default": false,
            "description": "开启 Seedream 图层拆解（`dola-seedream-5-5-261028`、`dola-seedream-5-0-pro-260628`、`dola-seedream-5-0-flash-260915` 支持，`seedream-5-0-260128` 不支持；须配恰好 1 张输入图，发往 `/v1/images/edits` 或 `/v1/images/generations` 均可。5.5 默认最多 30 层；5.0 Pro / 5.0 Flash 默认最多 17 层且不要传 `layer_decomposition_options`；仅开启该项时 `data[]` 才会返回 `z_index`、`bounding_box` 等拆层字段）。"
          },
          "layer_decomposition_options": {
            "type": "object",
            "description": "仅 Seedream 5.5（`dola-seedream-5-5-261028`）且 `layer_decomposition: true` 时可用；5.0 Pro / 5.0 Flash 请省略此字段（传入会返回 `400`）。",
            "properties": {
              "max_images": {
                "type": "integer",
                "minimum": 2,
                "maximum": 100,
                "default": 30,
                "description": "最大拆出图层数（含基底）。"
              },
              "text_recognition": {
                "type": "boolean",
                "default": true,
                "description": "是否对文字图层输出 OCR 结构（`text_recognition`）。"
              }
            }
          },
          "watermark": {
            "type": "boolean",
            "default": false,
            "description": "Seedream 是否添加水印，网关默认关闭（`false`）。"
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4294967295,
            "description": "随机种子（支持型号生效，如 `hy-image-v3` 支持 `>= 0`；Seedream 系列忽略该字段）。"
          },
          "safety_identifier": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64,
            "description": "Seedream 5.5/Pro/Flash 可选终端用户安全标识（1–64 位 ASCII）。"
          }
        }
      },
      "ImageEditRequest": {
        "allOf": [
          {
            "$ref": "#/components/schemas/ImageGenerationRequest"
          },
          {
            "type": "object",
            "required": [
              "model",
              "image"
            ],
            "properties": {
              "mask": {
                "type": "string",
                "format": "uri",
                "description": "可选局部编辑蒙版 URL（Seedream 系列不支持蒙版）。"
              }
            }
          }
        ]
      },
      "ImageBoundingBox": {
        "type": "object",
        "description": "仅在 Seedream 开启 `layer_decomposition: true` 图层拆解时返回：前景图层在原图中的位置坐标。",
        "properties": {
          "absolute": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "minItems": 4,
            "maxItems": 4,
            "description": "绝对像素坐标 `[x1, y1, x2, y2]`。"
          },
          "normalized": {
            "type": "array",
            "items": {
              "type": "integer"
            },
            "minItems": 4,
            "maxItems": 4,
            "description": "归一化坐标 `[x1, y1, x2, y2]`（千分比 0–1000）。"
          }
        }
      },
      "ImageDataItem": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "图片下载链接（受控代理短链 `/v1/images/proxy?t=...`，访问时 `302` 跳转至广州 COS 短期签名地址；请用 `curl -L` 下载并及时转存）。"
          },
          "b64_json": {
            "type": "string",
            "description": "当请求指定 `response_format: \"b64_json\"` 时返回的 Base64 图片字节。"
          },
          "revised_prompt": {
            "type": "string",
            "description": "上游自动改写后的提示词（部分型号返回）。"
          },
          "size": {
            "type": "string",
            "description": "**每张输出图的实际分辨率**，格式为 `\"宽x高\"`（如 `\"1024x1024\"`、`\"2496x1664\"`）。Seedream 5.5 / 5.0 Pro 必返回，用于按 `宽 × 高` 判定万像素计费档位。"
          },
          "output_format": {
            "type": "string",
            "enum": [
              "png",
              "jpeg",
              "gif",
              "svg"
            ],
            "description": "实际输出文件格式（Seedream / GPT Image 返回）。"
          },
          "background": {
            "type": "string",
            "enum": [
              "opaque",
              "transparent"
            ],
            "description": "实际背景类型（Seedream 5.5/Pro/Flash 返回）。"
          },
          "z_index": {
            "type": "integer",
            "description": "仅在 Seedream 开启 `layer_decomposition: true` 图层拆解时返回：图层叠放顺序，0 为底图背景，递增为前景层。"
          },
          "bounding_box": {
            "$ref": "#/components/schemas/ImageBoundingBox"
          },
          "name": {
            "type": "string",
            "description": "仅在 Seedream 开启 `layer_decomposition: true` 图层拆解时返回：前景图层短名称。"
          },
          "description": {
            "type": "string",
            "description": "仅在 Seedream 开启 `layer_decomposition: true` 图层拆解时返回：前景图层内容描述。"
          },
          "text_recognition": {
            "type": "object",
            "additionalProperties": true,
            "description": "仅在 Seedream 5.5 开启 `layer_decomposition: true` 且 `text_recognition: true` 时返回：文字图层 OCR 识别结构。"
          }
        }
      },
      "ImageUsage": {
        "type": "object",
        "description": "上游图片生成用量统计（Seedream 全系列透传返回）。",
        "properties": {
          "input_images": {
            "type": "integer",
            "description": "本次请求实际计入的参考输入图张数。"
          },
          "generated_images": {
            "type": "integer",
            "description": "本次成功生成并计费的输出图片/图层张数。"
          },
          "output_tokens": {
            "type": "integer",
            "description": "上游报告的输出图像 Token 数。"
          },
          "total_tokens": {
            "type": "integer",
            "description": "上游报告的总 Token 数。"
          }
        }
      },
      "ImageResponse": {
        "type": "object",
        "required": [
          "created",
          "data"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "实际执行的模型 ID（Seedream 透传返回）。"
          },
          "created": {
            "type": "integer",
            "description": "创建 Unix 秒时间戳。"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ImageDataItem"
            },
            "description": "生成的图片或图层列表。"
          },
          "usage": {
            "$ref": "#/components/schemas/ImageUsage"
          }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "精确文本/多模态模型 ID。"
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "description": "对话消息列表，支持 `system`/`user`/`assistant`/`tool` 角色及多模态内容数组。",
            "items": {
              "type": "object",
              "required": [
                "role"
              ],
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "system",
                    "developer",
                    "user",
                    "assistant",
                    "tool"
                  ]
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    },
                    {
                      "type": "null"
                    }
                  ]
                }
              }
            }
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "最大输出 Token 数。"
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "description": "采样温度；显式传 `0` 会原样透传上游。"
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "是否启用 SSE 流式响应。"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "可选工具定义列表。"
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": true
              }
            ],
            "description": "工具调用策略。"
          }
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "chat.completion"
            ]
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "reasoning_content": {
                      "type": "string",
                      "description": "推理模型返回的思维链文本（如有）。"
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  }
                }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "integer"
              },
              "completion_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              },
              "prompt_tokens_details": {
                "type": "object",
                "properties": {
                  "cached_tokens": {
                    "type": "integer"
                  }
                }
              },
              "completion_tokens_details": {
                "type": "object",
                "properties": {
                  "reasoning_tokens": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      },
      "ResponsesRequest": {
        "type": "object",
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "支持 Responses 协议的精确模型 ID（如 `gpt-5.6-sol`、`gpt-6-sol`）。"
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            ],
            "description": "文本输入或结构化输入项数组。"
          },
          "instructions": {
            "type": "string",
            "description": "可选系统级指令。"
          },
          "max_output_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "最大输出 Token 数。"
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "是否启用 SSE 流式事件。"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "可选工具定义。"
          }
        }
      },
      "ResponsesObject": {
        "type": "object",
        "required": [
          "id",
          "object",
          "status",
          "output"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "response"
            ]
          },
          "created_at": {
            "type": "integer"
          },
          "completed_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "in_progress",
              "completed",
              "incomplete",
              "failed"
            ]
          },
          "model": {
            "type": "string"
          },
          "output": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "输出项数组（含 `message`、`reasoning`、`function_call` 等）。"
          },
          "usage": {
            "type": "object",
            "properties": {
              "input_tokens": {
                "type": "integer"
              },
              "output_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              },
              "input_tokens_details": {
                "type": "object",
                "additionalProperties": true
              },
              "output_tokens_details": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        }
      },
      "AnthropicMessageRequest": {
        "type": "object",
        "required": [
          "model",
          "max_tokens",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "精确 Claude 模型 ID（如 `claude-sonnet-4-6`、`claude-opus-5`）。"
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "description": "必填，最大生成 Token 数。"
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            ],
            "description": "可选系统提示词。"
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "对话消息列表。"
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "description": "是否启用 SSE 流式输出。"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        }
      },
      "AnthropicMessageResponse": {
        "type": "object",
        "required": [
          "id",
          "type",
          "role",
          "model",
          "content",
          "usage"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "message"
            ]
          },
          "role": {
            "type": "string",
            "enum": [
              "assistant"
            ]
          },
          "model": {
            "type": "string"
          },
          "content": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "内容块数组（`text`、`thinking`、`tool_use` 等）。"
          },
          "stop_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "stop_sequence": {
            "type": [
              "string",
              "null"
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "input_tokens": {
                "type": "integer"
              },
              "output_tokens": {
                "type": "integer"
              },
              "cache_creation_input_tokens": {
                "type": "integer"
              },
              "cache_read_input_tokens": {
                "type": "integer"
              },
              "cache_creation": {
                "type": "object",
                "properties": {
                  "ephemeral_5m_input_tokens": {
                    "type": "integer"
                  },
                  "ephemeral_1h_input_tokens": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      },
      "VideoCreateRequest": {
        "type": "object",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "精确视频模型 ID（`magi-2`、`seedance-2.0-mini`、`minimax-h3`、`kling-video-v3`、`wan3.0-video` 等）。"
          },
          "prompt": {
            "type": "string",
            "description": "视频画面与运镜描述。"
          },
          "operation": {
            "type": "string",
            "enum": [
              "text_to_video",
              "image_to_video",
              "reference_to_video",
              "audio_to_video"
            ],
            "description": "可选显式操作类型。"
          },
          "seconds": {
            "type": "string",
            "description": "Seedance 兼容字符串时长（如 `\"5\"`）。"
          },
          "duration": {
            "type": "integer",
            "description": "视频时长秒数（如 `magi-2` 为 4–30，Seedance 自动时长为 `-1`）。"
          },
          "resolution": {
            "type": "string",
            "description": "分辨率（如 `480p`/`720p`/`768p`/`1080p`，按型号开放）。"
          },
          "aspect_ratio": {
            "type": "string",
            "description": "画幅比例（如 `16:9`/`9:16`/`1:1`/`4:3`/`3:4`/`21:9`）。"
          },
          "generate_audio": {
            "type": "boolean",
            "description": "是否生成同步音频。"
          },
          "seed": {
            "type": "integer",
            "description": "可选随机种子。"
          },
          "image": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "properties": {
                  "url": {
                    "type": "string"
                  }
                }
              }
            ],
            "description": "首帧图片链接。"
          },
          "content": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "description": "带角色的多模态素材数组（`first_frame`/`last_frame`/`reference_image`/`reference_video`/`reference_audio`）。"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Seedance 兼容参数对象（`resolution`、`ratio`、`generate_audio`、`return_last_frame` 等）。"
          }
        }
      },
      "VideoTask": {
        "type": "object",
        "required": [
          "id",
          "object",
          "model",
          "status"
        ],
        "properties": {
          "id": {
            "type": "string",
            "description": "视频任务 ID（`task_...`）。"
          },
          "task_id": {
            "type": "string",
            "description": "同 `id`，便于统一解析。"
          },
          "object": {
            "type": "string",
            "enum": [
              "video"
            ]
          },
          "model": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "in_progress",
              "completed",
              "failed",
              "unknown"
            ],
            "description": "任务当前状态。"
          },
          "progress": {
            "type": "integer",
            "minimum": 0,
            "maximum": 100,
            "description": "仅供参考的进度百分比。"
          },
          "created_at": {
            "type": "integer",
            "description": "创建 Unix 秒。"
          },
          "completed_at": {
            "type": "integer",
            "description": "完成 Unix 秒（未完成时省略）。"
          },
          "video_url": {
            "type": "string",
            "format": "uri",
            "description": "结果下载接口地址（需带 Key 访问）。"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "结果元数据：含 `url`、`delivery_status`，按 Token 计费视频（如 Seedance）包含 `usage: { \"completion_tokens\": ..., \"total_tokens\": ... }` 与可选 `last_frame_url`，MiniMax H3 包含 `expanded_prompt` / `timings` 等。",
            "properties": {
              "url": {
                "type": "string",
                "description": "结果下载接口路径。"
              },
              "delivery_status": {
                "type": "string",
                "description": "云存储交付状态（如 `ready`、`pending`）。"
              },
              "usage": {
                "type": "object",
                "description": "按 Token 计费视频型号（如 Seedance）结算后返回的实际视频 Token 用量。",
                "properties": {
                  "completion_tokens": {
                    "type": "integer",
                    "description": "视频生成实际消耗 Token 数。"
                  },
                  "total_tokens": {
                    "type": "integer",
                    "description": "本次视频任务总计费 Token 数。"
                  }
                }
              }
            }
          },
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "AudioSpeechRequest": {
        "type": "object",
        "required": [
          "model"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "语音合成或音乐生成模型 ID（如 `minimax-speech-2.8-turbo`、`seed-audio-1.0`、`minimax-music-v3.0`、`mureka-music-v8`）。"
          },
          "input": {
            "type": "string",
            "description": "待合成的文本内容（TTS 必填；音乐生成可作为风格/意境提示词）。"
          },
          "voice": {
            "type": "string",
            "description": "音色 ID（如 `male-qn-qingse`）。"
          },
          "instructions": {
            "type": "string",
            "description": "可选，播报风格或情感指引（`seed-audio-1.0` 等支持型号生效）。"
          },
          "response_format": {
            "type": "string",
            "description": "可选输出音频格式（如 `mp3`、`wav`、`pcm`、`flac`，默认 `mp3`）。"
          },
          "speed": {
            "type": "number",
            "minimum": 0.5,
            "maximum": 2,
            "default": 1,
            "description": "语速倍率。"
          },
          "pitch": {
            "type": "integer",
            "minimum": -12,
            "maximum": 12,
            "default": 0,
            "description": "音高整数偏移（非整数会被拒绝）。"
          },
          "volume": {
            "type": "number",
            "minimum": 0.1,
            "maximum": 10,
            "default": 1,
            "description": "音量倍率（通用范围 `0.1–10`；`seed-audio-1.0` 范围为 `0.5–2.0`）。"
          },
          "stream_format": {
            "type": "string",
            "enum": [
              "audio",
              "sse"
            ],
            "description": "可选流式返回模式（默认省略；`minimax-music-v2.6` 与 `mureka-music-v8` 仅接受 `sse` 或省略，显式传 `audio` 会返回 `400`）。"
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "扩展控制参数。**注意**：情绪控制（`emotion` / `voice_setting.emotion`）、音乐歌词（`lyrics`，`mureka-music-v8` 必填）、纯音乐开关（`is_instrumental`）、歌词优化（`lyrics_optimizer`，仅 `minimax-music-v3.0`）、采样率/码率（`minimax-music-v3.0` 须放在 `metadata.audio_setting.sample_rate` / `bitrate`；`minimax-music-v2.6` 支持 `metadata.sample_rate` / `bitrate`）与参考素材（`references`）均须放在 `metadata` 内，而非顶层字段。",
            "properties": {
              "emotion": {
                "type": "string",
                "description": "情绪控制（如 `happy`、`calm`、`whisper`，按型号支持）。"
              },
              "lyrics": {
                "type": "string",
                "description": "音乐生成歌词（`mureka-music-v8` 必填）。"
              },
              "is_instrumental": {
                "type": "boolean",
                "description": "是否生成纯器乐音乐。"
              },
              "lyrics_optimizer": {
                "type": "boolean",
                "description": "是否由模型自动优化歌词。"
              },
              "sample_rate": {
                "type": "integer",
                "description": "音乐输出采样率（如 `44100`）。"
              },
              "bitrate": {
                "type": "integer",
                "description": "音乐输出码率（如 `256000`）。"
              }
            }
          }
        }
      },
      "AudioTranscriptionResponse": {
        "type": "object",
        "required": [
          "text"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "识别转写出的完整文本内容。"
          }
        }
      },
      "WebToolSearchRequest": {
        "type": "object",
        "required": [
          "query"
        ],
        "properties": {
          "query": {
            "type": "string",
            "minLength": 1,
            "maxLength": 400,
            "description": "搜索关键词或自然语言查询；自动去除首尾空白，超过 400 字符自动截断。"
          },
          "count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 8,
            "description": "期望返回的搜索结果条数（默认 `8`，上限 `20`）。"
          },
          "max_results": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "description": "`count` 的兼容别名；当 `count` 未传或 `<= 0` 时生效。"
          },
          "need_content": {
            "type": "boolean",
            "default": false,
            "description": "是否尽量在每条结果的 `content` 字段返回更完整的正文摘录（最长约 4,000 字符）。"
          },
          "mode": {
            "type": "integer",
            "enum": [
              0,
              1,
              2
            ],
            "default": 2,
            "description": "摘要粒度控制模式，仅允许 `0`、`1`、`2`；传入范围外整数返回 `400`。"
          },
          "site": {
            "type": "string",
            "description": "可选域名过滤，如 `example.com` 限定站内结果，或 `exclude:domain1|domain2` 排除指定站点。"
          },
          "freshness": {
            "type": "string",
            "description": "可选时效过滤标识，用于限定搜索结果的时间范围。"
          }
        }
      },
      "WebToolSearchItem": {
        "type": "object",
        "required": [
          "title",
          "url",
          "content"
        ],
        "properties": {
          "title": {
            "type": "string",
            "description": "网页标题。"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "description": "网页链接。"
          },
          "snippet": {
            "type": "string",
            "description": "简短摘要（最长约 500 字符）。"
          },
          "summary": {
            "type": "string",
            "description": "较完整的内容摘要（最长约 1,500 字符）。"
          },
          "content": {
            "type": "string",
            "description": "较长正文摘录；当 `need_content` 为 `false` 或来源无长文时为空字符串 `\"\"`。"
          },
          "date": {
            "type": "string",
            "description": "页面发布时间或更新日期（如有）。"
          },
          "site": {
            "type": "string",
            "description": "来源站点名称或域名（如有）。"
          },
          "rerank_score": {
            "type": "number",
            "description": "相关性重排分数（如有）。"
          },
          "score": {
            "type": "number",
            "description": "综合相关性分数（如有）。"
          }
        }
      },
      "WebToolSearchResponse": {
        "type": "object",
        "required": [
          "results"
        ],
        "properties": {
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/WebToolSearchItem"
            },
            "description": "按相关性排序的搜索结果列表；无匹配结果时为空数组且不扣费。"
          }
        }
      },
      "WebToolFetchRequest": {
        "type": "object",
        "required": [
          "url"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "待读取网页的公网 `http://` 或 `https://` 地址；禁止携带认证信息、禁止 `localhost` 与内网/保留 IP。"
          }
        }
      },
      "WebToolFetchResponse": {
        "type": "object",
        "required": [
          "url",
          "title",
          "content"
        ],
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "description": "规范化后的目标网页地址。"
          },
          "title": {
            "type": "string",
            "description": "提取到的网页标题（若无则为空字符串）。"
          },
          "content": {
            "type": "string",
            "description": "清洗提取后的纯文本 / Markdown 网页正文（按 UTF-8 截断至 1 MiB 以内）。"
          }
        }
      }
    }
  }
}
