For teams already on the OpenAI SDK

Drop in to existing OpenAI code

Already using the OpenAI Python SDK? Keep your code. Point base_url to Shunya and you instantly gain 23 Indic languages, 46 voices, and on-prem deployment, no rewrites, no new client library.

Your journey

Step 1: The two-line swap

Take any working OpenAI TTS call. Change two lines, the base_url and the voice: and you're calling Shunya:

Before: vanilla OpenAI

python
from openai import OpenAI

client = OpenAI(api_key="sk-openai-...")

response = client.audio.speech.create(
    model="tts-1",
    input="Hello, how are you today?",
    voice="alloy",
    response_format="mp3",
)
response.stream_to_file("output.mp3")

After: same SDK, Shunya backend

python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_SHUNYA_KEY",
    base_url="https://tts.shunyalabs.ai/v1",   # ← swap 1
)

response = client.audio.speech.create(
    model="zero-indic",                         # ← swap 2 (model)
    input="Hello, how are you today?",
    voice="Varun",                              # ← swap 3 (voice)
    response_format="mp3",
)
response.stream_to_file("output.mp3")

Step 2: What stays the same

  • Client class, OpenAI / AsyncOpenAI from the official openai package.
  • Method shape, client.audio.speech.create(...), same fields.
  • Response shape, response.stream_to_file(), response.read(), response.iter_bytes() all work as in OpenAI.
  • Auth pattern, Bearer token via api_key; the SDK sets the Authorization header for you.
  • response_format, mp3, wav, pcm, flac, ogg_opus all map across.
  • Error handling, openai.AuthenticationError, openai.RateLimitError, openai.APIError behave as expected.

Step 3: What changes

FieldOpenAI valueShunya value
base_urlhttps://api.openai.com/v1https://tts.shunyalabs.ai/v1
modeltts-1 / tts-1-hdzero-indic
voicealloy, echo, nova, ...Varun, Sunita, Murugan, ... (46 voices)
api_keysk-openai-...Your Shunya key from the dashboard

Step 4: Voice mapping cheatsheet

OpenAI ships generic English voices. Shunya gives you native Indic voices that can also speak English (cross-lingual). Pick by language and gender:

LanguageMaleFemale
EnglishVarunNisha
HindiRajeshSunita
TamilMuruganThangam
TeluguVishnuLakshmi
BengaliArjunPriyanka
MarathiSiddharthAnanya
GujaratiRakeshPooja
KannadaKiranShreya
MalayalamKrishnanDeepa
PunjabiGurpreetSimran

See the full voice list for all 23 languages × 2 genders = 46 voices, plus details on cross-lingual synthesis (any voice, any language).

Step 5: Async + streaming with the OpenAI SDK

python
from openai import AsyncOpenAI

client = AsyncOpenAI(
    api_key="YOUR_SHUNYA_KEY",
    base_url="https://tts.shunyalabs.ai/v1",
)

async with client.audio.speech.with_streaming_response.create(
    model="zero-indic",
    input="Hello, how are you today?",
    voice="Sunita",
    response_format="pcm",
) as response:
    async for chunk in response.iter_bytes():
        play(chunk)   # bytes arrive as the model generates them

Step 6: Pipeline: GPT-4 → Shunya TTS

Use one OpenAI client for the LLM, a second OpenAI client (pointed at Shunya) for TTS. Stream tokens, flush at sentence boundaries:

python
from openai import AsyncOpenAI

oai     = AsyncOpenAI()                                      # default OpenAI base_url
shunya  = AsyncOpenAI(base_url="https://tts.shunyalabs.ai/v1",
                      api_key="YOUR_SHUNYA_KEY")

buffer = ""
stream = await oai.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
)
async for chunk in stream:
    token = chunk.choices[0].delta.content or ""
    buffer += token
    if token in (".", "!", "?", ";") and len(buffer) > 15:
        async with shunya.audio.speech.with_streaming_response.create(
            model="zero-indic", input=buffer, voice="Sunita", response_format="pcm",
        ) as resp:
            async for audio in resp.iter_bytes():
                play(audio)
        buffer = ""

Step 7: Why teams choose this path

Zero migration cost

If your codebase already uses the OpenAI SDK, the swap is two lines. No new dependencies, no rewrites, no team retraining.

Indic voices, sovereign deployment

Same SDK ergonomics, but with 23 Indic languages, on-prem deployment, and HIPAA / DPDP / GDPR compliance baked in.

Multi-vendor without multi-codebase

Keep OpenAI for English-only paths, route Indic and regulated traffic to Shunya, both via the same client class.

Cost & control

Predictable per-minute pricing vs. variable token billing. CPU-only inference for air-gapped environments.

Need richer features?
The native Shunya Python SDK exposes additional knobs, voice cloning (reference_wav), background audio mixing, word-level timestamps, that aren't in the OpenAI surface.