Audio
Convert text to lifelike speech and transcribe audio to text. OpenAI-compatible endpoints with support for Sarvam AI Indian language voices.
Use this page with an AI assistant
Opens a new chat with this docs URL and the correct AICredits base URLs.
Convert text to lifelike speech and transcribe audio to text using OpenAI-compatible endpoints. Both /audio/speech and /audio/transcriptions are available with costs charged in INR from your wallet.
Overview
| Endpoint | Method | Description |
|---|---|---|
/audio/speech | POST | Text-to-speech — returns raw audio bytes |
/audio/transcriptions | POST | Speech-to-text — returns a transcript |
Both endpoints are compatible with the OpenAI SDK. Point your client at https://api.aicredits.in/v1 and your existing audio code works without changes.
Text-to-Speech
Send text and receive an audio file. The response is raw audio bytes — write them directly to a file or stream them to a media player.
from pathlib import Path
from openai import OpenAI
client = OpenAI(
base_url="https://api.aicredits.in/v1",
api_key="sk-your-key-here",
)
response = client.audio.speech.create(
model="openai/tts-1",
voice="alloy",
input="Hello! Welcome to AICredits, your unified LLM gateway.",
)
Path("speech.mp3").write_bytes(response.content)import OpenAI from "openai";
import fs from "fs";
const client = new OpenAI({
baseURL: "https://api.aicredits.in/v1",
apiKey: "sk-your-key-here",
});
const response = await client.audio.speech.create({
model: "openai/tts-1",
voice: "alloy",
input: "Hello! Welcome to AICredits, your unified LLM gateway.",
});
const buffer = Buffer.from(await response.arrayBuffer());
fs.writeFileSync("speech.mp3", buffer);curl https://api.aicredits.in/v1/audio/speech \
-H "Authorization: Bearer sk-your-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/tts-1",
"voice": "alloy",
"input": "Hello! Welcome to AICredits, your unified LLM gateway."
}' \
--output speech.mp3TTS Parameters
| Parameter | Type | Description |
|---|---|---|
model | string (required) | openai/tts-1 for speed, openai/tts-1-hd for quality |
input | string (required) | Text to synthesize. Maximum 4096 characters. |
voice | string (required) | One of: alloy, echo, fable, onyx, nova, shimmer |
response_format | string | Default: mp3. Also supports opus, aac, flac. |
Voices
| Voice | Character |
|---|---|
alloy | Neutral and balanced — good all-purpose default |
echo | Clear and crisp — well-suited for narration |
fable | Expressive and warm — great for storytelling |
onyx | Deep and authoritative — strong, confident tone |
nova | Friendly and upbeat — energetic, conversational |
shimmer | Soft and gentle — calm, soothing delivery |
Transcription
Transcribe audio files to text using Whisper:
from openai import OpenAI
client = OpenAI(
base_url="https://api.aicredits.in/v1",
api_key="sk-your-key-here",
)
response = client.audio.transcriptions.create(
model="openai/whisper-1",
file=("audio.mp3", open("audio.mp3", "rb"), "audio/mp3"),
)
print(response.text)AUDIO_B64=$(base64 -i audio.mp3)
curl https://api.aicredits.in/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-key-here" \
-H "Content-Type: application/json" \
-d "{
\"model\": \"openai/whisper-1\",
\"input_audio\": {
\"data\": \"$AUDIO_B64\",
\"format\": \"mp3\"
}
}"Transcription Parameters
| Parameter | Type | Description |
|---|---|---|
model | string (required) | openai/whisper-1 is currently supported |
input_audio.data | string (required) | Base64-encoded audio content |
input_audio.format | string (required) | mp3, mp4, mpeg, mpga, m4a, wav, webm |
language | string | ISO-639-1 code (e.g. en, hi). Auto-detected if omitted. |
Sarvam AI — Indian Languages
Sarvam AI is an India-first voice provider specialising in Indian languages. AICredits routes sarvam/bulbul-v2 and sarvam/bulbul-v3 (TTS) and sarvam/saarika-v2 (STT) directly to the Sarvam API — no extra setup beyond your AICredits key.
Sarvam voices are called speakers and use Indian names (e.g. anushka, rahul). Pass the speaker name in the voice field — or use an OpenAI alias (alloy, nova, etc.) and AICredits maps it to a Sarvam speaker automatically.
Sarvam TTS
curl https://api.aicredits.in/v1/audio/speech \
-H "Authorization: Bearer sk-your-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "sarvam/bulbul-v2",
"input": "नमस्ते, आप कैसे हैं?",
"voice": "anushka"
}' \
--output speech.wavSarvam STT
AUDIO_B64=$(base64 -i speech.wav)
curl https://api.aicredits.in/v1/audio/transcriptions \
-H "Authorization: Bearer sk-your-key-here" \
-H "Content-Type: application/json" \
-d "{
\"model\": \"sarvam/saarika-v2\",
\"input_audio\": {
\"data\": \"$AUDIO_B64\",
\"format\": \"wav\"
},
\"language\": \"hi-IN\"
}"OpenAI Voice Alias Mapping
| OpenAI Alias | Sarvam Speaker |
|---|---|
alloy | anushka |
echo | abhilash |
fable | arya |
onyx | karun |
nova | priya |
shimmer | shreya |
All available Sarvam speakers: anushka, abhilash, manisha, vidya, arya, karun, hitesh, aditya, ritu, priya, neha, rahul, pooja, rohan, simran, kavya, amit, dev, ishita, shreya, ratan, varun, and more.
Language Codes
Pass a BCP-47 language code for Sarvam models. Defaults to hi-IN if omitted:
| Code | Language |
|---|---|
hi-IN | Hindi |
en-IN | English (India) |
bn-IN | Bengali |
gu-IN | Gujarati |
kn-IN | Kannada |
ml-IN | Malayalam |
mr-IN | Marathi |
pa-IN | Punjabi |
ta-IN | Tamil |
te-IN | Telugu |
Models
Use the right model for the right endpoint
TTS models only work with /audio/speech. Transcription models only work with /audio/transcriptions. Mixing them returns an error.
Text-to-Speech — use with /audio/speech:
| Model ID | Best For |
|---|---|
openai/tts-1 | Low latency, real-time synthesis |
openai/tts-1-hd | Higher quality audio — podcasts, voiceovers |
sarvam/bulbul-v2 | Indian language TTS — 12 languages, 44 speakers |
Transcription — use with /audio/transcriptions:
| Model ID | Best For |
|---|---|
openai/whisper-1 | Multilingual speech recognition and translation |
sarvam/saarika-v2 | Indian language STT — optimised for Indian accents |
Billing
| Model | Unit | Rate (USD) |
|---|---|---|
openai/tts-1 | Per 1K characters | $0.015 |
openai/tts-1-hd | Per 1K characters | $0.030 |
openai/whisper-1 | Per minute of audio | $0.006 |
sarvam/bulbul-v2 | Per request | INR-native pricing |
sarvam/saarika-v2 | Per second of audio | INR-native pricing |
Error Handling
| Status | Cause |
|---|---|
| 400 | Missing required field (model, input, or voice) |
| 400 | Input exceeds 4096 characters |
| 402 | Insufficient wallet balance |
| 429 | Rate limit exceeded — audio requests count toward your RPM limit |
| 502 | All upstream providers failed — retry with exponential backoff |