# 声音设计PRO API Documentation

> 声音设计PRO：通过文字描述生成专属音色，返回 voice_id 与预览音频。音色可用于语音合成PRO。描述最多500字符，仅支持中英文。

## Overview

This document describes how to call the **声音设计PRO** API.

- **Model / path slug**: `audio/sounddesignpro`
- **Task type**: `sync` (`sync` = synchronous, `async` = create task then poll / callback)
- **HTML docs**: `/doc/30`

## Authentication

All API requests require your platform API key as the query parameter `key`:

```
?key=YOUR_API_KEY
```

Get API Key:
1. Sign in to the console
2. Open [API Key Management](/user/key) and create or copy your key
3. Append `key=YOUR_API_KEY` to the request URL (or pass it in form/JSON when the endpoint accepts it)

---

## API Information

- **URL**: `POST http://apis.xiaobao.ink/api/audio/sounddesignpro`
- **Content-Type**: `application/json` (request body commonly `application/json` or `application/x-www-form-urlencoded` for POST)
- **HTTP Method**: `POST`

### Request Parameters

| Parameter | Required | Description |
|-----------|----------|-------------|
| `voice_prompt` | Yes | 一个可爱的声音，超级可爱的女孩。 |
| `preview_text` | Yes | 你好！ |
| `language_hints` | Yes | zh |

> **Note**: `key` (API key) is required for authenticated calls even if omitted from the parameter list above.

### Request Example

```
http://apis.xiaobao.ink/api/audio/sounddesignpro?key=你的密钥
```

## Details

## 请求HEADER：

| 名称 | 值 |
| --- | --- |
| Content-Type | application/x-www-form-urlencoded;charset=utf-8 或 application/json |

## 接口说明：

声音设计PRO：根据声音文字描述生成专属音色（音色定制/音色创作）。返回的 `voice_id` 可直接用于「语音合成PRO」。

**关联接口：**语音合成PRO `/api/audio/audiosavepro`

## 计费说明：

按次计费，默认 **200 点/次**（约 2 元/次）。免费额度以控制台配置为准（文档参考免费 3 次）。超过 1 年未使用的音色ID将被清除。

## 请求参数说明：

| 名称 | 必填 | 类型 | 示例值 | 说明 |
| --- | --- | --- | --- | --- |
| key | 是 | string | 你的平台密钥 | 接口密钥，在控制台→密钥管理查看 |
| voice_prompt | 是 | string | 一个可爱的声音，超级可爱的女孩。 | 声音描述，最大长度500字符，仅支持中文和英文 |
| preview_text | 否 | string | 你好！ | 预览音频文本，默认「你好！」，最多200字符 |
| language_hints | 否 | string | zh | 语言选择，默认 zh（可选 zh 中文 / en 英文） |

## 返回参数说明：

| 名称 | 类型 | 说明 |
| --- | --- | --- |
| code | int | 状态码 |
| msg | string | 状态信息 |
| data | object | 结果数据 |
| - voice_id | string | 音色ID；超过1年未使用将被清除 |
| - preview_audio | object | 预览音频：base64 / format / sample_rate |
| - preview_url | string | 预览音频转存后的本站URL（若保存成功） |
| - power_cost | number | 本次扣点 |
| exec_time | float | 执行耗时 |
| ip | string | 客户端IP |

## 错误码：

| 错误码 | 类型 | 说明 |
| --- | --- | --- |
| 403 | int | 没有权限（密钥无效等） |
| 400 | int | 参数传递不正确 / 业务失败 |
| 500 | int | 服务器内部错误 |

## Response Example

```json
{
    "code": 200,
    "msg": "音色创建成功",
    "data": {
        "voice_id": "sd-8c034e3c82db494fb6e728f04115d944",
        "preview_audio": {
            "base64": "UklGR...",
            "format": "wav",
            "sample_rate": 24000
        },
        "preview_url": "https://apis.xiaobao.ink/upload/audio/2026/07/15/sdpreview_xxx.wav",
        "power_cost": 200
    },
    "exec_time": 5.76,
    "ip": "1.2.3.4"
}
```

## Error Codes

| 错误码 | 类型 | 说明 |
| --- | --- | --- |
| 403 | int | 没有权限（密钥无效等） |
| 400 | int | 参数传递不正确 / 业务失败 |
| 500 | int | 服务器内部错误 |

## Usage Flow

1. Obtain your API Key from the console
2. Call the endpoint with `key` and required parameters
3. Parse the JSON (or binary) response according to the examples above

---

_Generated for AI / LLM consumption. Source of truth: `api_list` (same as HTML `/doc/{id}`)._
