Python OpenAI SDK → Audra TTS (copy-paste) — Audra

The Python OpenAI SDK works against Audra unchanged: one base_url argument and you keep the same client, retries, and streaming helpers your service already has. This is the production checklist — what to add around that one-line swap so the integration survives retries, timeouts, and deploys.

The swap

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["AUDRA_API_KEY"],
    base_url="https://audratalks.com/v1",
)

resp = client.audio.speech.create(
    model="audra-essential",
    voice="june",
    input="Chapter one. The river was low that autumn.",
)
resp.stream_to_file("ch1.mp3")

Production checklist

Streaming to file vs bytes

from openai import OpenAI

client = OpenAI(api_key=..., base_url="https://audratalks.com/v1")

# Streamed: writes incrementally, safe for long renders on small workers
with client.audio.speech.with_streaming_response.create(
    model="audra-essential",
    voice="june",
    input=script,
    response_format="mp3",
) as response:
    response.stream_to_file(f"episode_{ep}.mp3")

# Or buffer in memory when the file goes straight to S3
buf = client.audio.speech.create(
    model="audra-essential", voice="june", input=script,
).content
s3.put_object(Bucket="narration", Key=f"{ep}.mp3", Body=buf)

The JS-equivalent snippet and the full v1-to-v2 field map (input vs text, response_format vs format) live in /blog/openai-sdk-tts-migration — read that if you run Node services too.