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_.

ClientHow to send the key
HTTP, and WebSockets from serversHeader Authorization: Bearer mk_...
WebSockets where headers can't be set (browsers)Subprotocols ["pocket-tts", "bearer.mk_..."] for TTS, ["moses-stt", "bearer.mk_..."] for STT

All endpoints

Base: https://moses-ai.com (WebSockets: wss://moses-ai.com).

MethodPathWhat
WS/tts/realtimeText streams in (e.g. an LLM's tokens), audio streams out. Also /tts/v1/realtime.
POST/tts/v1/audio/speechWhole text in, audio streamed back (OpenAI-compatible)
GET/tts/v1/voicesVoices, including your own
GET/tts/v1/languagesLanguages with their default voice and voice ids
GET/tts/v1/statsYour limits, open sessions, today's usage, credit
WS/stt/realtimeAudio streams in, transcripts stream out. Also /stt/v1/realtime.
POST/stt/v1/audio/transcriptionsTranscribe a file (OpenAI-compatible)
GET/stt/v1/languagesLanguages
GET/stt/v1/statsYour 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"}}
CodeHTTPWebSocket closeMeaning
unauthorized4014401 (handshake refused)Key missing or wrong
wrong_scope, referer, blocked4034403Key not for this API, wrong website, account blocked
no_credit4024402Top up in the console
account_limit, key_limit, ip_limit4294429Requests 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_sessions4294429Too many requests or connections at the same time
daily_limit, daily_spend4294429A daily allowance or your daily spending limit (renews at midnight UTC)
bad_request, bad_format, too_large400 / 4134400 or an error eventSomething in the request
unavailable, busy, no_capacity503 / 4291013No capacity right now: retry after Retry-After
worker_lost-1012The connection's server went away: reconnect and carry on
idle, session_too_long-4408Abandoned 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)

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

MessageEffect
{"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

FieldDefaultMeaning
voicealbaVoice id (voices)
languagefrom the voiceen, de, fr, it, pt, es, nl (or english, german …)
first_chunk_chars300–300. How long the first piece of an answer must be before it may be cut at a comma. Lower = earlier first sound.
normalizetrueNumbers, dates, times, currencies, units and acronyms read as words
markuptrueRead the markup tags
trimtrueExact pauses instead of the model's own silences
acronymsspellspell ("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

EventFieldsWhen
readysample_rate (24000), format (pcm_s16le), channels (1), voice, language, textRight after connecting
configthe settings now in useReply to config
segmentindex, 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.
binaryPCMAudio of the current segment
segment_endindex, audio_ms, first_audio_msSegment finished
done-Everything after end is sent
cancelled-Reply to cancel
warmedreserved, expires_in, idle_timeout_s, or reasonReply to warmup. Without a reservation everything still works, just without the head start.
released, lease_expiredreasonThe reservation ended (on request, unused for a while, or after its maximum time); speech carries on
errorcode?, messageSee errors. Most errors leave the connection open.

How text is cut

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).

FieldDefaultMeaning
inputrequired1–20,000 characters; markdown is stripped
voicedefault voiceVoice id; OpenAI names (alloy, nova …) map to Moses voices
languagefrom the voiceAs in config
response_formatwavwav (streaming WAV), pcm (raw, 24 kHz s16le mono), mp3, opus, flac
speed1.00.5–2.0 (OpenAI's 0.25–4.0 is accepted and clamped)
normalize, markup, trim, acronyms, pauses, lexiconAs in config
model, stream_format, instructionsAccepted 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

LanguageCodeBuilt-in voices
Englishen21 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.
Germandegerman/juergen
Frenchfrfrench/estelle
Italianititalian/giovanni
Portugueseptportuguese/rafael
Spanishesspanish/lola
Dutchnldutch/daan

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):

TagEffect
<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

MessageMeaning
{"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.

Server events

EventFieldsWhen
readysample_rate, config, modelAt the start
speech_startedid, atSomeone started speaking: the moment to stop your agent talking (barge-in)
partialid, textThe utterance so far, about every 0.3 s
speech_endedid, atThe pause (endpoint_ms) is over
finalid, text, start, end, language, words?The utterance's transcript. language is yours, or a guess (null when unclear).
revisionid, 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.
configconfigYour config was applied
doneaudio_sAfter end: everything is out
errorcode, messageSee 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).

FieldMeaning
fileWAV, MP3, FLAC, OGG/Opus, M4A, WebM … up to 25 MB and 3 hours
languageOptional (recommended), as above
response_formatjson (default), text, verbose_json, srt, vtt
timestamp_granularities[]segment, word (with verbose_json)
model, prompt, temperatureAccepted and ignored
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