Moses API reference
Text to speech (7 languages) and speech to text (25 European languages), each over a realtime WebSocket and over HTTP. Processed in Germany; audio, text and transcripts are not stored, only the amount is recorded for billing. Keys: API console. Prices: pricing. Machine-readable HTTP spec: openapi.json.
Contents
Authentication and keys
Create a key in the API console. Each key has scopes: TTS, STT or both. Keys start with mk_.
| Client | How to send the key |
|---|---|
| HTTP, and WebSockets from servers | Header Authorization: Bearer mk_... |
| WebSockets where headers can't be set (browsers) | Subprotocols ["pocket-tts", "bearer.mk_..."] for TTS, ["moses-stt", "bearer.mk_..."] for STT |
- Keep keys secret. A key in a web page or app can be read by anyone. For browsers, relay through your own server, or limit the key (below).
- Allowed websites (optional, per key):
example.com,*.example.comorhttps://app.example.com. The key then only works for requests whoseReferer(or elseOrigin) matches. - Limits per key (optional): characters or minutes a day, requests at once or a minute. Every key also has a per-IP limit (50 requests a minute to start), unless it is a server key: tick that for keys used only from your own servers.
- New accounts get trial credit; after that, usage is charged against prepaid credit.
All endpoints
Base: https://moses-ai.com (WebSockets: wss://moses-ai.com).
| Method | Path | What |
|---|---|---|
| WS | /tts/realtime | Text streams in (e.g. an LLM's tokens), audio streams out. Also /tts/v1/realtime. |
| POST | /tts/v1/audio/speech | Whole text in, audio streamed back (OpenAI-compatible) |
| GET | /tts/v1/voices | Voices, including your own |
| GET | /tts/v1/languages | Languages with their default voice and voice ids |
| GET | /tts/v1/stats | Your limits, open sessions, today's usage, credit |
| WS | /stt/realtime | Audio streams in, transcripts stream out. Also /stt/v1/realtime. |
| POST | /stt/v1/audio/transcriptions | Transcribe a file (OpenAI-compatible) |
| GET | /stt/v1/languages | Languages |
| GET | /stt/v1/stats | Your limits, open streams, credit |
Errors and limits
HTTP errors carry a message, a code and, where waiting helps, Retry-After (header, and retry_after in seconds). The body also has OpenAI's error object, so OpenAI SDKs show the message.
HTTP/1.1 429 Too Many Requests
Retry-After: 23
{"detail": "at most 60 requests a minute for your account …", "code": "account_limit", "retry_after": 23,
"error": {"message": "at most 60 requests a minute for your account …", "type": "rate_limit_error", "code": "account_limit"}}
| Code | HTTP | WebSocket close | Meaning |
|---|---|---|---|
unauthorized | 401 | 4401 (handshake refused) | Key missing or wrong |
wrong_scope, referer, blocked | 403 | 4403 | Key not for this API, wrong website, account blocked |
no_credit | 402 | 4402 | Top up in the console |
account_limit, key_limit, ip_limit | 429 | 4429 | Requests a minute for the account, a limit you set on the key, the key's limit per IP address |
too_many_at_once, too_many_sessions | 429 | 4429 | Too many requests or connections at the same time |
daily_limit, daily_spend | 429 | 4429 | A daily allowance or your daily spending limit (renews at midnight UTC) |
bad_request, bad_format, too_large | 400 / 413 | 4400 or an error event | Something in the request |
unavailable, busy, no_capacity | 503 / 429 | 1013 | No capacity right now: retry after Retry-After |
worker_lost | - | 1012 | The connection's server went away: reconnect and carry on |
idle, session_too_long | - | 4408 | Abandoned connection (TTS: nothing for 5 minutes; STT: no audio for 60 s), or a stream longer than 4 hours |
WebSockets send the same codes in an {"type": "error", "code", "message"} event before closing. Errors that don't end the connection (a bad message, a message over 64 KB) come as an error event only.
Limits per account (standard)
- 60 requests and sessions started a minute, across all keys and the studio.
- At once: 2 TTS realtime connections, 2 TTS speech requests, 2 STT live streams, 2 STT files.
GET /tts/v1/statsand/stt/v1/statsshow yours. - TTS: up to 20,000 characters per speech request. STT: files up to 25 MB and 3 hours, streams up to 4 hours.
Need more? Ask via Support; limits are raised per account.
TTS: realtime WebSocket wss://moses-ai.com/tts/realtime
Send text as it is written (an LLM's tokens); audio for each sentence starts while the next one is still arriving. One connection can speak many answers in a row. Client → server: JSON text messages. Server → client: binary frames (audio) and JSON events.
connect ──► {"type":"ready", ...}
config (optional) ──► {"type":"config", ...}
text, text, text … ──► segment, <audio>, <audio>, segment_end, segment, <audio>, …
end ──► … segment_end, {"type":"done"}
text … end ──► (the next answer on the same connection)
cancel (any time) ──► {"type":"cancelled"} audio stops, buffered text is dropped
Audio: raw PCM, signed 16-bit little-endian, mono, 24,000 Hz (48,000 bytes a second), in small chunks. Play them in order without gaps; to save a file, add a WAV header.
Client messages
| Message | Effect |
|---|---|
{"type":"config", ...} | Changes settings for the following text (fields below). Any time; all fields optional. Alias start. |
{"type":"text", "text":"Hel"} | Appends text. Complete sentences are spoken right away. |
{"type":"flush"} | Speaks what is buffered now, even without punctuation (e.g. while your LLM calls a tool). |
{"type":"end"} | End of the answer: speaks the rest, then sends done. The connection stays open. |
{"type":"cancel"} | Barge-in: stops the audio within one chunk, drops queued text, replies cancelled. The next text starts a new answer. |
{"type":"warmup"} | Reserves a speech engine for this connection and loads the voice, for the fastest first audio (worth it for your own voices). Optional voice, language. Replies warmed. Doesn't change the session's voice. |
{"type":"release"} | Gives the reservation back; replies released. Send it when a conversation ends but the connection stays open. |
{"type":"prepare", "voice":"clone:me", "language":"de"} | Encodes your own voice for a language ahead of time; replies prepared. |
config fields
| Field | Default | Meaning |
|---|---|---|
voice | alba | Voice id (voices) |
language | from the voice | en, de, fr, it, pt, es, nl (or english, german …) |
first_chunk_chars | 30 | 0–300. How long the first piece of an answer must be before it may be cut at a comma. Lower = earlier first sound. |
normalize | true | Numbers, dates, times, currencies, units and acronyms read as words |
markup | true | Read the markup tags |
trim | true | Exact pauses instead of the model's own silences |
acronyms | spell | spell ("API" → "A P I") or keep |
pauses | {"sentence_ms":450, "clause_ms":200, "paragraph_ms":700} | Pauses after a sentence, a clause cut, a paragraph (0–3000 ms each; partial objects allowed) |
lexicon | {} | Pronunciations for this connection, {"Siobhan": "Shi-vawn"} (up to 500). Replaces the previous one; {} clears it. |
Voice and language: only language picks that language's default voice (your own voice keeps speaking, in the new language). voice without a prefix plus language speaks that voice in that language. A prefixed voice (german/juergen) with a different language is an error.
Server events
| Event | Fields | When |
|---|---|---|
ready | sample_rate (24000), format (pcm_s16le), channels (1), voice, language, text | Right after connecting |
config | the settings now in use | Reply to config |
segment | index, text, end, ops, warnings? | A piece of text starts; its audio frames follow. text is as written (for captions), ops is what is actually spoken, warnings lists markup problems. |
| binary | PCM | Audio of the current segment |
segment_end | index, audio_ms, first_audio_ms | Segment finished |
done | - | Everything after end is sent |
cancelled | - | Reply to cancel |
warmed | reserved, expires_in, idle_timeout_s, or reason | Reply to warmup. Without a reservation everything still works, just without the head start. |
released, lease_expired | reason | The reservation ended (on request, unused for a while, or after its maximum time); speech carries on |
error | code?, message | See errors. Most errors leave the connection open. |
How text is cut
- At sentence ends (
. ! ? …followed by a space, or a line break). Abbreviations (Dr.,e.g.,z.B.) and decimals don't end a sentence. - The first piece of an answer may already be cut at
, ; :or a dash once it hasfirst_chunk_charscharacters. - Long sentences are cut at a clause after 180 characters, at a space after 320.
- Markdown is removed; text in code blocks isn't spoken. Send raw LLM output.
- A final punctuation mark waits for the next text, so finish each answer with
end(orflush).
Example (Python)
import asyncio, json, websockets # pip install websockets
async def main():
async with websockets.connect("wss://moses-ai.com/tts/realtime",
additional_headers={"Authorization": "Bearer mk_YOUR_KEY"}) as ws:
await ws.recv() # {"type": "ready", ...}
await ws.send(json.dumps({"type": "config", "voice": "alba"}))
for word in "Hello there, this is spoken while it is written.".split():
await ws.send(json.dumps({"type": "text", "text": word + " "}))
await ws.send(json.dumps({"type": "end"}))
with open("speech.pcm", "wb") as f:
async for msg in ws:
if isinstance(msg, bytes):
f.write(msg) # PCM s16le, mono, 24 kHz
elif json.loads(msg)["type"] == "done":
break
asyncio.run(main())
Convert: ffmpeg -f s16le -ar 24000 -ac 1 -i speech.pcm speech.mp3. Barge-in: when the user starts talking, stop your local playback and send cancel.
TTS: speech over HTTP POST /tts/v1/audio/speech
For whole texts (notifications, prompts, cached phrases). The audio streams back while it is made; closing the connection stops it. OpenAI-compatible: use the OpenAI SDKs with base_url="https://moses-ai.com/tts/v1" (details).
| Field | Default | Meaning |
|---|---|---|
input | required | 1–20,000 characters; markdown is stripped |
voice | default voice | Voice id; OpenAI names (alloy, nova …) map to Moses voices |
language | from the voice | As in config |
response_format | wav | wav (streaming WAV), pcm (raw, 24 kHz s16le mono), mp3, opus, flac |
speed | 1.0 | 0.5–2.0 (OpenAI's 0.25–4.0 is accepted and clamped) |
normalize, markup, trim, acronyms, pauses, lexicon | As in config | |
model, stream_format, instructions | Accepted for OpenAI clients; the audio always comes as audio |
curl -N https://moses-ai.com/tts/v1/audio/speech \
-H "Authorization: Bearer mk_YOUR_KEY" -H "Content-Type: application/json" \
-d '{"input": "Das kostet 42 Euro.", "language": "de", "response_format": "mp3"}' -o speech.mp3
TTS: voices and languages
| Language | Code | Built-in voices |
|---|---|---|
| English | en | 21 voices without a prefix. Female: alba, anna, vera, fantine, eponine, azelma, mary, jane, eve, cosette, caro_davy. Male: marius, javert, jean, charles, paul, george, michael, bill_boerst, peter_yearsley, stuart_bell. |
| German | de | german/juergen |
| French | fr | french/estelle |
| Italian | it | italian/giovanni |
| Portuguese | pt | portuguese/rafael |
| Spanish | es | spanish/lola |
| Dutch | nl | dutch/daan |
- Your own voice: record or upload 5–30 s in the TTS studio (My voices, with consent). Only your keys can use it, as
clone:<name>, in every language ({"voice": "clone:me", "language": "fr"}). After saving,prepareorwarmupmakes the first sentence fast. - Each language has its own model, so send text in the chosen language. For a foreign phrase inside a sentence use
<lang xml:lang="en">…</lang>. GET /tts/v1/voiceslists the current voices with label, gender and language.
TTS: text, numbers and markup
Normalisation (on by default) reads written forms as words, in the voice's language: €1,250.50, 2026-11-20, 14:30, +49 30 1234567, 97%, -5 °C, 3rd, info@example.com, Dr., e.g.. In English , groups thousands; in the other languages . does (1.250,50). Numbers of 5+ digits without separators, and numbers with a leading zero, are read digit by digit. Short acronyms are spelled (API), pronounceable ones are kept (NASA).
Lexicon: exact terms (case-sensitive, whole words) replaced by a respelling before normalisation, per connection (config) or per request: {"lexicon": {"Aoife": "Ee-fa", "SQL": "sequel"}}.
Markup (an SSML subset, also inside streamed text; a tag is never split; unknown tags are removed):
| Tag | Effect |
|---|---|
<break time="500ms"/> | Exact pause (ms or s, up to 5 s), or strength="weak|medium|strong|x-strong" |
<lang xml:lang="en">…</lang> | Read the passage in another language |
<voice name="german/juergen">…</voice> | Another voice for the passage (dialogue) |
<sub alias="Doctor Who">Dr. Who</sub> | Read alias instead |
<say-as interpret-as="…"> | characters, digits, cardinal, ordinal, telephone, date, time, currency, address, verbatim |
<prosody rate="slow" volume="soft"> | Speed 50–200 % (x-slow … x-fast, 80%), volume (x-soft … x-loud, -3dB) |
<emphasis>, <p> | Short pauses around the words; a paragraph pause |
Ihr Code lautet <break time="400ms"/> <say-as interpret-as="digits">4711</say-as>. Please call <sub alias="Ee-fa">Aoife</sub> at <say-as interpret-as="telephone">+44 20 7946 0958</say-as>.
Not supported: <prosody pitch>, <phoneme>, <audio>. Problems with a tag show up as warnings in the segment event; the text is still spoken.
STT: realtime WebSocket wss://moses-ai.com/stt/realtime
Send audio as it is recorded; get partial transcripts while someone speaks and the final transcript shortly after they stop. Settings can go in the URL (?language=de&sample_rate=16000) or in a config message.
Audio: binary messages, raw PCM, 16-bit signed little-endian, mono, at sample_rate (8000, 16000, 24000, 32000 or 48000; default 16000). Send 20–100 ms per message, at the pace it is recorded. Up to 2× real time is fine (catching up after a hiccup); much faster is refused (too_fast). Use the file endpoint for recordings. Keep sending audio (silence included) or send end: a stream without audio for 60 s is closed.
Client messages
| Message | Meaning |
|---|---|
{"type":"config", "language":"de", "endpoint_ms":300, "interim":true, "words":false, "vad_events":true} | Change settings, any field optional. sample_rate only before the first audio. |
{"type":"flush"} | End the current utterance now; its final comes at once. Use it when your own turn detection decides the user has finished (push-to-talk released, VAD stop). Without an open utterance nothing is sent. |
{"type":"end"} | No more audio: the last final, then done, then the server closes. |
language: a code from the list, orauto(default). Set it when you know it: short utterances are otherwise sometimes taken for English; withlanguageset they are corrected (seerevision).endpoint_ms: the pause that ends an utterance, 100–3000 ms (default 300).interim: partial transcripts (default true).words: word timings in finals (default false).vad_events:speech_started/speech_ended(default true).
Server events
| Event | Fields | When |
|---|---|---|
ready | sample_rate, config, model | At the start |
speech_started | id, at | Someone started speaking: the moment to stop your agent talking (barge-in) |
partial | id, text | The utterance so far, about every 0.3 s |
speech_ended | id, at | The pause (endpoint_ms) is over |
final | id, text, start, end, language, words? | The utterance's transcript. language is yours, or a guess (null when unclear). |
revision | id, text, language, words? | You set language and the final came out as English: the utterance decoded again in your language (about 1 s later). Replace the final with the same id. |
config | config | Your config was applied |
done | audio_s | After end: everything is out |
error | code, message | See errors; also too_fast (4429) |
Times (at, start, end, word timings {"word", "start", "end"}) are seconds since the stream began.
Example (Python)
import asyncio, json, websockets # pip install websockets
async def main():
url = "wss://moses-ai.com/stt/realtime?language=de"
async with websockets.connect(url, additional_headers={"Authorization": "Bearer mk_YOUR_KEY"}) as ws:
async def listen():
async for msg in ws:
ev = json.loads(msg)
if ev["type"] in ("final", "revision"):
print(ev["id"], ev["text"])
task = asyncio.create_task(listen())
with open("speech.pcm", "rb") as f: # 16 kHz s16le mono
while chunk := f.read(3200): # 100 ms
await ws.send(chunk)
await asyncio.sleep(0.1) # at the pace it would be recorded
await ws.send(json.dumps({"type": "end"}))
await task
asyncio.run(main())
From a browser, capture the microphone with an AudioWorklet and send the PCM through your own relay server, which adds the key. A working page with code to copy: JavaScript example.
STT: file transcription POST /stt/v1/audio/transcriptions
Multipart form, as in OpenAI's API (use the OpenAI SDKs with base_url="https://moses-ai.com/stt/v1"). Raw audio in the body works too (Content-Type: audio/..., fields as query parameters).
| Field | Meaning |
|---|---|
file | WAV, MP3, FLAC, OGG/Opus, M4A, WebM … up to 25 MB and 3 hours |
language | Optional (recommended), as above |
response_format | json (default), text, verbose_json, srt, vtt |
timestamp_granularities[] | segment, word (with verbose_json) |
model, prompt, temperature | Accepted and ignored |
json:{"text", "language", "duration", "usage"}.verbose_jsonaddssegments(id,start,end,text) and, if asked for,words.- The answer comes when the whole file is done: a few seconds per minute of audio, plus waiting time when busy.
- Errors: 400 (not audio, bad field), 401/403, 402, 413 (over 25 MB), 429 (files at once), 503 with
Retry-After, 504 (took too long).
curl https://moses-ai.com/stt/v1/audio/transcriptions -H "Authorization: Bearer mk_YOUR_KEY" \
-F file=@meeting.mp3 -F language=de -F response_format=srt
from openai import OpenAI # pip install openai
client = OpenAI(api_key="mk_YOUR_KEY", base_url="https://moses-ai.com/stt/v1")
with open("meeting.mp3", "rb") as f:
r = client.audio.transcriptions.create(model="whisper-1", file=f, language="de",
response_format="verbose_json", timestamp_granularities=["word"])
print(r.text)
STT: languages
bg Bulgarian, cs Czech, da Danish, de German, el Greek, en English, es Spanish, et Estonian, fi Finnish, fr French, hr Croatian, hu Hungarian, it Italian, lt Lithuanian, lv Latvian, mt Maltese, nl Dutch, pl Polish, pt Portuguese, ro Romanian, ru Russian, sk Slovak, sl Slovenian, sv Swedish, uk Ukrainian. Detected automatically, or set per stream or file. Transcripts come with punctuation and capitals.
SDKs and integrations
- JavaScript / TypeScript:
npm install @mosesai/tts,npm install @mosesai/stt(Node 18+ and browsers). Try them in the browser. - Voice agents: Pipecat plugin and LiveKit Agents plugin, both on the realtime WebSockets.
- OpenAI SDKs and tools: OpenAI compatibility.
- AI assistants (Claude, Cursor, VS Code): MCP server.
- OpenAPI: openapi.json for the HTTP endpoints.