# 即刻Router Jike AI音乐生成 API 接口文档：异步轮询与参考音频仿写全流程

- Link: https://routellm.cn/97.html
- Published: 2026-10-17T00:33:19+08:00
- Author: 17610401733

## 目录

 1.  [一、概览：5 个模型与两条调用主线](https://routellm.cn/97.html#s1)
 2.  [二、接入信息：Base URL、鉴权与网关版本](https://routellm.cn/97.html#s2)
 3.  [三、模型清单与能力对照表](https://routellm.cn/97.html#s3)
 4.  [四、⚠️ 协议要求：为什么生成类必须走 /v1/responses](https://routellm.cn/97.html#s4)
 5.  [五、快速开始：最小可运行的生成与轮询](https://routellm.cn/97.html#s5)
 6.  [六、接口 1：创建生成任务 POST /v1/responses](https://routellm.cn/97.html#s6)
 7.  [七、接口 2：查询任务结果 GET /v1/responses/{id}](https://routellm.cn/97.html#s7)
 8.  [八、接口 3：上传参考音频 POST /v1/videos](https://routellm.cn/97.html#s8)
 9.  [九、接口 4：原生路由（调试用）](https://routellm.cn/97.html#s9)
 10. [十、音频产物下载与上游原始地址](https://routellm.cn/97.html#s10)
 11. [十一、状态机与轮询策略](https://routellm.cn/97.html#s11)
 12. [十二、参数约束速查表](https://routellm.cn/97.html#s12)
 13. [十三、错误码与报错文案对照](https://routellm.cn/97.html#s13)
 14. [十四、计费：按 action + clips 计算](https://routellm.cn/97.html#s14)
 15. [十五、已知限制与注意事项](https://routellm.cn/97.html#s15)
 16. [十六、完整可运行示例（Node.js / Python / curl）](https://routellm.cn/97.html#s16)
 17. [十七、变更记录与官方文档说明](https://routellm.cn/97.html#s17)

## 一、概览：5 个模型与两条调用主线

本文档描述通过即刻 Router 网关调用（Jike）[音乐生成](https://routellm.cn/tag/%e9%9f%b3%e4%b9%90%e7%94%9f%e6%88%90)
模型的完整方式。所有字段名、响应结构、错误文案均来自实测，对应网关渠道插件 `jike@
1.2.4`。

网关对外提供音乐模型，按调用形态分成两类：生成类走 Responses 协议、是异步任务，必须
轮询；上传类是 multipart 同步接口。

| 形态 | 模型 | 入口 | 是否需要轮询 | 
| 生成类（异步任务） | `jike_music`、`jike_reference`、`jike_instrumental`、`jike_lyric` | `POST /v1/responses` | 需要（歌词秒级，其余 1~5 分钟） | 
| 上传类（同步） | `jike_upload` | `POST /v1/videos`（multipart） | 不需要 |

两条主线可以概括成下面两个流程：

    ```gl
    生成线：
    POST /v1/responses          → 拿到 id（resp_ 前缀）
    GET  /v1/responses/{id}     → 每 2~5 秒轮询，直到 status=completed
                                → 从 output[0].content[0].text 取歌词
                                → 从 output[0].content[1..N].text 取 <audio src="..."> 并解析地址

    上传线（为仿写准备参考音频）：
    POST /v1/videos (multipart) → 拿到 id（注意：这里没有 upload_id）
    GET  /v1/videos/{id}        → 取 upload_id
                                → 作为 jike_reference 的 reference_audio 使用
    ```

换言之，`/v1/responses` 负责所有生成动作，`/v1/videos` 负责文件上传。模型之间的差异
不再靠 endpoint 区分，而是靠顶层 `model` 字段加 `metadata` 中的参数区分。

## 二、接入信息：Base URL、鉴权与网关版本

| 项 | 值 | 
| Base URL | `https://api.routellm.cn` | 
| 备用域名 | `https://router.wx173.cn`（行为完全一致，可互换使用） | 
| 鉴权 | `Authorization: Bearer <你的 API Key>` | 
| 请求 Content-Type | `application/json`；**上传接口例外**，为 `multipart/form-data` | 
| 模型分组 | 「音乐生成」 | 
| 网关版本 | `v1.0.0-rc.44` |

`GET /v1/models` 可以列出全部可用模型，但请特别注意：**该接口返回的模型列表不能作为「
这个模型能不能用」的判据**。它既不反映协议入口（`supported_endpoint_types` 字段不可
信），也可能残留已经下架、实际调用会失败的模型。判定可用性请以本文第 3 节的模型表
为准。

## 三、模型清单与能力对照表

| 模型名 | 能力 | 入口 | 同步/异步 | 可用版本 | 
| `jike_music` | 提示词生成歌曲 | `POST /v1/responses` | 异步，约 90~170s/首 | `v4.5`（默认）、`v4.0`、`v3.5` | 
| `jike_reference` | 仿写歌曲（给参考音频） | `POST /v1/responses` | 异步，约 150~240s | `v3.5`（仅此一个） | 
| `jike_instrumental` | 生成纯音乐 | `POST /v1/responses` | 异步，约 160s | `v4.5`（默认）、`v4.0` | 
| `jike_lyric` | 生成歌词 | `POST /v1/responses` | 准同步（秒级返回） | 无版本概念 | 
| `jike_upload` | 上传音频文件 | `POST /v1/videos` | 同步，< 5s | 无版本概念 |

可以拿来做超时配置的实测耗时：歌词 **7s**；纯音乐 **161s**；歌曲 `n=2` 两首合计约**
270s**（首 136s、次 170s）；仿写 `n=2` 约 **150~240s**。**请把客户端超时设到 ≥ 5
分钟**，否则容易在任务已经成功时被本地超时打断，白白浪费一次计费。

## 四、⚠️ 协议要求：为什么生成类必须走 /v1/responses

### 4.1 用 /v1/chat/completions 会得到误导性的 503

该渠道插件只声明了两个协议入口：`openai_responses` 与 `openai_video`，**没有 chat
入口**。如果用 `/v1/chat/completions` 调用，5 个模型会**全部**返回：

    ```gl
    HTTP 503
    {"error":{"code":"model_not_found",
      "message":"No available channel for model jike_music under group 音乐生成 (distributor)"}}
    ```

**这是假象。**渠道本身是健康的，只是没有 chat 路由。看到这句话时不要判断成渠道故障、
也不要急着换 key，把入口换成 `POST /v1/responses` 即可。

同理，`GET /v1/models` 里 `supported_endpoint_types: ["openai"]` 这个字段也不可信——
实际必须走 Responses 协议。

### 4.2 路由速查表

| 用途 | 正确入口 | 
| 生成歌曲 / 仿写 / 纯音乐 / 歌词 | `POST /v1/responses` | 
| 查询生成进度与结果 | `GET /v1/responses/{id}` | 
| 上传音频文件 | `POST /v1/videos`（`model=jike_upload` + `file` + `upload_type`） | 
| 取上传得到的 `upload_id` | `GET /v1/videos/{id}` | 
| 调试：看上游原文 | `GET /jike/fetch/{task_id}` |

### 4.3 顶层 model 与 metadata.model 的区别（最容易搞错）

 * 顶层 `model`：**网关模型名**，必须是 `jike_music` / `jike_reference` / `jike_instrumental`/`
   jike_lyric` 之一。
 * `metadata.model`：**厂商版本号**，例如 `"v4.5"` / `"v4.0"` / `"v3.5"`。**版本
   只能通过这里指定**，顶层没有版本字段。

不传 `metadata.model` 时使用各 action 的默认版本：`jike_music` → `v4.5`，`jike_reference`
→ `v3.5`，`jike_instrumental` → `v4.5`。

> ⚠️ 如果在 `metadata.model` 里误传了模型名（例如 `"jike_music"`），插件会识别出来
> 并**回退到默认版本，不会报错**。也就是说写错了不报错、结果和你想的不一样，这类
> 静默回退是排查成本最高的一种坑。

## 五、快速开始：最小可运行的生成与轮询

生成一首歌（`n=1`），创建任务：

    ```gl
    curl -X POST "https://api.routellm.cn/v1/responses" \
      -H "Authorization: Bearer sk-xxxxxxxx" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "jike_music",
        "input": "轻快的夏日流行，关于海边和汽水",
        "background": true,
        "metadata": { "model": "v4.5", "n": 1 }
      }'
    ```

HTTP 200 返回（任务已受理，`status` 为 `in_progress`）：

    ```gl
    {
      "id": "resp_ze8v5S5amU9JR45XRP4IxEaRmVborLEn",
      "object": "response",
      "model": "jike_music",
      "status": "in_progress",
      "created_at": 1792167363,
      "completed_at": null,
      "background": true,
      "error": null,
      "incomplete_details": null,
      "output": [],
      "usage": null,
      "metadata": {
        "retrieval_path": "/v1/responses/resp_ze8v5S5amU9JR45XRP4IxEaRmVborLEn",
        "task_id": "task_ze8v5S5amU9JR45XRP4IxEaRmVborLEn",
        "task_status": "in_progress"
      }
    }
    ```

然后每 2~5 秒轮询一次（用返回的 `id`）：

    ```gl
    curl "https://api.routellm.cn/v1/responses/resp_ze8v5S5amU9JR45XRP4IxEaRmVborLEn" \
      -H "Authorization: Bearer sk-xxxxxxxx"
    ```

等到 `status` 变成 `completed`，`output[0].content` 里就有歌词和音频地址了。注意：**
轮询必须串行**，多任务同时轮询会触发限流（见第 11 节）。

## 六、接口 1：创建生成任务 POST /v1/responses

    ```gl
    POST https://api.routellm.cn/v1/responses
    Authorization: Bearer <API Key>
    Content-Type: application/json
    ```

### 6.1 请求体字段总表

| 字段 | 类型 | 必填 | 说明 | 
| `model` | string | 是 | 网关模型名：`jike_music` / `jike_reference` / `jike_instrumental` / `jike_lyric` | 
| `input` | string | array | 是* | 生成提示词。字符串直接作为 prompt；也可传 Responses 风格的消息数组 | 
| `background` | boolean | 建议 | 传 `true`，异步任务模式 | 
| `metadata` | object | 建议 | 任务参数载体，版本、首数、歌词、参考音频都放这里 | 
| `prompt` | string | — | 顶层兜底写法，等价于 `metadata.prompt` | 
| `lyric` | string | — | 顶层兜底写法，等价于 `metadata.lyric` | 
| `n` | number | — | 顶层兜底写法，等价于 `metadata.n` | 
| `similarity` | number | — | 顶层兜底写法，等价于 `metadata.similarity` | 
| `reference_audio` | object | string | — | 顶层兜底写法，等价于 `metadata.reference_audio` | 
| `instructions` / `temperature` / `tools` 等 | — | — | 会被忽略，无副作用 |

*`input` 是必填的替代来源：只要有 `input`、`metadata.prompt`、顶层 `prompt` 或 `
metadata.lyric` 任意一个提供内容即可；全空时报 `input is required`。

> ⚠️ `metadata` 里**未被识别的键会被静默忽略**，不会报错。参数拼错名字时不会收到
> 任何提示，只会按默认值跑，务必对照本节表格逐字核对。

### 6.2 metadata 字段详解

| 字段 | 类型 | 适用模型 | 说明 | 
| `prompt` | string | music / reference / instrumental / lyric | 提示词（风格、主题、情绪等） | 
| `lyric` | string | music / reference | 自定义歌词。music：prompt 与 lyric 至少给一个（可同时给）；reference：prompt 与 lyric 至少给一个 | 
| `model` | string | music / reference / instrumental | 厂商版本号，见第 12 节 | 
| `n` | number | music / reference / instrumental | 生成首数，`1` 或 `2`，**不传默认 2** | 
| `similarity` | number | 仅 `jike_reference` | 与参考音频的相似度，只能取 `0.2` / `0.8` / `1.3` / `1.5` | 
| `reference_audio` | object | string | 仅 `jike_reference` | 参考音频，**必填**，三种写法见下 |

### 6.3 reference_audio 的三种写法

**写法 A：官方标准形式**

    ```gl
    { "audio_type": "upload_id", "audio_content": "beb6a2ab-347f-4416-a3f2-c5d6bf3b698d" }
    ```

`audio_type` 的三个取值：

| audio_type | audio_content 内容 | 说明 | 
| `upload_id` | 上传接口返回的 upload_id | 最常用，先调 `jike_upload` 拿 ID | 
| `audio_id` | 平台歌曲 ID | 直接引用平台上的既有歌曲，无需自己上传 | 
| `audio_url` | 公网可访问的音频 URL | 需上游能直接拉取 |

**写法 B：简写对象**

    ```gl
    { "upload_id": "beb6a2ab-347f-4416-a3f2-c5d6bf3b698d" }
    { "audio_id":   "12345" }
    { "audio_url":  "https://example.com/ref.mp3" }
    ```

**写法 C：裸字符串**

    ```gl
    "beb6a2ab-347f-4416-a3f2-c5d6bf3b698d"
    ```

裸字符串以 `http://` 或 `https://` 开头时按 `audio_url` 处理，否则按 `upload_id`
处理。对象结构不对时会报 `reference_audio must provide audio_type plus audio_content,
or one of upload_id / audio_id / audio_url`。

### 6.4 四个生成模型的请求示例

**`jike_music`：提示词生成歌曲**

    ```gl
    {
      "model": "jike_music",
      "input": "轻快的夏日流行，关于海边和汽水",
      "background": true,
      "metadata": { "model": "v4.5", "n": 2 }
    }
    ```

带自定义歌词（此时 `prompt` 可省，也可以同时给）：

    ```gl
    {
      "model": "jike_music",
      "background": true,
      "metadata": {
        "model": "v4.5",
        "lyric": "[verse]\n夏天的风吹过来\n[chorus]\n我们一起去看海",
        "n": 1
      }
    }
    ```

**`jike_instrumental`：生成纯音乐**

    ```gl
    {
      "model": "jike_instrumental",
      "input": "温暖的钢琴独奏，慢速，适合深夜",
      "background": true,
      "metadata": { "model": "v4.5", "n": 1 }
    }
    ```

> ⚠️ 纯音乐**没有 `lyric` 参数**，只接受 `prompt`；版本只支持 `v4.5` / `v4.0`，传`
> v3.5` 会直接报 `model must be v4.5 or v4.0 for this action; got v3.5`。

**`jike_reference`：仿写歌曲**

    ```gl
    {
      "model": "jike_reference",
      "input": "改成更轻快的民谣风格",
      "background": true,
      "metadata": {
        "model": "v3.5",
        "reference_audio": {
          "audio_type": "upload_id",
          "audio_content": "beb6a2ab-347f-4416-a3f2-c5d6bf3b698d"
        },
        "similarity": 1.3,
        "n": 2
      }
    }
    ```

> ⚠️ 仿写**只支持 `v3.5`**；`reference_audio` 必填；`similarity` 只能取 `0.2` / `
> 0.8` / `1.3` / `1.5`，传 `1.2` 这类中间值会被拒。

**`jike_lyric`：生成歌词**

    ```gl
    {
      "model": "jike_lyric",
      "input": "写一首关于山顶日出的短歌",
      "background": true
    }
    ```

> ⚠️ 歌词接口**没有版本、没有 `n`**；`prompt` 必填且上限 **2000 字**。返回的是带`[
> verse]` / `[chorus]` / `[bridge]` 等结构标记的完整歌词。

### 6.5 创建响应字段说明

| 字段 | 说明 | 
| `id` | 响应 ID，**轮询时用它**（`resp_` 前缀） | 
| `metadata.task_id` | 内部任务 ID（`task_` 前缀），用于原生路由 `/jike/fetch/{task_id}` | 
| `metadata.task_status` | 细粒度状态：`queued` / `in_progress` / `completed` / `failed` | 
| `status` | 对外状态，轮询以它判终态：`in_progress` → `completed` / `failed` | 
| `usage` | 恒为全 0（本渠道按「首数」计费，不走 token 计费） |

## 七、接口 2：查询任务结果 GET /v1/responses/{id}

    ```gl
    curl "https://api.routellm.cn/v1/responses/resp_xxx" \
      -H "Authorization: Bearer sk-xxxxxxxx"
    ```

参数就是创建时返回的 `id`（`resp_xxx`），**没有 query 参数**。

### 7.1 进行中的返回

    ```gl
    {
      "id": "resp_xxx",
      "status": "in_progress",
      "output": [],
      "metadata": { "task_status": "in_progress", "task_id": "task_xxx" }
    }
    ```

### 7.2 已完成（歌曲类）的完整返回

    ```gl
    {
      "id": "resp_BPYcrp7pPN1HJwEBTrA6VLdqJgSDjiz3",
      "object": "response",
      "model": "jike_music",
      "status": "completed",
      "created_at": 1792166880,
      "metadata": {
        "retrieval_path": "/v1/responses/resp_BPYcrp7pPN1HJwEBTrA6VLdqJgSDjiz3",
        "task_id": "task_BPYcrp7pPN1HJwEBTrA6VLdqJgSDjiz3",
        "task_status": "completed",
        "vendor": "jike"
      },
      "output": [
        {
          "id": "item_task_BPYcrp7pPN1HJwEBTrA6VLdqJgSDjiz3_0",
          "type": "message",
          "status": "completed",
          "role": "assistant",
          "content": [
            {
              "id": "content_task_BPYcrp7pPN1HJwEBTrA6VLdqJgSDjiz3_0_0",
              "type": "output_text",
              "text": "属于我们的夏天\n\n[Intro]\n\n[Verse 1]\n阳光落在肩上\n...",
              "annotations": [],
              "logprobs": []
            },
            {
              "id": "content_task_BPYcrp7pPN1HJwEBTrA6VLdqJgSDjiz3_0_1",
              "type": "output_text",
              "text": "<audio controls src=\"https://api.routellm.cn/v1/tasks/task_BPYcrp7pPN1HJwEBTrA6VLdqJgSDjiz3/artifacts/audio-0f48f.../content?access=1BMFdejeTDFn...\"></audio>",
              "annotations": [],
              "logprobs": []
            }
          ]
        }
      ],
      "usage": {
        "input_tokens": 0,
        "output_tokens": 0,
        "total_tokens": 0
      }
    }
    ```

### 7.3 output[0].content 的结构规则

`output` 数组**恒为 1 个 message 元素**，真正的内容都在 `output[0].content[]` 里，
按类型分条：

| 位置 | 内容 | 说明 | 
| `content[0]` | 歌词文本 | 形如 `标题\n\n歌词正文`；多个曲目之间用空行分隔。无歌词时是占位文案 `Music generation completed.` | 
| `content[1..N]` | 音频标签 | 每个成功生成的曲目一条，格式固定为 HTML 标签字符串 |

关于 `content[0]` 的格式差异：`jike_lyric` 返回的是 `标题\n\n歌词正文` 的纯文本；`
jike_music` / `jike_instrumental` / `jike_reference` 则按曲目拼接，每首为 `标题\
n歌词`，曲目之间空行分隔。

音频条目的格式固定为：

    ```gl
    <audio controls src="https://api.routellm.cn/v1/tasks/{task_id}/artifacts/audio-{sha256}/content?access={token}"></audio>
    ```

> ⚠️ **这是一个 HTML 片段字符串，不是 JSON 对象**，需要自己解析出 `src`。最常见的
> 错误是：把整个响应 `JSON.stringify` 之后再正则匹配 `src="..."`——引号会被转义成`\"`，
> 永远匹配不到。正确做法是**在已解析的对象上取 `content[].text` 再匹配**：

    ```gl
    const urls = [];
    for (const item of resp.output || []) {
      for (const c of item.content || []) {
        for (const m of String(c.text).matchAll(/src="([^"]+)"/g)) urls.push(m[1]);
      }
    }
    // urls[0] 就是第一个音频地址
    ```

### 7.4 已完成（歌词类）的返回

    ```gl
    {
      "id": "resp_ze8v5S5amU9JR45XRP4IxEaRmVborLEn",
      "status": "completed",
      "model": "jike_lyric",
      "metadata": { "task_status": "completed", "vendor": "jike" },
      "output": [
        {
          "content": [
            {
              "type": "output_text",
              "text": "山顶日出\n\n[verse]\n夜色还挂在肩头\n...\n[outro]\n日出升起来\n我也醒过来"
            }
          ],
          "role": "assistant",
          "status": "completed",
          "type": "message"
        }
      ]
    }
    ```

歌词类 `content` **只有 1 条**（纯文本，没有音频条目），所以不能对 `jike_lyric` 
的结果做 `content[1]` 取值。

## 八、接口 3：上传参考音频 POST /v1/videos

上传用于给 `jike_reference`（仿写歌曲）提供参考音频。

### 8.1 提交上传

    ```gl
    POST https://api.routellm.cn/v1/videos
    Authorization: Bearer <API Key>
    Content-Type: multipart/form-data
    ```

| 字段 | 类型 | 必填 | 说明 | 
| `model` | text | 是 | 固定 `jike_upload` | 
| `file` | file | 是 | 音频文件，字段名必须是 `file` | 
| `upload_type` | text | — | 只能填 `reference`（不填默认 `reference`） |

    ```gl
    curl -X POST "https://api.routellm.cn/v1/videos" \
      -H "Authorization: Bearer sk-xxxxxxxx" \
      -F "model=jike_upload" \
      -F "file=@./ref.mp3" \
      -F "upload_type=reference"
    ```

HTTP 200 响应（**注意这里没有 `upload_id`**）：

    ```gl
    {
      "id": "task_rImcARFu4Sl3g2OsPrYCGYjVrcTuUWOv",
      "object": "video",
      "model": "jike_upload",
      "status": "completed",
      "progress": 0,
      "created_at": 1792167370,
      "completed_at": 1792167370
    }
    ```

### 8.2 ⚠️ 关键坑：upload_id 不在 POST 响应里

> ⚠️ 网关按 video 的 schema 白名单过滤了 create 路径的输出，插件自定义字段会被丢弃，
> 所以 `upload_id` 不会出现在 POST 的响应中。**必须用 `id` 再查一次 `GET /v1/videos/{
> id}` 才能拿到 `upload_id`。**一个可用的判据是：POST 响应里 `progress` 是 `0`，
> 而插件内部计算的是 `100`——两者不一致，说明 render 结果被 schema 覆盖过了。

    ```gl
    curl "https://api.routellm.cn/v1/videos/task_rImcARFu4Sl3g2OsPrYCGYjVrcTuUWOv" \
      -H "Authorization: Bearer sk-xxxxxxxx"
    ```

    ```gl
    {
      "id": "task_rImcARFu4Sl3g2OsPrYCGYjVrcTuUWOv",
      "object": "video",
      "model": "jike_upload",
      "status": "completed",
      "progress": 0,
      "created_at": 1792167370,
      "completed_at": 1792167370,
      "upload_id": "beb6a2ab-347f-4416-a3f2-c5d6bf3b698d"
    }
    ```

### 8.3 把 upload_id 用于 jike_reference

    ```gl
    {
      "model": "jike_reference",
      "input": "改成轻快的民谣风格",
      "background": true,
      "metadata": {
        "model": "v3.5",
        "reference_audio": { "audio_type": "upload_id", "audio_content": "beb6a2ab-347f-4416-a3f2-c5d6bf3b698d" },
        "similarity": 1.3,
        "n": 2
      }
    }
    ```

### 8.4 文件约束

 * 格式：MP3 / WAV
 * 大小：≤ 10 MB（官方限制）
 * 上传**不计费**
 * `upload_type` 只认 `reference`，传 `extend` 或 `inspiration` 会在网关侧被拒（
   上游也只认 `reference`）

## 九、接口 4：原生路由（调试用）

网关还暴露出插件自带的路由，鉴权和计费与主接口相同，主要用于排查问题时看上游原文。

> ⚠️ 这两个路由**只接受 JSON**（宿主未对它们开放 multipart），上传不要走这里；`prompt`
> 等参数是上游原样格式，不是 Responses 格式。

### 9.1 提交：POST /jike/submit/{action}

`{action}` 取值：`music` / `reference` / `instrumental` / `lyric` / `upload`。

    ```gl
    curl -X POST "https://api.routellm.cn/jike/submit/lyric" \
      -H "Authorization: Bearer sk-xxxxxxxx" \
      -H "Content-Type: application/json" \
      -d '{"prompt":"写一首关于春日清晨的短歌"}'
    ```

成功响应，`data` 是任务 ID；上传 action 时 `data` 直接就是 `upload_id`：

    ```gl
    { "code": "success", "message": "", "data": "task_BSKpE6avoA2sVx2gMTlw9htG2JoQezse" }
    ```

失败响应：

    ```gl
    { "code": "invalid_request", "data": null, "message": "<具体原因>" }
    ```

例如传非法版本：

    ```gl
    {
      "code": "invalid_request",
      "data": null,
      "message": "plugin jike@1.2.4 hook buildSubmitRequest failed: Error: model must be v3.5 or v4.5 or v4.0 for this action; got v4.4 at resolveVersion (jike.js:373:11)"
    }
    ```

> 这条报错里带出了**插件版本号** `jike@1.2.4`，是确认服务端插件版本的可靠方法。

### 9.2 查询：GET /jike/fetch/{task_id}

    ```gl
    curl "https://api.routellm.cn/jike/fetch/task_xxx" \
      -H "Authorization: Bearer sk-xxxxxxxx"
    ```

返回上游原文快照，顶层含 `task_id` / `platform` / `status` / `progress` / `fail_reason`
与若干时间戳（`created_at`、`updated_at`、`submit_time`、`finish_time`）：

    ```gl
    {
      "code": "success",
      "message": "",
      "data": {
        "task_id": "task_oO69gELygIMHOQwxZVwGRDSZYaalXxx3",
        "platform": "jike",
        "status": "SUCCESS",
        "progress": "100%",
        "fail_reason": "",
        "created_at": 1792162852,
        "updated_at": 1792163136,
        "submit_time": 1792162852,
        "finish_time": 1792163136,
        "data": {
          "id": "task_oO69gELygIMHOQwxZVwGRDSZYaalXxx3",
          "task_type": "normal",
          "create_at": 1792162852,
          "choices": [
            {
              "id": "82c14a22-7334-4cb9-8692-fd2f8778d15c",
              "status": "done",
              "title": "夏日模样",
              "lyric": "[Intro]\n阳光洒在窗台上\n...",
              "audio_url": "https://api-cdn.yinchaoyongxian.com/openapi/public/song/39859e46c1954e06bb10ae45869dbe6a.mp3",
              "pipe_url": "",
              "duration": 136.02,
              "size": 5442182,
              "error": "",
              "error_code": 0,
              "create_at": 1792162852,
              "finish_at": 1792163044
            }
          ]
        }
      }
    }
    ```

`data.data` 是上游原文快照，`choices[]` 中每个曲目对象包含：

| 字段 | 说明 | 
| `task_type` | `normal`（提示词生成）/ `reference`（仿写） | 
| `choices[].id` | 曲目 ID | 
| `choices[].status` | `pending` / `running` / `stream` / `done` / `fail` / `cancelled` | 
| `choices[].title` | 歌曲标题 | 
| `choices[].lyric` | 完整歌词 | 
| `choices[].audio_url` | 上游原始 CDN 地址（`api-cdn.yinchaoyongxian.com`） | 
| `choices[].pipe_url` | 流式地址，`stream` 状态时可能可用 | 
| `choices[].duration` | 时长（秒，浮点） | 
| `choices[].size` | 文件大小（字节） | 
| `choices[].error` / `error_code` | 失败原因 |

调试价值在于：这里能看到上游原始地址和真实字节数，便于核对网关产物是否一致。

## 十、音频产物下载与上游原始地址

### 10.1 网关代理地址（推荐）

从 `GET /v1/responses/{id}` 的 `content[].text` 里解析出 `<audio src="...">`：

    ```gl
    https://api.routellm.cn/v1/tasks/{task_id}/artifacts/audio-{sha256}/content?access={token}
    ```

 * 直接 `GET` 该 URL 即可下载，**必须带上完整的 `access` 查询参数**（这是签名，缺失
   或过期会返回 403）
 * `Content-Type` 为 `audio/mpeg`
 * 实测样例：`6,618,737` 字节，文件头 `ID3`

    ```gl
    curl -L -o out.mp3 "https://api.routellm.cn/v1/tasks/task_xxx/artifacts/audio-yyy/content?access=zzz"
    ```

### 10.2 上游原始地址（调试用）

从 `GET /jike/fetch/{task_id}` 的 `data.data.choices[].audio_url` 取，形如 `https://
api-cdn.yinchaoyongxian.com/openapi/public/song/{md5}.mp3`。两个地址指向同一份文件，
可以用 `size` 字段逐字节核对是否一致。

## 十一、状态机与轮询策略

### 11.1 状态流转

上游曲目级状态（`choices[].status`）：

    ```gl
    pending ──▶ running ──▶ stream ──▶ done
                     │
                     ├──▶ fail
                     └──▶ cancelled
    ```

网关任务级聚合规则：

| 条件 | 网关状态 | 对外 status | 
| 全部曲目到终态，且 ≥ 1 首 `done` | `SUCCESS` | `completed` | 
| 全部曲目到终态，且 0 首 `done` | `FAILURE` | `failed` | 
| 有曲目在 `running` / `stream` | `IN_PROGRESS` | `in_progress` | 
| 其余（都在排队） | `QUEUED` | `in_progress` |

> ⚠️ **部分成功也算成功**：`n=2` 时若只成 1 首，整体仍然是 `completed`，失败原因
> 写在内部 `reason` 里。另外，`cancelled` 与 `fail` 同为终态，且都算失败。

### 11.2 轮询建议

| 项 | 建议值 | 
| 轮询间隔 | 2~5 秒（官方建议） | 
| 超时上限 | ≥ 300 秒（歌曲 `n=2` 实测约 270s） | 
| 并发 | **必须串行** |

> ⚠️ **429 Too many active task observations**：并发轮询多个任务会被拒。这是任务
> 观察并发限流，非常容易被误判为「任务挂了」。请对多个任务**串行轮询**，不要用 `
> Promise.all` 批量轮询。

### 11.3 各模型耗时基线

| 模型 | 实测耗时 | 
| `jike_lyric` | 约 3~7 秒 | 
| `jike_upload` | < 5 秒 | 
| `jike_instrumental` | 约 161 秒（n=1） | 
| `jike_music` | n=2：136s + 170s（两首先后完成）；n=1：约 94~117 秒 | 
| `jike_reference` | n=2：约 150~240 秒 |

## 十二、参数约束速查表

### 12.1 模型版本白名单与默认值

| 模型 | 允许版本 | 默认 | 
| `jike_music` | `v3.5`、`v4.5`、`v4.0` | `v4.5` | 
| `jike_instrumental` | `v4.5`、`v4.0` | `v4.5` | 
| `jike_reference` | `v3.5` | `v3.5` | 
| `jike_lyric` | —（无版本） | — |

`v4.0` 是官方 4.x 早期的别名，上游仍接受，作为兼容保留。**新接入请直接用 `v4.5`。**

### 12.2 字数上限

| 参数 | 模型 | 上限 | 
| `prompt` | `jike_lyric` | **2000 字** | 
| `prompt` | `jike_music` / `jike_reference`（v3.5） | 1000 字 | 
| `prompt` | `jike_music`（v4.5 / v4.0）、`jike_instrumental` | 3000 字 | 
| `lyric` | `jike_music` / `jike_reference`（v3.5） | 3000 字 | 
| `lyric` | `jike_music`（v4.5 / v4.0） | 5000 字 |

### 12.3 其他参数

| 参数 | 取值 | 默认 | 
| `n` | `1` 或 `2` | `2` | 
| `similarity`（仅 reference） | `0.2` / `0.8` / `1.3` / `1.5` | 不传则由上游决定 | 
| `audio_type` | `upload_id` / `audio_id` / `audio_url` | — | 
| `upload_type` | `reference` | `reference` | 
| 上传格式 / 大小 | MP3、WAV / ≤ 10 MB | — |

## 十三、错误码与报错文案对照

### 13.1 两种错误响应结构

标准路由（`/v1/responses`、`/v1/videos`）：

    ```gl
    {
      "error": {
        "code": "",
        "message": "prompt must be at most 2000 characters",
        "type": "new_api_error"
      }
    }
    ```

原生路由（`/jike/*`）：

    ```gl
    { "code": "invalid_request", "data": null, "message": "..." }
    ```

解析错误时要注意走的是哪条路由，两种结构的取值路径完全不同。

### 13.2 参数校验错误（HTTP 400，可直接回显给用户）

| 文案 | 触发条件 | 
| `input is required` | `input` / `prompt` / `lyric` 全未提供 | 
| `prompt or lyric is required` | `jike_music` / `jike_reference` 两者都没给 | 
| `prompt is required` | `jike_instrumental`、`jike_lyric` 未给 prompt | 
| `prompt must be at most 2000 characters` | 歌词 prompt 超过 2000 字 | 
| `prompt must be at most 3000 characters for v4.5` | 歌曲/纯音乐 prompt 超上限（文案含版本号） | 
| `lyric must be at most 5000 characters for v4.5` | 自定义歌词超上限 | 
| `model must be v3.5 or v4.5 or v4.0 for this action; got v4.4` | 版本不在白名单 | 
| `model must be v4.5 or v4.0 for this action; got v3.5` | 纯音乐不接受 v3.5 | 
| `model must be v3.5 for this action; got v4.5` | 仿写只接受 v3.5 | 
| `similarity must be 0.2, 0.8, 1.3 or 1.5` | `similarity` 传了非枚举值（如 `1.2`） | 
| `n must be 1 or 2` | `n` 超出范围或非整数 | 
| `reference_audio is required` | 仿写未提供参考音频 | 
| `reference_audio.audio_type must be upload_id, audio_id or audio_url` | `audio_type` 非法 | 
| `reference_audio must provide audio_type plus audio_content, or one of upload_id / audio_id / audio_url` | 参考音频对象结构不对 | 
| `upload_type must be "reference" (got "extend"); the upstream only accepts "reference"` | 上传类型非法 | 
| `a multipart file field named file is required` | 上传缺少 `file` 字段 | 
| `jike_upload requires a multipart body: POST /v1/videos with model=jike_upload, file=<audio> and upload_type=reference` | 用 JSON 调了上传接口 | 
| `input must be a string or array` | `input` 类型错误 | 
| `metadata must be an object` | `metadata` 类型错误 | 
| `model must be jike_music, jike_reference, jike_instrumental or jike_lyric (or a channel alias mapped to one of them)` | 顶层 `model` 不是这 4 个之一 | 
|  |  |

### 13.3 路由 / 渠道类错误

| HTTP | 文案 | 说明 | 
| 503 | `No available channel for model jike_xxx under group 音乐生成 (distributor)` | 协议不匹配（用了 `/v1/chat/completions`）或模型已下架。换成 `/v1/responses` | 
| 429 | `Too many active task observations` | 轮询并发过高，改为串行 | 
| 403 | 产物地址报错 | `access` 签名缺失或过期，重新取一次响应 |

> ⚠️ **注意 503 的误导性**：它长得像「渠道故障」，但对这 5 个模型而言，绝大多数情况
> 是**用错了协议**。建议排查顺序：① 确认走的是 `/v1/responses`？② 模型名是否拼对？
> ③ 最后再看渠道状态。

## 十四、计费：按 action + clips 计算

计费由网关按 `action` + `clips`（成功首数）计算，**不看 token**（响应里的 `usage`
恒为 0）。网关声明的计费表达式取自 `GET /api/pricing`：

| 模型 | 表达式 | 说明 | 
| `jike_music` | `0.15 + clips × 0.22` | clips = 实际 `done` 的首数 | 
| `jike_reference` | `0.15 + clips × 0.22` | 同上 | 
| `jike_instrumental` | `0.15 + clips × 0.22` | 同上 | 
| `jike_lyric` | `0.15 + clips × 0.22` | **clips 固定为 1** | 
| `jike_upload` | `clips × 0` | **免费** |

换算举例（按表达式单位）：

| 场景 | 计费 | 
| 歌曲 `n=1`，成功 | 0.37 | 
| 歌曲 `n=2`，两首都成功 | 0.59 | 
| 歌曲 `n=2`，只成功 1 首 | 0.37 | 
| 纯音乐 `n=1` | 0.37 | 
| 歌词 1 次 | 0.37 | 
| 上传 | 0 | 
| 任务失败 / 取消 | 0 |

要点：

 * **只按成功首数扣费**：`fail` / `cancelled` 的曲目不计入 `clips`
 * 扣费发生在任务到达终态**之后**
 * 具体金额换算（quota ↔ 货币）由站点 `quota_per_unit` 决定，请以站点账单页为准

    ```gl
    curl "https://api.routellm.cn/v1/dashboard/billing/usage?start_date=2026-10-01&end_date=2026-10-17" \
      -H "Authorization: Bearer sk-xxxxxxxx"
    ```

## 十五、已知限制与注意事项

| # | 限制 | 说明 | 
| 1 | 不支持 `/v1/chat/completions` | 会返回误导性的 503，必须用 `/v1/responses` | 
| 2 | 不支持流式 `stream` 边生成边播 | 上游 `pipe_url` 未被网关透传，只能在 `completed` 后拿成品 | 
| 3 | 不支持 `callback` 回调 | 官方支持回调地址，但网关不透传该参数，只能轮询 | 
| 4 | `/v1/videos` 的 POST 不返回 `upload_id` | 必须 `GET /v1/videos/{id}` 回查 | 
|  |  |  | 
| 6 | 上传不校验格式 / 体积 | 超过 10MB 时的报错文案不明确，请在客户端预校验 | 
| 7 | `/v1/models` 可能残留已下架模型 | 模型清单为缓存，以本文档的模型表为准 | 
| 8 | 轮询必须串行 | 并发会触发 `429 Too many active task observations` |

## 十六、完整可运行示例（Node.js / Python / curl）

### 16.1 Node.js：生成歌曲 → 串行轮询 → 下载保存

    ```gl
    const KEY = process.env.JIKE_API_KEY;
    const B = "https://api.routellm.cn";
    const H = { Authorization: "Bearer " + KEY };

    // 1) 创建任务
    const created = await fetch(B + "/v1/responses", {
      method: "POST",
      headers: { ...H, "Content-Type": "application/json" },
      body: JSON.stringify({
        model: "jike_music",
        input: "轻快的夏日流行，关于海边和汽水",
        background: true,
        metadata: { model: "v4.5", n: 1 },
      }),
    }).then(r => r.json());

    const id = created.id;
    console.log("任务已创建:", id);

    // 2) 串行轮询（务必串行，避免 429）
    let resp = created;
    for (let i = 0; i < 120; i++) {
      await new Promise(r => setTimeout(r, 3000));
      resp = await fetch(B + "/v1/responses/" + id, { headers: H }).then(r => r.json());
      console.log("状态:", resp.status, resp.metadata && resp.metadata.task_status);
      if (["completed", "failed", "cancelled", "incomplete"].includes(resp.status)) break;
    }
    if (resp.status !== "completed") throw new Error("任务失败: " + JSON.stringify(resp.error));

    // 3) 解析歌词与音频地址
    const lyrics = resp.output[0].content[0].text;
    const urls = [];
    for (const item of resp.output) {
      for (const c of item.content) {
        for (const m of String(c.text).matchAll(/src="([^"]+)"/g)) urls.push(m[1]);
      }
    }
    console.log("歌词:\n", lyrics);
    console.log("音频数:", urls.length);

    // 4) 下载（必须带完整 access 参数）
    const audio = await fetch(urls[0]);
    const buf = Buffer.from(await audio.arrayBuffer());
    require("node:fs").writeFileSync("song.mp3", buf);
    console.log("已保存 song.mp3:", buf.length, "字节");
    ```

### 16.2 Python：上传参考音频 → 回查 upload_id → 发起仿写 → 串行轮询

    ```gl
    import os, time, json, urllib.request

    KEY = os.environ["JIKE_API_KEY"]
    B = "https://api.routellm.cn"

    def req(path, data=None, method=None):
        r = urllib.request.Request(
            B + path,
            data=json.dumps(data).encode() if data is not None else None,
            headers={"Authorization": "Bearer " + KEY, "Content-Type": "application/json"},
            method=method,
        )
        with urllib.request.urlopen(r, timeout=60) as x:
            return json.loads(x.read().decode())

    # 1) 上传参考音频（multipart，用 requests 更方便）
    import requests
    up = requests.post(
        B + "/v1/videos",
        headers={"Authorization": "Bearer " + KEY},
        files={"file": ("ref.mp3", open("ref.mp3", "rb"), "audio/mpeg")},
        data={"model": "jike_upload", "upload_type": "reference"},
    ).json()

    # 2) POST 不返回 upload_id，必须回查
    upload_id = req("/v1/videos/" + up["id"])["upload_id"]
    print("upload_id =", upload_id)

    # 3) 发起仿写
    task = req("/v1/responses", {
        "model": "jike_reference",
        "input": "改成轻快的民谣风格",
        "background": True,
        "metadata": {
            "model": "v3.5",
            "reference_audio": {"audio_type": "upload_id", "audio_content": upload_id},
            "similarity": 1.3,
            "n": 1,
        },
    })
    print("任务:", task["id"])

    # 4) 串行轮询
    while True:
        time.sleep(5)
        r = req("/v1/responses/" + task["id"])
        print(r["status"], r["metadata"].get("task_status"))
        if r["status"] in ("completed", "failed"):
            break
    ```

### 16.3 curl 速查

    ```gl
    # 生成歌曲
    curl -X POST "$B/v1/responses" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
      -d '{"model":"jike_music","input":"夏日流行","background":true,"metadata":{"model":"v4.5","n":1}}'

    # 生成歌词
    curl -X POST "$B/v1/responses" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
      -d '{"model":"jike_lyric","input":"写一首关于秋天的短歌","background":true}'

    # 生成纯音乐
    curl -X POST "$B/v1/responses" -H "Authorization: Bearer $KEY" -H "Content-Type: application/json" \
      -d '{"model":"jike_instrumental","input":"温暖的钢琴独奏，慢速","background":true,"metadata":{"model":"v4.5","n":1}}'

    # 查询结果
    curl "$B/v1/responses/resp_xxx" -H "Authorization: Bearer $KEY"

    # 上传参考音频
    curl -X POST "$B/v1/videos" -H "Authorization: Bearer $KEY" \
      -F "model=jike_upload" -F "file=@./ref.mp3" -F "upload_type=reference"

    # 取 upload_id
    curl "$B/v1/videos/task_xxx" -H "Authorization: Bearer $KEY"

    # 看上游原文（调试）
    curl "$B/jike/fetch/task_xxx" -H "Authorization: Bearer $KEY"
    ```
