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

# MiniMax Speech 2.8 API：用预设音色合成语音

> MiniMax 文本转语音 API，支持 APIXO 预设 voice_id 以及自定义 MiniMax voice_id

## 概览

MiniMax Speech 2.8 是一种用于生成高质量语音的异步文本到语音模型。APIXO 通过记录的预设支持内置预设声音 `voice_id` 列表，也接受自定义 `voice_id` 创造的价值 [MiniMax Voice](https://apixo.ai/docs/zh/models/audio/minimax-voice.md)。

| 功能 | 值 |
| - | - |
| 模型 ID | `minimax-speech-2-8` |
| 模式 | `speech-turbo`, `speech-hd` |
| 内置预设音色 | 是的，通过文档中的预设 `voice_id` 列表 |
| 自定义音色 | 是 |
| 提示词长度 | 1 至 10000 个字符 |
| 发音词典格式 | `Alias/Pronunciation` |
| 速度范围 | `0.5`至`2.0` |
| 音量范围 | `0.1`至`10.0` |
| 音高范围 | `-12`至`12` |

> [!TIP]
>
> 有关完整的内置预设 `voice_id` 列表，请参阅 [MiniMax Speech 2.8 预设音色](https://apixo.ai/docs/zh/guides/minimax-speech-2-8-voices.md)。

## 接口与身份验证

API 基础地址：

```text theme={null}
https://api.apixo.ai/api/v1
```

| 方法 | 端点 | 用途 |
| - | - | - |
| `POST` | `/generateTask/minimax-speech-2-8` | 提交语音任务 |
| `GET` | `/statusTask/minimax-speech-2-8?taskId={taskId}` | 查询任务状态并获取结果 |

每个请求都必须携带 APIXO API 密钥：

```http theme={null}
Authorization: Bearer YOUR_API_KEY
```

提交任务时，还需要设置以下请求头：

```http theme={null}
Content-Type: application/json
```

## 异步请求示例

此最小请求提交语音任务并返回 `taskId`。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/minimax-speech-2-8" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "speech-hd",
      "voice_id": "preset_general_wise_woman",
      "prompt": "Hello, welcome to APIXO.",
      "format": "mp3"
    }
  }'
```

成功提交响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing"
  }
}
```

保存 `taskId`，后续轮询结果时需要用到它。

## 轮询结果

```bash theme={null}
curl -X GET "https://api.apixo.ai/api/v1/statusTask/minimax-speech-2-8?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
```

任务处理中的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "processing",
    "createTime": 1781502331739
  }
}
```

成功响应：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://file.apixo.ai/temp/output.mp3\"]}",
    "createTime": 1781502331739,
    "completeTime": 1781502332542,
    "costTime": 803
  }
}
```

任务失败时的响应示例：

```json theme={null}
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "VALIDATION_ERROR",
    "failMsg": "The parameter {{voice_id}} is invalid.",
    "createTime": 1781502331739,
    "completeTime": 1781502332542
  }
}
```

等 `state` 变为 `success` 后，再解析 `resultJson`：

```javascript theme={null}
const payload = JSON.parse(data.resultJson);
const audioUrls = payload.resultUrls;
```

## 请求体

```json theme={null}
{
  "request_type": "async",
  "input": {
    "mode": "speech-hd",
    "voice_id": "preset_general_wise_woman",
    "prompt": "Welcome to APIXO.",
    "pronunciation_dict": [
      "Omg/Oh my god"
    ],
    "speed": 1.0,
    "volume": 1.0,
    "pitch": 0,
    "emotion": "happy",
    "sample_rate": 24000,
    "bitrate": 128000,
    "channel": "stereo",
    "format": "mp3",
    "language_boost": "English"
  }
}
```

## 参数

**request\_type** `string` *required* (default: async)

结果获取方式。选择 `async` 时，通过 `statusTask` 轮询结果；选择 `callback` 时，通过 Webhook 接收结果。

**callback\_url** `string`

当 `request_type` 为 `callback` 时必填。请提供公网可访问的 HTTPS 地址，用于接收任务的最终结果。详见 [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

**input** `object` *required*

MiniMax Speech 2.8 的输入参数。

**属性**

**mode** `string` *required*

语音质量模式。支持的值：`speech-turbo`、`speech-hd`。

**voice\_id** `string` *required*

必需的语音选择器。使用预设 `voice_id` 从 [MiniMax Speech 2.8 预设音色](https://apixo.ai/docs/zh/guides/minimax-speech-2-8-voices.md)，或使用自定义 `voice_id` 从 [MiniMax Voice](https://apixo.ai/docs/zh/models/audio/minimax-voice.md) 创建。

**prompt** `string` *required*

必需的合成文本。支持1-10000个字符。需要时，可包含暂停控制（例如 `<#0.5#>`）和表达标签（例如 `(laughs)`、`(sighs)` 和 `(coughs)`）。

**pronunciation\_dict** `string[]`

可选的发音覆盖。每个项目必须使用 `Alias/Pronunciation` 格式，例如 `Omg/Oh my god`。

**speed** `number`

可选的语速控制。APIXO 接受数字或数字字符串，最终值必须在 `0.5` 到 `2.0` 之间。

**volume** `number`

可选的音量控制。APIXO 接受数字或数字字符串，最终值必须在 `0.1` 到 `10.0` 之间。

**pitch** `number`

可选的音调控制。APIXO 接受数字或数字字符串，最终值必须在 `-12` 到 `12` 之间。

**emotion** `string`

可选的情绪控制。支持的值：`happy`、`sad`、`angry`、`fearful`、`disgusted`、`surprised`、`neutral`。

**sample\_rate** `integer`

可选输出采样率。APIXO 接受整数或数字字符串。支持的值：`8000`、`16000`、`22050`、`24000`、`32000`、`44100`。

**bitrate** `integer`

可选输出比特率。APIXO 接受整数或数字字符串。支持的值：`32000`、`64000`、`128000`、`256000`。

**channel** `string`

可选的输出通道选择器。`1` = `mono`，`2` = `stereo`。支持的值：`1`、`2`、`mono`、`stereo`。

**format** `string`

可选的输出格式。可选值为 `mp3`、`wav`、`pcm`、`flac`。

**language\_boost** `string`

可选语言提示。支持的值：`Chinese`、`Chinese,Yue`、`English`、`Arabic`、`Russian`、`Spanish`、`French`、`Portuguese`、`German`、`Turkish`、`Dutch`、`Ukrainian`、`Vietnamese`、`Indonesian`、`Japanese`、`Italian`、`Korean`、`Thai`、`Polish`、`Romanian`、`Greek`、`Czech`、`Finnish`、`Hindi`、`Bulgarian`、`Danish`、`Hebrew`、`Malay`、`Persian`、`Slovak`、`Swedish`、`Croatian`、`Filipino`、`Hungarian`、`Norwegian`、`Slovenian`、`Catalan`、`Nynorsk`、`Tamil`、`Afrikaans`、`auto`。

## 语音 ID 规则

* 使用 [MiniMax Speech 2.8 预设音色](https://apixo.ai/docs/zh/guides/minimax-speech-2-8-voices.md) 中的预设 `voice_id` 列表来配置内置音色。
* 当需要自定义克隆或设计的声音时，使用从 [MiniMax Voice](https://apixo.ai/docs/zh/models/audio/minimax-voice.md) 返回的自定义 `voice_id`。
* 自定义 `voice_id` 值必须有效且可用于当前账户。
* 只有此页面上记录的字段才是公共请求合同的一部分。APIXO 会忽略额外的不受支持的字段，除非它们与平台行为冲突。

## 提示行为

* `prompt`支持普通旁白文本。
* 您可以在文本内使用暂停控件，例如 `<#0.5#>`。
* 如果有用，还可以包含内联表达标签，例如 `(laughs)`、`(sighs)` 和 `(coughs)`。
* `pronunciation_dict` 是缩写或别名发音覆盖的正确位置。

## 定价

新提交的非 LLM 请求按 **1 积分 = `$0.001`** 计费。先按用量和附加项目计算总额，再应用账号折扣，最后将请求总额向上取整到整数积分。如果约定了固定单价，则按该单价的原始精度计算，不再使用标准价或另行打折；最终积分仍向上取整。详见[积分换算与取整](https://apixo.ai/docs/zh/pricing.md#credit-conversion-and-rounding)。

| 模式 | 价格 |
| - | - |
| `speech-turbo` | `0.060 USD / 1000 characters` |
| `speech-hd` | `0.100 USD / 1000 characters` |

计费基于提交的 `prompt` 字符数。

## 响应格式

### 提交任务时的响应

任务受理后，`POST /generateTask/minimax-speech-2-8` 会返回任务 ID：

**code** `integer`

API 状态码。`200` 表示任务已受理。

**message** `string`

状态说明。

**data.taskId** `string`

任务的唯一 ID，用于查询任务状态。

### 状态响应字段

**taskId** `string`

任务的唯一标识符。

**state** `string`

当前任务状态，可能的值为 `processing`、`success`、`failed`。

**resultJson** `string`

包含音频结果 URL 的 JSON 字符串。`state` 为 `success` 时返回。

**failCode** `string`

供程序处理的错误码，仅在 `state` 为 `failed` 时返回。

**failMsg** `string`

失败原因说明，仅在 `state` 为 `failed` 时返回。

**createTime** `integer`

任务创建时的 Unix 时间戳，单位为毫秒。

**completeTime** `integer`

任务完成时的 Unix 时间戳，单位为毫秒。任务完成后返回。

**costTime** `integer`

处理耗时，单位为毫秒。任务成功后返回。

## Webhook 回调模式

如果希望服务端自动收到最终结果，可以使用回调模式，无需轮询。

```bash theme={null}
curl -X POST "https://api.apixo.ai/api/v1/generateTask/minimax-speech-2-8" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/webhooks/apixo",
    "input": {
      "mode": "speech-turbo",
      "voice_id": "preset_general_friendly_person",
      "prompt": "Hello, this result will be delivered by webhook."
    }
  }'
```

Webhook 接收要求和重试规则见 [Webhook 文档](https://apixo.ai/docs/zh/api-reference/webhooks.md)。

## 延迟与轮询

实际延迟因文本长度、所选模式、队列负载和路由运行状况而异。

| 工作流程 | 通常生成耗时 | 建议首次查询时间 | 轮询间隔 |
| - | - | - | - |
| `speech-turbo` | 5s-30s | 任务创建 5 秒后 | 3s-5s |
| `speech-hd` | 5s-30s | 任务创建 5 秒后 | 3s-5s |

## 错误与排查

### HTTP 错误

| 代码 | 含义 | 处理方式 |
| - | - | - |
| `400` | 请求体或参数结构不正确 | 在重试前修复请求 |
| `401` | 缺少 API 密钥，或密钥无效 | 检查 `Authorization` 请求头 |
| `402` | 余额或配额不足 | 充值或更换账号或API密钥 |
| `403` | 密钥或路由无权访问该模型 | 检查权限和路由策略 |
| `429` | 已达到速率或并发限制 | 按指数退避策略重试 |
| `500` | 服务器错误 | 逐步延长间隔后重试 |
| `502` | 临时模型服务错误 | 逐步延长间隔后重试 |
| `504` | 处理超时 | 重试或使用回调模式 |

### 通用验证规则

* 需提供 `mode`、`voice_id` 和 `prompt`。
* 内置音色必须使用文档中定义的预设 `voice_id` 列表。
* 自定义 `voice_id` 值必须有效且可用于当前账户。
* `pronunciation_dict` 必须是字符串数组，且每个元素必须使用 `Alias/Pronunciation` 格式。
* `speed`、`volume` 和 `pitch` 可以是数字字符串，但最终值必须保持在文档规定的范围内。
* `sample_rate` 和 `bitrate` 可以是数字字符串，但仅接受文档中列出的选项值。
* `channel` 接受 `1`、`2`、`mono` 或 `stereo`，其中 `1=mono` 且 `2=stereo`。
* `emotion`、`format` 和 `language_boost` 必须与文档中列出的支持值匹配。

## MCP 集成

[完整模型 Schema](https://apixo.ai/docs/models/schemas/audio/minimax-speech-2-8.json) 中的 `mcp.result` 指定了结果的解析方式，`mcp.attachments` 列出支持绑定文件的字段。这些元数据供客户端集成使用，无需作为生成参数提交。API 负责校验模型参数。

## 相关链接

* [MiniMax Speech 2.8预设音色](https://apixo.ai/docs/zh/guides/minimax-speech-2-8-voices.md)
* [MiniMax Voice](https://apixo.ai/docs/zh/models/audio/minimax-voice.md)
* [生成 API 概览](https://apixo.ai/docs/zh/models.md)
* [音频模型](https://apixo.ai/docs/zh/models/audio)
* [提交生成任务](https://apixo.ai/docs/zh/api-reference/generate-task.md)
* [查询任务状态](https://apixo.ai/docs/zh/api-reference/status-task.md)
* [Webhook](https://apixo.ai/docs/zh/api-reference/webhooks.md)
* [错误码](https://apixo.ai/docs/zh/api-reference/errors.md)
* [在 APIXO Playground 中试用 MiniMax Speech 2.8](https://apixo.ai/models/minimax-speech-2-8)
* [API定价](https://apixo.ai/pricing/api)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.