import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.OPENAI_API_KEY
});
const speech = await client.audio.speech.create({
model: "gpt-4o-mini-tts",
voice: "OPENAI_VOICE",
input: "Hello from my application",
response_format: "mp3"
});How to Switch from OpenAI Voice to Fish Audio
Keep the OpenAI SDK. Point it at AllModels, then replace the model and voice. Your speech-generation call stays the same.
- 1Use your AllModels key and set the SDK base URL to
https://api.allmodels.io/oai. - 2Set
fish/s2-1-proand choose a Fish voice ID.
AllModels is an independent service and is not affiliated with, endorsed by, or sponsored by OpenAI, ElevenLabs, Fish Audio, or Cartesia.
Change the base URL, model, and voice
These examples generate a normal MP3 response. Highlighted lines are the only provider-migration changes.
JavaScript
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.ALLMODELS_API_KEY,
baseURL: "https://api.allmodels.io/oai"
});
const speech = await client.audio.speech.create({
model: "fish/s2-1-pro",
voice: "FISH_VOICE_ID",
input: "Hello from my application",
response_format: "mp3"
});Python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
)
with client.audio.speech.with_streaming_response.create(
model="gpt-4o-mini-tts",
voice="OPENAI_VOICE",
input="Hello from my application",
response_format="mp3",
) as response:
response.stream_to_file("speech.mp3")import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["ALLMODELS_API_KEY"],
base_url="https://api.allmodels.io/oai",
)
with client.audio.speech.with_streaming_response.create(
model="fish/s2-1-pro",
voice="FISH_VOICE_ID",
input="Hello from my application",
response_format="mp3",
) as response:
response.stream_to_file("speech.mp3")Keep using the OpenAI SDK
Switching providers through AllModels is intentionally simple: keep the SDK and request flow you already use, point the client at AllModels, then choose a different model and voice.
The AllModels-compatible OpenAI SDK surface supports text-to-speech and streamed speech responses, file transcription, and realtime transcription. Read the complete OpenAI SDK compatibility guide for setup details, supported methods, and current limitations.
About Fish Audio S2.1 Pro
Fish Audio launched S2.1 Pro alongside a $52 million seed announcement. The company says the model can clone a voice from five seconds of audio and offers word-level control over emotion, intonation, and pacing.
Fish Audio also claims S2.1 Pro is twice as fast as Cartesia and costs one sixth as much as ElevenLabs, and names HeyGen, LiveKit, Retell, Sanas, and OpenArt as production users. Treat those as provider-reported comparisons and test quality, latency, and cost against your own workload.
Quick answers
Common migration questions
Do I need to replace the OpenAI SDK?
No. Keep the installed SDK and its speech method. AllModels exposes a compatible base URL for it.
Can I reuse my OpenAI voice?
No. Choose a voice from the Fish Audio S2.1 Pro voice list, then replace FISH_VOICE_ID with its ID.
Can I switch providers again later?
Yes. Keep the AllModels base URL and API key, then change the model and voice to another supported provider.
