跳转到主要内容
Send a POST request to https://api.qhaigc.net/v1/audio/speech to convert a text string into an audio file. The qhai-tts model supports over 38 distinct voice characters — from cute and youthful to mature and authoritative — including popular game and anime personas such as 派蒙 (Paimon), 温迪 (Venti), and 纳西妲 (Nahida).
Call GET /v1/audio/voices to retrieve the full list of available voice character names before making a TTS request.

Request

POST https://api.qhaigc.net/v1/audio/speech

Parameters

model
string
必填
The TTS model to use. Set this to "qhai-tts".
input
string
必填
The text to convert to speech. Maximum length is approximately 4096 characters.
voice
string
必填
The name of the voice character to use, for example "可爱少女" or "御姐". Call GET /v1/audio/voices to see all available characters.
response_format
string
The audio format of the returned file. Supported values include "mp3", "wav", and "opus". Defaults to "mp3".
speed
number
Playback speed multiplier. A value of 1.0 is normal speed. Increase to speed up or decrease to slow down the output. Defaults to 1.0.

Response

The endpoint returns the audio file as a binary stream in the format specified by response_format. Save the response body directly to a file.

Code examples

import openai

client = openai.OpenAI(
    api_key="sk-your-api-key-here",
    base_url="https://api.qhaigc.net/v1"
)

response = client.audio.speech.create(
    model="qhai-tts",
    voice="可爱少女",
    input="启航 AI API 系统是一款聚焦低成本探索 AIGC 无限可能的服务平台。"
)

response.stream_to_file("output.mp3")