ElevenLabs family
ElevenLabs’ speech models, two in total: Eleven v4 for speech synthesis and Scribe v2 for transcription. Both are called through the OpenAI-compatible audio endpoints.
elevenlabs/eleven_v4POST /v1/audio/speechelevenlabs/scribe_v2POST /v1/audio/transcriptionsFor the common endpoint parameters, see Audio Speech API and Audio Transcriptions API. For live prices, see the model page : speech synthesis is billed per character, and transcription is billed by audio duration.
Eleven v4 speech synthesis
Python
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"])
with client.audio.speech.with_streaming_response.create(
model="elevenlabs/eleven_v4",
voice="21m00Tcm4TlvDq8ikWAM",
input="Hello, and welcome to OfoxAI speech synthesis.",
response_format="mp3",
) as resp:
resp.stream_to_file("speech.mp3")In our tests, a Chinese sentence of about 20 characters returned in about 2 seconds, producing about 4 seconds of audio.
Scribe v2 transcription
In addition to the transcribed text, Scribe v2 returns start and end times for each word and can identify different speakers.
Python
import json
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.ofox.io/v1", api_key=os.environ["OFOX_API_KEY"])
with open("meeting.mp3", "rb") as f:
result = client.audio.transcriptions.create(
model="elevenlabs/scribe_v2",
file=f,
extra_body={"provider_options": json.dumps({"elevenlabs": {"diarize": True}})},
)
print(result.text)
for w in (result.model_extra or {}).get("words", [])[:10]:
print(w.get("speaker"), w["start"], w["end"], w["word"])Response structure:
- Speaker diarization must be enabled through
provider_options:{"elevenlabs": {"diarize": true}}, passed as a JSON string in a form field. response_formatsupportsjsonandverbose_json, which return the same content. If you need a subtitle file, generate it yourself from the timestamps inwords.
Common errors
For more errors, see Audio Speech API and Audio Transcriptions API.
Official docs
FAQ
What do I put in voice for ElevenLabs?
A voice ID (20 characters), such as 21m00Tcm4TlvDq8ikWAM, which you can find in the ElevenLabs voice library. A voice name (such as Rachel) or an OpenAI voice such as alloy returns 404 voice_id not found.
Which audio formats does Eleven v4 support?
mp3 (default), opus, wav, and pcm. aac and flac are not supported.
Can Scribe v2 distinguish speakers?
Yes. Pass {"elevenlabs": {"diarize": true}} through provider_options, and each word in the response words will carry a speaker field, such as speaker_0 or speaker_1.
Can Scribe v2 output srt subtitles directly?
No. response_format supports only json and verbose_json. You can generate subtitles yourself from the start and end timestamps in the response words.
How is ElevenLabs speech billed?
Eleven v4 is billed by the number of input characters and Scribe v2 by audio duration; see the model page for rates.