{
  "openapi": "3.1.2",
  "info": {
    "title": "Sonelle Speech API",
    "version": "2026-10-28-qwen-r68",
    "description": "Qwen3-TTS ClearVoice 单句 epoch5 的系统声线接口：同步、完整文本输入的音频流式、异步 Jobs、语速与格式。X-API-Key 鉴权，USD15/百万加权字符。具体部署和质量核验见项目发布记录；声线与等级以运行时目录为准。"
  },
  "servers": [
    {
      "url": "https://www.sonelle.ai",
      "description": "Sonelle 生产入口"
    }
  ],
  "security": [
    {
      "ApiKey": []
    }
  ],
  "tags": [
    {
      "name": "Voices",
      "description": "运行时声线能力目录。"
    },
    {
      "name": "Speech",
      "description": "一次返回完整音频的同步合成。"
    },
    {
      "name": "Jobs",
      "description": "持久异步生成与幂等重放"
    },
    {
      "name": "Billing",
      "description": "查询操作最终账务状态"
    }
  ],
  "externalDocs": {
    "url": "https://www.sonelle.ai/docs/",
    "description": "用户接入文档"
  },
  "paths": {
    "/api/v1/tts/voices": {
      "get": {
        "tags": [
          "Voices"
        ],
        "operationId": "listVoices",
        "summary": "读取当前声线目录",
        "description": "需要有效 API Key。返回可用状态与声线信息；读取目录不会触发合成。提交时仍会再次检查声线状态。",
        "responses": {
          "200": {
            "description": "目录读取成功。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/VoiceCatalogResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "default": {
            "description": "代理或框架可能返回其他状态或非 JSON 错误。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          }
        }
      }
    },
    "/api/v1/text-to-speech": {
      "post": {
        "tags": [
          "Speech"
        ],
        "operationId": "createSpeech",
        "summary": "将文字生成完整音频",
        "description": "同步完整文件；只有全部分句完成才返回音频。request_id仅追踪，同值重试可能再次生成和计费。错误、超时或断连后查询billing operation；需要幂等重试请用Jobs。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SpeechRequest"
              },
              "example": {
                "voice_id": "YOUR_VOICE_ID",
                "generate_text": "这是一段 Sonelle 语音示例。",
                "audio_format": "wav",
                "speed": 1,
                "request_id": "your-business-request-id"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "完整音频字节，不是 JSON 或 base64；以 Content-Type 判断格式。",
            "headers": {
              "X-Request-Id": {
                "description": "请求追踪标识，不是生成或计费幂等键。",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "X-Trace-Id": {
                "description": "服务端追踪标识。",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "X-Input-Chars": {
                "description": "去除首尾空白后的原始文本加权计费字符数；中文按 2，其余按 1。",
                "required": true,
                "schema": {
                  "type": "integer"
                }
              },
              "X-Audio-Sample-Rate": {
                "description": "WAV/PCM 的采样率，单位 Hz。 其他编码不保证此头。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "X-Audio-Channels": {
                "description": "WAV/PCM 的声道数。 其他编码不保证此头。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "X-Audio-Bit-Depth": {
                "description": "WAV/PCM 的位深。 其他编码不保证此头。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "X-Billing-Operation-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Billing-Currency": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Billing-Price-Version": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Model-Profile": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Checkpoint-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Generation-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Selected-Style": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Style-Source": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Reference-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              }
            },
            "content": {
              "audio/wav": {},
              "audio/pcm": {},
              "audio/mpeg": {},
              "audio/ogg": {},
              "audio/flac": {}
            }
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        }
      }
    },
    "/api/v1/text-to-speech/stream": {
      "post": {
        "tags": [
          "Speech"
        ],
        "operationId": "streamSpeech",
        "summary": "完整文本输入并增量返回音频",
        "description": "stream_format=audio默认原始字节；sse逐事件返回Base64增量。必须收到done才算完整。首音频前正常HTTP/JSON错误；交付后SSE error带discard=true，raw中止传输。断连不自动重试。 流式总时限 900 秒，上游首音频或空闲超时 90 秒，客户端写入停滞 30 秒终止。同步总时限仍为 180 秒。 metadata.sample_rate/channels/bit_depth 描述源PCM；压缩格式按容器解码，Opus解码采样率为48kHz。 metadata.selected_style/reference_id/reference_config_version/capability_version 表示实际等级、参考及版本。",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SpeechStreamRequest"
              },
              "example": {
                "voice_id": "YOUR_VOICE_ID",
                "generate_text": "这是一段 Sonelle 语音示例。",
                "audio_format": "pcm",
                "speed": 1.1,
                "request_id": "your-business-request-id",
                "stream_format": "sse"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "原始音频或SSE事件；HTTP200本身不保证生成完成。",
            "headers": {
              "X-Request-Id": {
                "description": "请求追踪标识，不是生成或计费幂等键。",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "X-Trace-Id": {
                "description": "服务端追踪标识。",
                "required": true,
                "schema": {
                  "type": "string"
                }
              },
              "X-Input-Chars": {
                "description": "去除首尾空白后的原始文本加权计费字符数；中文按 2，其余按 1。",
                "required": true,
                "schema": {
                  "type": "integer"
                }
              },
              "X-Audio-Sample-Rate": {
                "description": "WAV/PCM 的采样率，单位 Hz。 其他编码不保证此头。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "X-Audio-Channels": {
                "description": "WAV/PCM 的声道数。 其他编码不保证此头。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "X-Audio-Bit-Depth": {
                "description": "WAV/PCM 的位深。 其他编码不保证此头。",
                "schema": {
                  "type": "integer",
                  "minimum": 1
                }
              },
              "X-Billing-Operation-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Billing-Currency": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Billing-Price-Version": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Model-Profile": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Checkpoint-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Generation-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Selected-Style": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Style-Source": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              },
              "X-Reference-Id": {
                "schema": {
                  "type": "string"
                },
                "description": "服务端实际响应；账务以operation最终查询结果为准。"
              }
            },
            "content": {
              "audio/wav": {},
              "audio/pcm": {},
              "audio/mpeg": {},
              "audio/ogg": {},
              "audio/flac": {},
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "event: audio\ndata: {\"audio\":\"ZABkAA==\",\"seq\":0,\"audio_format\":\"pcm\",\"request_id\":\"example\",\"operation_id\":\"operation-id\"}\n\nevent: done\ndata: {\"seq\":1,\"audio_format\":\"pcm\",\"request_id\":\"example\",\"operation_id\":\"operation-id\"}\n\n"
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        },
        "x-sse-events": {
          "audio": {
            "required": [
              "audio",
              "seq",
              "request_id",
              "operation_id",
              "audio_format"
            ],
            "audio": "Base64, ordered increments; metadata on first event"
          },
          "done": {
            "required": [
              "seq",
              "request_id",
              "operation_id",
              "audio_format"
            ],
            "meaning": "complete audio and finalized billing"
          },
          "error": {
            "required": [
              "error",
              "discard"
            ],
            "discard": true,
            "meaning": "discard partial audio; no done follows"
          }
        }
      }
    },
    "/api/v1/tts/jobs": {
      "post": {
        "tags": [
          "Jobs"
        ],
        "operationId": "createSpeechJob",
        "summary": "创建或重放异步任务",
        "description": "相同Idempotency-Key与归一化请求重放同一job，不重复生成/计费；改变文本、格式、语速、等级等返回409。创建时固定模型、等级和Reference，后续策略变化不改已接收任务。",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "minLength": 8,
              "maxLength": 128
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SpeechJobRequest"
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "已受理或幂等重放",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "succeed": {
                      "type": "boolean"
                    },
                    "error_code": {
                      "type": "integer"
                    },
                    "error_message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "required": [
                        "job",
                        "idempotent_replay"
                      ],
                      "properties": {
                        "job": {
                          "$ref": "#/components/schemas/Job"
                        },
                        "idempotent_replay": {
                          "type": "boolean"
                        }
                      }
                    }
                  },
                  "required": [
                    "succeed",
                    "data"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "幂等键与请求冲突"
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        }
      }
    },
    "/api/v1/tts/jobs/{id}": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "operationId": "getSpeechJob",
        "summary": "查询任务",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "任务信息",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "succeed": {
                      "type": "boolean"
                    },
                    "error_code": {
                      "type": "integer"
                    },
                    "error_message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Job"
                    }
                  },
                  "required": [
                    "succeed",
                    "data"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "任务不存在或不属于当前账户"
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Jobs"
        ],
        "operationId": "markSpeechJobDeleted",
        "summary": "停止签发新下载链接",
        "description": "仅删除标记，不等于已签发链接失效或对象已清理。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "任务信息",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "succeed": {
                      "type": "boolean"
                    },
                    "error_code": {
                      "type": "integer"
                    },
                    "error_message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Job"
                    }
                  },
                  "required": [
                    "succeed",
                    "data"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "状态不允许"
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        }
      }
    },
    "/api/v1/tts/jobs/{id}/audio": {
      "get": {
        "tags": [
          "Jobs"
        ],
        "operationId": "downloadSpeechJob",
        "summary": "获取私有音频下载链接",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "有效5分钟的签名URL",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "409": {
            "description": "任务尚未完成或音频不可用"
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        }
      }
    },
    "/api/v1/tts/jobs/{id}/cancel": {
      "post": {
        "tags": [
          "Jobs"
        ],
        "operationId": "cancelSpeechJob",
        "summary": "取消排队或等待重试的任务",
        "description": "运行中的Jobs返回409；不是流式断连操作。",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "任务信息",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "succeed": {
                      "type": "boolean"
                    },
                    "error_code": {
                      "type": "integer"
                    },
                    "error_message": {
                      "type": "string"
                    },
                    "data": {
                      "$ref": "#/components/schemas/Job"
                    }
                  },
                  "required": [
                    "succeed",
                    "data"
                  ]
                }
              }
            }
          },
          "409": {
            "description": "任务运行中或已终结"
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        }
      }
    },
    "/api/v1/tts/billing/operations/{id}": {
      "get": {
        "tags": [
          "Billing"
        ],
        "operationId": "getBillingOperation",
        "summary": "查询本账户计费操作",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "最终金额、state、outcome、delivery_started；pending_review不是未扣费的证明。",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "succeed": {
                      "type": "boolean"
                    },
                    "error_code": {
                      "type": "integer"
                    },
                    "error_message": {
                      "type": "string"
                    },
                    "data": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string"
                        },
                        "currency": {
                          "const": "USD"
                        },
                        "state": {
                          "type": "string"
                        },
                        "outcome": {
                          "type": "string"
                        },
                        "delivery_started": {
                          "type": "boolean"
                        },
                        "quoted_amount_micro": {
                          "type": "string"
                        },
                        "billable_chars": {
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "required": [
                    "succeed",
                    "data"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "操作不存在或不属于本账户"
          },
          "400": {
            "$ref": "#/components/responses/Status400"
          },
          "401": {
            "$ref": "#/components/responses/Status401"
          },
          "402": {
            "$ref": "#/components/responses/Status402"
          },
          "403": {
            "$ref": "#/components/responses/Status403"
          },
          "429": {
            "$ref": "#/components/responses/Status429"
          },
          "500": {
            "$ref": "#/components/responses/Status500"
          },
          "503": {
            "$ref": "#/components/responses/Status503"
          },
          "504": {
            "$ref": "#/components/responses/Status504"
          },
          "502": {
            "description": "反向代理无法连接上游；可能是 HTML，不保证业务 JSON 格式。",
            "content": {
              "text/html": {},
              "text/plain": {}
            }
          },
          "default": {
            "description": "网关或框架拒绝（例如请求体过大）可能返回其他状态或非 JSON 正文。停止并检查状态与 Content-Type。",
            "content": {
              "text/html": {},
              "text/plain": {},
              "application/json": {}
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "服务端安全配置的 API Key。不是 Bearer token；不要写入 URL、公开代码或聊天提示词。"
      }
    },
    "schemas": {
      "SpeechRequest": {
        "type": "object",
        "required": [
          "voice_id",
          "generate_text"
        ],
        "properties": {
          "voice_id": {
            "type": "string",
            "minLength": 1,
            "description": "从 GET /api/v1/tts/voices 当前响应选择 ready 或 preview 声线。去除首尾空白并转为小写。",
            "pattern": "\\S"
          },
          "generate_text": {
            "type": "string",
            "minLength": 1,
            "description": "去除首尾空白后必须含可朗读内容。最多 2000 加权字符，中文按 2、其余字符按 1；预处理展开后的执行文本也受限制，不能用 maxLength 表达该规则。",
            "x-weighted-max-characters": 2000,
            "pattern": "\\S"
          },
          "audio_format": {
            "type": "string",
            "default": "wav",
            "enum": [
              "wav",
              "pcm",
              "pcm_s16le",
              "mp3",
              "opus",
              "ogg",
              "ogg_opus",
              "flac",
              ""
            ],
            "description": "省略或空串使用 WAV。格式忽略大小写及首尾空白。pcm_s16le 是 pcm 的别名；ogg、ogg_opus 是 opus 的别名，返回 Ogg 容器。"
          },
          "speed": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.5,
                "maximum": 2
              },
              {
                "type": "number",
                "const": 0
              }
            ],
            "default": 1,
            "description": "默认1；0等同默认。0.5–2倍速度，连续音频后处理保持音高；同步、流式和Jobs一致。"
          },
          "request_id": {
            "type": "string",
            "description": "可选追踪标识；去除首尾空白后最多160个ASCII字符，首字符须为字母或数字，后续仅字母、数字、_ . : -，否则400；省略或空串由服务端生成。不是生成或计费幂等键，重复请求可能再次生成和计费；以X-Request-Id为准。",
            "maxLength": 160,
            "pattern": "^([A-Za-z0-9][A-Za-z0-9_.:-]{0,159})?$"
          },
          "style_level": {
            "type": "string",
            "enum": [
              "",
              "L1",
              "L2",
              "L3",
              "L4"
            ],
            "description": "省略或空串自动选择；非空手动选择 L1–L4。实际等级见 selected_style 或 X-Selected-Style。"
          },
          "ref_audio_url": {
            "type": "string",
            "const": "",
            "deprecated": true,
            "description": "系统声线接口不支持自定义参考音频，请省略此字段。"
          },
          "ref_text": {
            "type": "string",
            "const": "",
            "deprecated": true,
            "description": "系统声线接口不支持自定义参考文本，请省略此字段。"
          }
        },
        "additionalProperties": false,
        "description": "系统声线请求；最大2000加权字符。禁止自定义参考音频。未知字段不属于合同。"
      },
      "Voice": {
        "type": "object",
        "required": [
          "voice_id",
          "display_name",
          "language",
          "status",
          "capability_version",
          "available_styles"
        ],
        "properties": {
          "voice_id": {
            "type": "string",
            "description": "动态目录值。调用时读取，不能固化为固定枚举。"
          },
          "display_name": {
            "type": "string"
          },
          "language": {
            "type": "string",
            "description": "声线语言标识，以目录响应为准。"
          },
          "status": {
            "type": "string",
            "description": "只有 ready 和 preview 可调用；preview 使用前应试听。其余或未知状态均不应提交合成。"
          },
          "capability_version": {
            "type": "string"
          },
          "available_styles": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "声线能力元数据。此最小接入合同使用服务端自动表达，不开放手动风格参数。"
          }
        },
        "additionalProperties": true
      },
      "VoiceCatalogResponse": {
        "type": "object",
        "required": [
          "error_code",
          "error_message",
          "succeed",
          "data"
        ],
        "properties": {
          "error_code": {
            "type": "integer",
            "const": 0
          },
          "error_message": {
            "type": "string",
            "const": ""
          },
          "succeed": {
            "type": "boolean",
            "const": true
          },
          "data": {
            "type": "object",
            "required": [
              "capability_version",
              "voices"
            ],
            "properties": {
              "capability_version": {
                "type": "string"
              },
              "voices": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/Voice"
                }
              }
            },
            "additionalProperties": true
          }
        },
        "additionalProperties": true
      },
      "Error": {
        "type": "object",
        "required": [
          "error_code",
          "error_message",
          "succeed",
          "data"
        ],
        "properties": {
          "error_code": {
            "type": "integer",
            "description": "业务错误码，不等于 HTTP 状态码。"
          },
          "error_message": {
            "type": "string"
          },
          "succeed": {
            "type": "boolean",
            "const": false
          },
          "data": {
            "type": "null"
          }
        },
        "additionalProperties": true
      },
      "SpeechStreamRequest": {
        "type": "object",
        "required": [
          "voice_id",
          "generate_text"
        ],
        "properties": {
          "voice_id": {
            "type": "string",
            "minLength": 1,
            "description": "从 GET /api/v1/tts/voices 当前响应选择 ready 或 preview 声线。去除首尾空白并转为小写。",
            "pattern": "\\S"
          },
          "generate_text": {
            "type": "string",
            "minLength": 1,
            "description": "去除首尾空白后必须含可朗读内容。最多 2000 加权字符，中文按 2、其余字符按 1；预处理展开后的执行文本也受限制，不能用 maxLength 表达该规则。",
            "x-weighted-max-characters": 2000,
            "pattern": "\\S"
          },
          "audio_format": {
            "type": "string",
            "default": "pcm",
            "enum": [
              "wav",
              "pcm",
              "pcm_s16le",
              "mp3",
              "opus",
              "ogg",
              "ogg_opus",
              "flac",
              ""
            ],
            "description": "默认PCM；支持PCM/MP3/Opus/FLAC增量。WAV收齐后返回，不是低首包流。"
          },
          "speed": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.5,
                "maximum": 2
              },
              {
                "type": "number",
                "const": 0
              }
            ],
            "default": 1,
            "description": "默认1；0等同默认。0.5–2倍速度，连续音频后处理保持音高；同步、流式和Jobs一致。"
          },
          "request_id": {
            "type": "string",
            "description": "可选追踪标识；去除首尾空白后最多160个ASCII字符，首字符须为字母或数字，后续仅字母、数字、_ . : -，否则400；省略或空串由服务端生成。不是生成或计费幂等键，重复请求可能再次生成和计费；以X-Request-Id为准。",
            "maxLength": 160,
            "pattern": "^([A-Za-z0-9][A-Za-z0-9_.:-]{0,159})?$"
          },
          "style_level": {
            "type": "string",
            "enum": [
              "",
              "L1",
              "L2",
              "L3",
              "L4"
            ],
            "description": "省略或空串自动选择；非空手动选择 L1–L4。实际等级见 selected_style 或 X-Selected-Style。"
          },
          "ref_audio_url": {
            "type": "string",
            "const": "",
            "deprecated": true,
            "description": "系统声线接口不支持自定义参考音频，请省略此字段。"
          },
          "ref_text": {
            "type": "string",
            "const": "",
            "deprecated": true,
            "description": "系统声线接口不支持自定义参考文本，请省略此字段。"
          },
          "stream_format": {
            "type": "string",
            "enum": [
              "audio",
              "sse",
              ""
            ],
            "default": "audio",
            "description": "audio为原始音频；sse为audio/done/error事件，只有done表示完整成功。"
          }
        },
        "additionalProperties": false,
        "description": "系统声线请求；最大2000加权字符。禁止自定义参考音频。未知字段不属于合同。"
      },
      "SpeechJobRequest": {
        "type": "object",
        "required": [
          "voice_id",
          "generate_text"
        ],
        "properties": {
          "voice_id": {
            "type": "string",
            "minLength": 1,
            "description": "从 GET /api/v1/tts/voices 当前响应选择 ready 或 preview 声线。去除首尾空白并转为小写。",
            "pattern": "\\S"
          },
          "generate_text": {
            "type": "string",
            "minLength": 1,
            "description": "去除首尾空白后必须含可朗读内容。最多 2000 加权字符，中文按 2、其余字符按 1；预处理展开后的执行文本也受限制，不能用 maxLength 表达该规则。",
            "x-weighted-max-characters": 2000,
            "pattern": "\\S"
          },
          "audio_format": {
            "type": "string",
            "enum": [
              "wav",
              "mp3",
              "opus",
              "flac"
            ],
            "default": "wav"
          },
          "speed": {
            "anyOf": [
              {
                "type": "number",
                "minimum": 0.5,
                "maximum": 2
              },
              {
                "type": "number",
                "const": 0
              }
            ],
            "default": 1,
            "description": "默认1；0等同默认。0.5–2倍速度，连续音频后处理保持音高；同步、流式和Jobs一致。"
          },
          "request_id": {
            "type": "string",
            "description": "可选追踪标识；去除首尾空白后最多160个ASCII字符，首字符须为字母或数字，后续仅字母、数字、_ . : -，否则400；省略或空串由服务端生成。不是生成或计费幂等键，重复请求可能再次生成和计费；以X-Request-Id为准。",
            "maxLength": 160,
            "pattern": "^([A-Za-z0-9][A-Za-z0-9_.:-]{0,159})?$"
          },
          "style_level": {
            "type": "string",
            "enum": [
              "",
              "L1",
              "L2",
              "L3",
              "L4"
            ],
            "description": "省略或空串自动选择；非空手动选择 L1–L4。实际等级见 selected_style 或 X-Selected-Style。"
          },
          "ref_audio_url": {
            "type": "string",
            "const": "",
            "deprecated": true,
            "description": "系统声线接口不支持自定义参考音频，请省略此字段。"
          },
          "ref_text": {
            "type": "string",
            "const": "",
            "deprecated": true,
            "description": "系统声线接口不支持自定义参考文本，请省略此字段。"
          }
        },
        "additionalProperties": false,
        "description": "系统声线请求；最大2000加权字符。禁止自定义参考音频。未知字段不属于合同。"
      },
      "Job": {
        "type": "object",
        "required": [
          "job_id",
          "status",
          "voice_id",
          "audio_format"
        ],
        "properties": {
          "job_id": {
            "type": "string",
            "format": "uuid"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "synthesizing",
              "uploading",
              "retry_wait",
              "succeeded",
              "failed",
              "canceled",
              "delete_pending"
            ]
          },
          "voice_id": {
            "type": "string"
          },
          "audio_format": {
            "type": "string"
          },
          "billing_operation_id": {
            "type": "string"
          },
          "selected_style": {
            "type": "string"
          },
          "requested_style": {
            "type": "string"
          },
          "style_source": {
            "type": "string"
          },
          "asset": {
            "type": "object",
            "description": "成功后的音频格式、时长、SHA256等；下载用单独audio入口。"
          }
        }
      }
    },
    "responses": {
      "Status400": {
        "description": "参数、文本或所选能力不符合要求。修正请求后再提交。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Status401": {
        "description": "X-API-Key 缺失、无效或已吊销。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Status402": {
        "description": "账户余额不足。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Status403": {
        "description": "账户或所选声线不可用。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Status429": {
        "description": "请求频率或并发容量受限。不要无限重试。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Status500": {
        "description": "服务内部错误。生成结果与计费状态可能需要核对。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Status503": {
        "description": "鉴权依赖不可用，或合成服务暂时繁忙/不可用。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          },
          "Retry-After": {
            "description": "鉴权存储异常时返回 1 秒；其他 503 不保证此头。遵守该头不意味着合成重试具有计费幂等性。",
            "schema": {
              "type": "string",
              "examples": [
                "1"
              ]
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Status504": {
        "description": "处理超时；结果不明，不能据此假定未计费。",
        "headers": {
          "X-Request-Id": {
            "description": "进入合成服务后产生的请求标识；参数解码或鉴权失败时可能没有。",
            "schema": {
              "type": "string"
            }
          },
          "X-Trace-Id": {
            "description": "服务端追踪标识，可能缺省。",
            "schema": {
              "type": "string"
            }
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
