Quickstart
Go from an API key to your first transcript in five minutes: a file, then live audio.
Before you begin
Create an account on platform.vatis.tech: a new workspace starts with free credit, no card needed (The free credit). Verify your email, then open API keys and create a key. It starts with vatis_sk_ and is shown only once: copy it.
Set it in your shell: every example reads it from VATIS_KEY. read -rs keeps it out of your shell's history: paste the key, then press Enter (it is not shown).
read -rs VATIS_KEY && export VATIS_KEYCheck your key
Ask the API which models your workspace can use. Python needs 3.10 or later and pip install httpx; the others need no packages: JavaScript Node.js 22 or later, Go 1.23 or later, Java 11 or later, C# .NET 8 or later.
curl -sS -H "Authorization: Bearer $VATIS_KEY" https://api.eu.vatis.tech/v1/modelsExpected result: the models, on one line (here on several). vatis_ro_v9 transcribes files, vatis_ro_v9_realtime live audio. Without a batch model, batch transcription is not open on your workspace yet: go on with step 3. Something else: If something goes wrong.
{"models": [
{"id": "vatis_ro_v9", "name": "Romanian v9", "mode": "batch", "languages": ["ro"], "licensed": null},
{"id": "vatis_ro_v9_realtime", "name": "Romanian v9 real-time", "mode": "realtime", "languages": ["ro"], "licensed": null}
]}Transcribe a file
Send a recording in Romanian, in any common audio or video format (speech.wav here). diarize=true tells the speakers apart. The answer comes at once, with the transcript queued; then ask for it by its id every 2 seconds until it is done.
# 1. Send the file: the answer comes at once, with the transcript queued
curl -sS -H "Authorization: Bearer $VATIS_KEY" https://api.eu.vatis.tech/v1/speech-to-text \
-F model_id=vatis_ro_v9 -F diarize=true -F file=@speech.wav
# 2. Ask every 2 seconds while it is queued or processing (-o keeps the last answer in a file)
ID=tr_69348b9588d248d1 # the "id" of the first answer
while sleep 2; do
curl -sS -H "Authorization: Bearer $VATIS_KEY" -o transcript.json https://api.eu.vatis.tech/v1/transcripts/$ID
grep -qE '"status": ?"(queued|processing)"' transcript.json || break
done
cat transcript.jsonExpected result: at once, 202 and the transcript queued, with its id; a few seconds later for a few minutes of audio, the transcript, completed. curl prints it as JSON on one line (here on several, trimmed); the programs print its id, then one line for each utterance.
{
"id": "tr_69348b9588d248d1",
"status": "completed",
"text": "Bună ziua, vă rog să luați loc. Mulțumesc.",
"segments": [
{"speaker": "speaker_0", "start": 0.12, "end": 2.31, "text": "Bună ziua, vă rog să luați loc."},
{"speaker": "speaker_1", "start": 2.9, "end": 3.62, "text": "Mulțumesc."}
],
...
}id: the transcript is kept for 7 days after its job ends. Use the id to read, export or delete it (Manage transcripts). The uploaded audio is deleted 1 day after.text: the whole transcript, with punctuation, capitals and numbers as digits.segments: the transcript as utterances, what one speaker said in one go. Show these to people.
Every field: The transcript object. Instead of asking, your server can have the transcript posted to it (Send now, collect later).
Transcribe live audio
Send audio over a WebSocket as it is recorded, and text comes back at once (curl cannot do this: skip it with curl). Partial text is the segment so far, replaced by the next. Final text is a finished segment: it never changes.
The program sends a WAV file at the pace of real time. The file must be 16 kHz, 16-bit, mono: the program does not check, and another format comes out as wrong text, so convert other recordings first (the command is in the program). Python also needs pip install --upgrade websockets, and Go a WebSocket package: in a new folder, go mod init live && go get github.com/coder/websocket. Java and C# need nothing more.
// Needs Node.js 22 or newer, no packages.
// Set your API key, then run: export VATIS_KEY=your_api_key && node live.mjs
import { readFileSync } from "node:fs";
import { setTimeout as sleep } from "node:timers/promises";
const url = "wss://api.eu.vatis.tech/v1/speech-to-text/realtime";
const headers = { Authorization: `Bearer ${process.env.VATIS_KEY}` };
// Request parameters
const params = {
model_id: "vatis_ro_v9_realtime",
diarize: "true",
};
// The audio: a 16 kHz 16-bit mono WAV. To convert a file:
// ffmpeg -i your-audio.mp3 -ac 1 -ar 16000 -c:a pcm_s16le speech.wav
const wav = readFileSync("speech.wav");
const audio = wav.subarray(wav.indexOf("data") + 8);
const chunkSize = 3200; // 100 ms of audio
// Open the session
const ws = new WebSocket(`${url}?${new URLSearchParams(params)}`, { headers });
// Send the audio at real-time pace
async function sendAudio() {
for (let start = 0; start < audio.length; start += chunkSize) {
ws.send(audio.subarray(start, start + chunkSize));
await sleep(100);
}
ws.send(JSON.stringify({ type: "end" }));
console.log("finished sending");
}
// Print the messages as they come
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
if (message.type === "session.started") {
console.log("connected");
sendAudio();
} else if (message.type === "partial") {
console.log(`... ${message.text}`);
} else if (message.type === "final") {
console.log(`${message.speaker}: ${message.text}`);
} else if (message.type === "session.ended") {
console.log(`done: ${message.duration_s} s of audio`);
} else if (message.type === "error") {
console.log(`error ${message.code}: ${message.message}`);
}
};
// A failed connection is an error; when the server closes, the program ends
ws.onerror = () => {
console.error("connection failed");
process.exit(1);
};
ws.onclose = (event) => {
if (event.code !== 1000) { // 1000 is the normal end
console.error(`connection failed: close code ${event.code}`);
process.exit(1);
}
process.exit();
};Expected result: the program runs as long as the recording lasts.
connected
... bună ziua vă rog
speaker_0: Bună ziua, vă rog să luați loc.
... mulțumesc
speaker_1: Mulțumesc.
finished sending
done: 3.8 s of audio- A partial comes fast and raw: lowercase words without punctuation, numbers in words.
- A final comes when the speaker pauses, with punctuation, capitals and digits.
- The API keeps no transcript of a live session: keep the finals you receive.
Every option: Real-time transcription.
If something goes wrong
| You see | What it means | What to do |
|---|---|---|
401 unauthorized, or error unauthorized | No key, or a wrong, revoked or expired one. | Set VATIS_KEY again, in this shell. Create a new key on the API keys page if it is lost. |
403, or an error before session.started | The workspace is paused (its credit is used up), or its live sessions are all in use. | The message says which. Add credit, or end another session (Limits and free credit). |
400 invalid_parameter | A field is misspelled or has a wrong value: param names it. | Fix that field. |
curl: (6) Could not resolve host | The address is mistyped, or the machine is offline. | Check the address: https://api.eu.vatis.tech. |
Next steps
- Batch transcription: long files without waiting, and every option.
- Real-time transcription: every option of a live session, and live text in a web page.
- Errors: every code, and what to do about it.
Try it in the console first
The console's Real-time page runs a live session from your microphone or a file, and shows the program for that session with its options.