NexisVoice API
Sign in

Docs Migrating from OpenAI

What is identical, what differs, and the three places an OpenAI-shaped client will break here.

Identical

  • POST /v1/audio/speech and the JSON field names model, input, voice, response_format.
  • mp3, wav, pcm response formats.
  • Bearer authentication.
  • The body of a successful response: raw audio bytes, Content-Type: audio/mpeg.

Changing a client over is usually one line:

- base_url = "https://api.openai.com/v1"
+ base_url = "https://tts.nexis-ai.tech/v1"
- api_key = os.environ["OPENAI_API_KEY"]
+ api_key = os.environ["NEXIS_TTS_KEY"]

Three differences that break clients

1. voice has no built-in names

OpenAI ships alloy, nova, shimmer; this worker has no saved voices at all. A request naming one of them is a 404 relayed from the worker.

Two honest options:

  • Call the HTTP endpoint directly and use instructions instead of voice — the recommended path.
  • Ask the operator to register a saved voice and use its id.

2. Errors are not OpenAI's shape

OpenAI returns {"error": {"message", "type", "param", "code"}}. This gateway returns:

{"error": {"type": "gateway_error", "code": "rate_limited", "message": "…", "hint": "…", "request_id": "…"}}

The SDKs read error.message and error.code, which are both present, so error handling usually survives. param is absent.

3. There is one stream

OpenAI scales horizontally. This worker generates one stream at a time. Parallel SDK calls will collect 503 worker_busy past the first. Serialise calls, or accept the retries.

The OpenAI SDK, as it stands

The Python SDK requires voice, so this fails today unless a saved voice exists:

from openai import OpenAI

client = OpenAI(base_url="https://tts.nexis-ai.tech/v1", api_key=os.environ["NEXIS_TTS_KEY"])
with client.audio.speech.with_streaming_response.create(
    model="tts-1", voice="harbour", input="Registered voices only.",
) as response:
    response.stream_to_file("line.mp3")

If you cannot register a voice, use httpx:

import httpx

response = httpx.post(
    "https://tts.nexis-ai.tech/v1/audio/speech",
    headers={"Authorization": f"Bearer {os.environ['NEXIS_TTS_KEY']}"},
    json={"input": "No voice id needed.", "instructions": "a calm narrator"},
    timeout=180,
)
response.raise_for_status()
open("line.mp3", "wb").write(response.content)

Field-by-field

OpenAI field here note
model accepted, ignored Any string is fine
input required 3,000 character cap
voice optional, saved ids only Use instructions instead
response_format same three opus/aac/flac are sent as WAV
speed accepted, ignored The model has no speed control
instructions native, not gpt-4o-mini-tts This is the main voice control
stream_format audio or sse Same meaning

Checklist

  1. Point base_url at https://tts.nexis-ai.tech/v1.
  2. Replace the API key with a gateway key.
  3. Remove or map voice; add instructions.
  4. Serialise calls.
  5. Handle 429 and 503 with the Retry-After header.