Appearance
Audio
Generate speech from text (TTS) and transcribe audio to text (STT).
Text-to-Speech
POST https://api.3xcoder.com/v1/audio/speechGenerate spoken audio from text input.
Request Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model to use (e.g., tts-1, tts-1-hd) |
input | string | Yes | The text to convert to speech (max 4096 characters) |
voice | string | Yes | Voice to use: alloy, echo, fable, onyx, nova, shimmer |
response_format | string | No | Audio format: mp3, opus, aac, flac, wav, pcm. Default: mp3 |
speed | number | No | Speed (0.25 to 4.0). Default: 1.0 |
Examples
bash
curl https://api.3xcoder.com/v1/audio/speech \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "tts-1",
"input": "Hello, welcome to 3xCoder!",
"voice": "alloy"
}' \
--output speech.mp3python
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.3xcoder.com/v1"
)
response = client.audio.speech.create(
model="tts-1",
voice="alloy",
input="Hello, welcome to 3xCoder!"
)
response.stream_to_file("speech.mp3")javascript
const response = await fetch('https://api.3xcoder.com/v1/audio/speech', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`
},
body: JSON.stringify({
model: 'tts-1',
input: 'Hello, welcome to 3xCoder!',
voice: 'alloy'
})
})
const buffer = await response.arrayBuffer()
// Save to file or play audioSpeech-to-Text (Transcription)
POST https://api.3xcoder.com/v1/audio/transcriptionsTranscribe audio into text.
Request Body (multipart/form-data)
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | Yes | Audio file (mp3, mp4, mpeg, mpga, m4a, wav, webm, max 25MB) |
model | string | Yes | Model to use (e.g., whisper-1) |
language | string | No | Language in ISO-639-1 format |
prompt | string | No | Optional context hint for the model |
response_format | string | No | json, text, srt, verbose_json, vtt. Default: json |
temperature | number | No | Sampling temperature (0-1). Default: 0 |
Response
json
{
"text": "Hello, welcome to 3xCoder."
}Examples
bash
curl https://api.3xcoder.com/v1/audio/transcriptions \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-F file="@audio.mp3" \
-F model="whisper-1"python
from openai import OpenAI
client = OpenAI(
api_key="your-api-key",
base_url="https://api.3xcoder.com/v1"
)
with open("audio.mp3", "rb") as audio_file:
transcript = client.audio.transcriptions.create(
model="whisper-1",
file=audio_file
)
print(transcript.text)