Multimedia

Text-to-Speech (TTS)

ShopAIKey provides custom TTS endpoints supporting multiple providers: OpenAI, Google Gemini, and MiniMax.

Base URL

code
https://api.shopaikey.com

Authentication

All endpoints require the header:

code
Authorization: Bearer <your-api-key>

1. OpenAI TTS

Generate speech in OpenAI-compatible format. The server uploads the audio file to S3 and returns a URL.

Endpoint: POST /tts/openai/speech

Request Body

ParameterTypeDescription
inputstringRequired. Text to convert to speech (max 4096 characters)
modelstringTTS model (default: tts-1)
voicestringVoice (default: alloy). Available voices: alloy, echo, fable, onyx, nova, shimmer
response_formatstringAudio format: mp3, opus, aac, flac, wav, pcm (default: mp3)
speednumberReading speed: 0.25 - 4.0 (default: 1)

cURL Example

code
curl -X POST 'https://api.shopaikey.com/tts/openai/speech' \
  -H 'Authorization: Bearer <your-api-key>' \
  -H 'Content-Type: application/json' \
  -d '{
    "input": "Hello, this is a demo voice",
    "model": "tts-1",
    "voice": "alloy",
    "response_format": "mp3",
    "speed": 1.0
  }'

JavaScript Example

code
const response = await fetch('https://api.shopaikey.com/tts/openai/speech', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <your-api-key>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    input: 'Hello, this is a demo voice',
    model: 'tts-1',
    voice: 'alloy',
  }),
});

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

Response

code
{
  "url": "https://s3.example.com/audio/abc123.mp3",
  "key": "audio/abc123.mp3",
  "model": "tts-1",
  "voice": "alloy",
  "format": "mp3",
  "mimeType": "audio/mpeg"
}

2. Google Gemini TTS

Generate speech using Gemini TTS. The server converts PCM to WAV, uploads to S3, and returns a URL.

Endpoint: POST /tts/google/generations

Request Body

ParameterTypeDescription
textstringRequired. Text to convert to speech
modelstringTTS model (default: gemini-2.5-flash-preview-tts)
voicestringVoice name (default: Kore)

cURL Example

code
curl -X POST 'https://api.shopaikey.com/tts/google/generations' \
  -H 'Authorization: Bearer <your-api-key>' \
  -H 'Content-Type: application/json' \
  -d '{
    "text": "Hello, this is a Gemini voice",
    "model": "gemini-2.5-flash-preview-tts",
    "voice": "Kore"
  }'

Response

code
{
  "url": "https://s3.example.com/audio/abc123.wav",
  "key": "audio/abc123.wav",
  "model": "gemini-2.5-flash-preview-tts",
  "voice": "Kore",
  "sampleRate": 24000,
  "mimeType": "audio/wav"
}

3. MiniMax TTS

3a. Text-to-Audio v2 (Synchronous)

Supports streaming via Server-Sent Events when stream: true.

Endpoint: POST /tts/minimax/t2a_v2

Request Body

ParameterTypeDescription
modelstringRequired. MiniMax TTS model (e.g., speech-02-hd)
textstringRequired. Text to convert
streambooleanEnable streaming (default: false)
voice_settingobjectVoice configuration
voice_setting.voice_idstringVoice ID
voice_setting.speednumberSpeed
voice_setting.volnumberVolume
voice_setting.pitchnumberPitch
voice_setting.emotionstringEmotion
audio_settingobjectAudio configuration
audio_setting.sample_rateintegerSample rate
audio_setting.bitrateintegerBitrate
audio_setting.formatstringFormat (mp3/pcm/flac)
language_booststringLanguage enhancement

cURL Example

code
curl -X POST 'https://api.shopaikey.com/tts/minimax/t2a_v2' \
  -H 'Authorization: Bearer <your-api-key>' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "speech-02-hd",
    "text": "Hello, I am MiniMax TTS",
    "voice_setting": {
      "voice_id": "male-qn-qingse",
      "speed": 1,
      "vol": 1,
      "pitch": 0
    },
    "audio_setting": {
      "sample_rate": 32000,
      "bitrate": 128000,
      "format": "mp3"
    }
  }'

Response (Synchronous)

code
{
  "data": {
    "audio": "<hex-encoded-audio>",
    "status": 1
  },
  "extra_info": {},
  "trace_id": "abc123",
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

3b. Text-to-Audio v2 (Asynchronous)

Returns a task_id for later querying.

Endpoint: POST /tts/minimax/t2a_async_v2

The request body is the same as the synchronous endpoint.

Response

code
{
  "task_id": "abc123",
  "task_token": "token123",
  "file_id": "file123",
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

3c. Query T2A Async Task

Endpoint: GET /tts/minimax/query/t2a_async_query_v2?task_id={task_id}

Response

code
{
  "task_id": "abc123",
  "status": "Success",
  "file_id": "file123",
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

Possible statuses: Processing, Success, Failed, Expired.

3d. Retrieve Audio File

Endpoint: GET /tts/minimax/files/retrieve?file_id={file_id}

Response

code
{
  "file": {
    "file_id": "file123",
    "bytes": 102400,
    "created_at": 1700000000,
    "filename": "audio.mp3",
    "purpose": "t2a",
    "download_url": "https://example.com/download/file123"
  },
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

4. System Voice List (MiniMax)

Returns the system_voice list from MiniMax. Results are cached for 1 hour on the server. No API key required.

Endpoint: GET /tts/minimax/voices

cURL Example

code
curl -X GET 'https://api.shopaikey.com/tts/minimax/voices'

Response

code
[
  {
    "voice_id": "male-qn-qingse",
    "voice_name": "青涩青年音色",
    "description": ["male", "young"],
    "created_time": "2024-01-01T00:00:00Z"
  }
]