API 文档

开放平台 API v1

概览

本平台提供 RESTful API 接口,供第三方应用调用语音合成、声音克隆、音频混音等服务。

API 基础信息

  • Base URL: https://www.dls666.cc/api/v1
  • 认证方式: API Key (Bearer Token 或 X-API-Key)
  • 数据格式: JSON
  • 字符编码: UTF-8

认证

所有 API 请求都需要在请求头中包含您的 API Key。您可以在控制台创建和管理 API Key。

方式一:Authorization Header

Authorization: Bearer pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

方式二:X-API-Key Header

X-API-Key: pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

API 端点

POST/tts

文字转语音

请求参数:

{
  "text": "要转换的文本",
  "model": "speech-02-turbo",
  "voice_id": "female-tianmei",
  "voice_setting": {
    "speed": 1.0,
    "vol": 1.0,
    "pitch": 1.0,
    "emotion": "happy"
  },
  "language": "Chinese"
}

响应示例:

{
  "success": true,
  "data": {
    "audio": "data:audio/mp3;base64,...",
    "format": "mp3",
    "size": 12345,
    "duration": 3.82,
    "credits_used": 40,
    "remaining_credits": 99960
  }
}
GET/voices?type=all

获取声音列表

查询参数:

  • type: all | male | female (默认: all)

响应示例:

{
  "success": true,
  "data": {
    "voices": [
      {
        "voice_id": "female-tianmei",
        "name": "甜美米音",
        "description": "温柔甜美的女声",
        "recommended_speed": 1.05,
        "recommended_volume": 1.4
      }
    ],
    "total": 50
  }
}
POST/voice-clone/upload

上传音频文件(用于声音克隆)

注意:声音克隆需要您绑定自己的 MiniMax API Key

请求类型:

multipart/form-data

表单字段:

  • file: 音频文件 (MP3/WAV/M4A, 最大 20MB)
  • purpose: voice_clone | prompt_audio

响应示例:

{
  "success": true,
  "data": {
    "file_id": 12345,
    "purpose": "voice_clone"
  }
}
POST/voice-clone/create

创建声音克隆

注意:声音克隆需要您绑定自己的 MiniMax API Key

请求参数:

{
  "file_id": 12345,
  "voice_id": "my-voice-001",
  "model": "speech-02-turbo",
  "text": "这是用于克隆的参考文本"
}

响应示例:

{
  "success": true,
  "data": {
    "voice_id": "my-voice-001",
    "status": "completed",
    "preview_url": "https://..."
  }
}
POST/mix

音频混音

请求类型:

multipart/form-data

表单字段:

  • vocals: 人声音频文件(支持多个)
  • bgm: 背景音乐文件(可选)
  • bgmVolume: 背景音乐音量 (0-1, 默认 0.3)

响应:

返回 WAV 格式的混音音频文件

错误码

401未授权,API Key 无效或已过期
402积分不足
400请求参数错误
500服务器内部错误

使用示例

JavaScript / Node.js

const response = await fetch('https://www.dls666.cc/api/v1/tts', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    text: '你好,世界!',
    model: 'speech-02-turbo',
    voice_id: 'female-tianmei'
  })
});

const data = await response.json();
console.log(data);

Python

import requests

headers = {
    'Authorization': 'Bearer pk_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
    'Content-Type': 'application/json'
}

data = {
    'text': '你好,世界!',
    'model': 'speech-02-turbo',
    'voice_id': 'female-tianmei'
}

response = requests.post(
    'https://www.dls666.cc/api/v1/tts',
    headers=headers,
    json=data
)

print(response.json())