# Set up Vatis Tech speech-to-text

You are a coding agent, and the person asked you to add Vatis Tech speech-to-text to their project. Follow these steps in order. Tell the person what you need from them, and what you changed when you are done.

## 1. What the API does

The Vatis Tech API turns speech into text. **Batch:** send a recording (a file, or a link the API downloads itself) and get its transcript: the text with punctuation, capitals and numbers as digits, each word with its times and confidence, and, when asked, who spoke when. **Real-time:** stream audio over a WebSocket while it is recorded, and get the text back as it is spoken. The models are Romanian: `vatis_ro_v9` for files, `vatis_ro_v9_realtime` for live audio; `GET /v1/models` lists the ones the person's workspace can use.

## 2. The API key

Every request carries a key of the person's workspace: `Authorization: Bearer <key>`.

1. Ask the person to create a key on the console's API keys page: https://platform.vatis.tech/keys. A key starts with `vatis_sk_` and is shown once, when it is made, so they copy it then. Only a workspace's owners and admins can make keys: a member asks an owner or admin of the workspace for one.
2. Ask the person to set it as the `VATIS_KEY` environment variable themselves, wherever the code will run: in their shell (`read -rs VATIS_KEY && export VATIS_KEY` keeps it out of the shell's history), in an untracked `.env` file the project already loads, or in their deployment's secret settings.
3. Write code that reads the key from `VATIS_KEY` when it runs.

**Never ask for the key in the chat, and never write it into code, a command, a file that is committed, or a log.** If the person pastes it to you anyway, do not use or repeat it: tell them to revoke it on https://platform.vatis.tech/keys and make a new one.

Check the key once `VATIS_KEY` is set. The answer lists the workspace's models; `401 unauthorized` means the variable is not set in this shell, or the key is wrong or revoked.

```bash
curl -sS -H "Authorization: Bearer $VATIS_KEY" https://api.eu.vatis.tech/v1/models
```

## 3. The API's address

- REST: `https://api.eu.vatis.tech`. Every path starts with `/v1`.
- Real-time WebSocket: `wss://api.eu.vatis.tech/v1/speech-to-text/realtime`, on the same host.

Keep the address in one place in the project's configuration.

## 4. A first batch request

`POST /v1/speech-to-text`, a multipart form: `model_id`, then the recording as `file` (any common audio or video format) or as `url` (a link the API downloads itself). These are the requests the console's Overview shows under Your first request; replace `your-audio.wav` with one of the person's recordings.

Every request is answered at once: `202` with `{"id": "tr_...", "status": "queued"}`, while the file is transcribed in the background. No request waits for its transcript: each program then asks for `GET /v1/transcripts/{id}` every 2 seconds until `status` is `completed` (the answer is the transcript) or `failed` (its `error` says why).

### cURL

The request, then a loop that asks for the transcript and prints it as JSON: put the `id` of the first answer in `ID`.

```bash
# Needs curl. Set your API key first: export VATIS_KEY=your_api_key
# 1. Send the file: the answer comes at once, with the transcript's id
curl -sS -X POST "https://api.eu.vatis.tech/v1/speech-to-text" \
  -H "Authorization: Bearer $VATIS_KEY" \
  -F file=@your-audio.wav \
  -F model_id=vatis_ro_v9 \
  -F language_code=ro

# 2. Ask every 2 seconds while it is queued or processing, then print it
ID=tr_ae35f8db719b4d9c   # 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.json
```

### Python

```python
# Needs Python 3.10 or newer and httpx (pip install httpx).
# Set your API key, then run: export VATIS_KEY=your_api_key && python3 transcribe.py
import os
import time

import httpx

base_url = "https://api.eu.vatis.tech"
headers = {"Authorization": f"Bearer {os.environ['VATIS_KEY']}"}

# Request parameters
data = {
    "model_id": "vatis_ro_v9",
    "language_code": "ro",
}

# The audio file
file = "your-audio.wav"

# Send the file: the answer comes at once, with the transcript queued
with open(file, "rb") as audio:
    response = httpx.post(
        f"{base_url}/v1/speech-to-text",
        headers=headers,
        data=data,
        files={"file": audio},
        timeout=600,
    )
transcript = response.json()
if response.is_error:
    error = transcript["error"]
    raise SystemExit(
        f"{response.status_code} {error['code']}: {error['message']}"
    )

# Ask every 2 seconds until the transcript is ready
while transcript["status"] not in ("completed", "failed"):
    time.sleep(2)
    response = httpx.get(
        f"{base_url}/v1/transcripts/{transcript['id']}",
        headers=headers,
        timeout=60,
    )
    transcript = response.json()
if transcript["status"] == "failed":
    raise SystemExit(f"failed: {transcript['error']['message']}")

# Print the result
print(transcript["text"])
```

### JavaScript (Node.js)

```javascript
// Needs Node.js 22 or newer, no packages.
// Set your API key, then run: export VATIS_KEY=your_api_key && node transcribe.mjs
import { openAsBlob } from "node:fs";
import { setTimeout as sleep } from "node:timers/promises";

const baseUrl = "https://api.eu.vatis.tech";
const headers = { Authorization: `Bearer ${process.env.VATIS_KEY}` };

// Request parameters
const params = {
  model_id: "vatis_ro_v9",
  language_code: "ro",
};

// The audio file
const file = "your-audio.wav";

// Send the file: the answer comes at once, with the transcript queued
const form = new FormData();
for (const [name, value] of Object.entries(params)) {
  form.append(name, value);
}
form.append("file", await openAsBlob(file), file);

let response = await fetch(`${baseUrl}/v1/speech-to-text`, {
  method: "POST",
  headers,
  body: form,
});
let transcript = await response.json();
if (!response.ok) {
  const { code, message } = transcript.error;
  throw new Error(`${response.status} ${code}: ${message}`);
}

// Ask every 2 seconds until the transcript is ready
while (transcript.status !== "completed" && transcript.status !== "failed") {
  await sleep(2000);
  const url = `${baseUrl}/v1/transcripts/${transcript.id}`;
  response = await fetch(url, { headers });
  transcript = await response.json();
}
if (transcript.status === "failed") {
  throw new Error(`failed: ${transcript.error.message}`);
}

// Print the result
console.log(transcript.text);
```

### Collecting the result

Asking every few seconds is fine: each request is short. A server can have the finished transcript posted to it instead, with `webhook=true` or `webhook_id`: https://platform.vatis.tech/docs/batch/webhooks. `async` is still taken, `true` or `false`, and changes nothing. `store=false` (keep nothing) needs a webhook, since nothing would be left to fetch. A transcript is kept 7 days after its job ends; the uploaded audio is deleted 1 day after.

Names and terms the transcript must get right: a Romanian file takes a saved vocabulary as `vocabulary_id`, its own list as `vocabulary` (a JSON list of up to 250 entries, sent as a text field: `["Vatis Tech", "Ispas"]`), and `vocabulary_strength` (0 to 2, 1 by default). The transcript then carries `"vocabulary": {"id": ..., "strength": ..., "entries": ...}`, never the entries: https://platform.vatis.tech/docs/realtime/vocabularies#files.

A refused request answers `{"error": {"code": "...", "message": "...", "param": "..."}}`; `400 invalid_parameter` names the field in `param`. Every code: https://platform.vatis.tech/docs/errors.

## 5. Real-time in short

Open a WebSocket to `wss://api.eu.vatis.tech/v1/speech-to-text/realtime` with the header `Authorization: Bearer <key>` and the session's options in the query, for example `?model_id=vatis_ro_v9_realtime&diarize=true`:

- `model_id` (required): `vatis_ro_v9_realtime`.
- `encoding`: `pcm_s16le` (the default), `pcm_f32le`, `mulaw` or `alaw` (telephone audio); mono.
- `sample_rate`: `16000` by default; 8000 to 48000 (`mulaw`, `alaw`: 8000).
- `diarize`: `true` labels each final, and each word, with its speaker.
- `timestamps`: `true` adds each word's times.
- `vocabulary_id`: a saved list of names and terms the transcript must get right (`POST /v1/vocabularies`, Admin key). A session can also send its own list at any time, `{"type": "vocabulary", "entries": ["Vatis Tech", "Ispas"]}`, answered with `vocabulary.applied`: https://platform.vatis.tech/docs/realtime/vocabularies.
- `commit`: what ends a segment. `vad` (the default): a pause of `vad_silence_s` (1.5 s). `manual`: your `{"type": "commit"}`. `turn` (Romanian models only), for voice bots: as soon as the speaker sounds finished, else after `vad_silence_s`, now the longest pause. `turn_sensitivity` (0 to 1, 0.5 by default, only with `commit=turn`): higher answers sooner and cuts more pauses inside a sentence. Each final then carries `end_reason`: `turn` (answer now), `pause`, `commit` or `end`: https://platform.vatis.tech/docs/realtime/end-of-turn.

Send raw audio in binary frames at the pace of real time (100 ms a frame gives the fastest text), and read the JSON messages: `session.started`, then `partial` (the segment so far, replaced by the next) and `final` (a finished segment, never changed). Send `{"type": "end"}` when the audio ends: the last finals come, then `session.ended`. The API keeps no transcript of a live session, so keep the finals. A web page never holds the key: the person's server makes a single-use token (`POST /v1/tokens`) and the page connects with `?token=`.

Every option and message, and whole programs: https://platform.vatis.tech/docs/realtime.

## 6. Keep the docs at hand

Once the first request works, offer the person two changes, so that every later session in this project works from the current docs rather than from what it remembers. Ask before each one, make it only if they agree, and tell them what you changed.

**The line in the project's instructions.** Add this line to the instructions file the project's agent reads at the start of a session: the one the project already has (`AGENTS.md`, `CLAUDE.md`, a rule in `.cursor/rules/`, `.github/copilot-instructions.md`), else a new `AGENTS.md` at the project's root.

```
Before writing code that calls the Vatis Tech API, read https://platform.vatis.tech/llms.txt and the pages it links that fit the task. The API changes: do not rely on remembered endpoints, fields or model names.
```

**The docs MCP server**, `https://platform.vatis.tech/docs/mcp` (Streamable HTTP, no sign-in; it reads only the public docs and changes nothing). With it, a later session searches these docs and reads only the pages it needs. Skip it if your client has it already. Add it the way the client you run in takes it, below; another client that supports MCP takes the address as it is, with no key and no header. It works from the next session, or once the client reloads its MCP servers. How to add it, for the person too: https://platform.vatis.tech/docs/agents.

**Claude Code**: run it in the project: it adds the server for this project, for this person only.

```bash
claude mcp add --transport http vatis-docs https://platform.vatis.tech/docs/mcp
```

**Cursor**: in `.cursor/mcp.json` in the project, merged into the file if it has one.

```json
{
  "mcpServers": {
    "vatis-docs": {
      "url": "https://platform.vatis.tech/docs/mcp"
    }
  }
}
```

**VS Code**: in `.mcp.json` at the workspace's root, merged into the file if it has one.

```json
{
  "mcpServers": {
    "vatis-docs": {
      "type": "http",
      "url": "https://platform.vatis.tech/docs/mcp",
      "tools": ["*"]
    }
  }
}
```

**Codex**: it writes `~/.codex/config.toml`, so the server is there in every project: say so when you ask.

```bash
codex mcp add vatis-docs --url https://platform.vatis.tech/docs/mcp
```

## 7. The full docs

Every page, in the docs' groups. Each one is also Markdown at its address plus `.md`.

### Get started

- [Introduction](https://platform.vatis.tech/docs): The Vatis Tech API turns speech into text, from a file or live, with times and speakers.
- [Quickstart](https://platform.vatis.tech/docs/quickstart): Go from an API key to your first transcript in five minutes: a file, then live audio.
- [Authentication and API keys](https://platform.vatis.tech/docs/authentication): Every request carries your API key, and a web page uses a single-use token instead.
- [Build with AI agents](https://platform.vatis.tech/docs/agents): Give your coding agent the current docs: a line in its instructions, the setup guide, the docs MCP server or Markdown pages.

### Guides

- [Batch transcription](https://platform.vatis.tech/docs/batch): Send a recording, or its address, and collect its text with words, times and speakers when it is done.
- [Batch transcription: Send now, collect later](https://platform.vatis.tech/docs/batch/send-now-collect-later): Every request is answered at once with the transcript queued: collect it when it is done, by asking for it or by having it posted to you.
- [Batch transcription: Webhooks](https://platform.vatis.tech/docs/batch/webhooks): Get a finished transcript posted to your server, signed so you know it came from us.
- [Batch transcription: Parameters](https://platform.vatis.tech/docs/batch/parameters): The form fields a request takes and the rules they follow, its headers, and files sent by their address.
- [Batch transcription: Idempotency](https://platform.vatis.tech/docs/batch/idempotency): Send a request again safely after a timeout: the same Idempotency-Key gets the first answer, and no second job starts.
- [Batch transcription: Manage transcripts](https://platform.vatis.tech/docs/batch/manage-transcripts): Read, list and delete your transcripts, who can read which, and how long they are kept.
- [Batch transcription: Exports](https://platform.vatis.tech/docs/batch/exports): Download a finished transcript as plain text or as SRT or WebVTT subtitles, with speaker names.
- [Batch transcription: Request errors](https://platform.vatis.tech/docs/batch/request-errors): The errors a transcription request can get, and what to do about each.
- [Real-time transcription](https://platform.vatis.tech/docs/realtime): Stream audio over a WebSocket while it is recorded, and get the text back as it is spoken.
- [Real-time transcription: Query parameters](https://platform.vatis.tech/docs/realtime/query-parameters): Every option of a session, set in the query of the WebSocket address.
- [Real-time transcription: Sending audio](https://platform.vatis.tech/docs/realtime/sending-audio): Raw audio in binary frames at the pace of real time: how much per frame, and the formats a session takes.
- [Real-time transcription: Messages](https://platform.vatis.tech/docs/realtime/messages): Every JSON message of a session: the ones you send and the ones you receive.
- [Real-time transcription: Partial and final text](https://platform.vatis.tech/docs/realtime/partial-and-final-text): How a partial grows into a final, what ends a segment, and which text to show and which to store.
- [Real-time transcription: End of turn](https://platform.vatis.tech/docs/realtime/end-of-turn): For voice bots: end each segment as soon as the caller sounds finished, and know what ended it, to answer sooner.
- [Real-time transcription: Speakers and channels](https://platform.vatis.tech/docs/realtime/speakers-and-channels): Label each final and each word with its speaker, get the text before its speakers, or transcribe a stereo call with each side labelled.
- [Real-time transcription: Vocabularies](https://platform.vatis.tech/docs/realtime/vocabularies): Give a live session or a file the names and terms it must get right, and get them written exactly as you listed them.
- [Real-time transcription: Ending a session](https://platform.vatis.tech/docs/realtime/ending-a-session): End a session without losing the last words, and what the server sends before it closes.
- [Real-time transcription: Live text in a web page](https://platform.vatis.tech/docs/realtime/live-text-in-a-web-page): Stream from a browser with a single-use token your server makes, so the page never holds your key.
- [Real-time transcription: Reconnect after a restart](https://platform.vatis.tech/docs/realtime/reconnect-after-a-restart): Connect again after a session ends early, and send the audio from where the transcript is complete.
- [Real-time transcription: Errors in a session](https://platform.vatis.tech/docs/realtime/errors-in-a-session): How a refused or failed session ends: its error message, its close code, and what to do.

### Endpoints

- [All endpoints](https://platform.vatis.tech/docs/endpoints): Every request the API takes, with its method and path, and where it is described.

### Reference

- [The transcript object](https://platform.vatis.tech/docs/transcript-object): Every field of a transcript: its text, words, times, confidence, speakers and segments.
- [Usage](https://platform.vatis.tech/docs/usage): How much audio your workspace transcribed, by day or month and by key, and every job and session.
- [Errors](https://platform.vatis.tech/docs/errors): Every refused request and every failed session says what went wrong in the same way: the shape and every code.
- [Limits and free credit](https://platform.vatis.tech/docs/limits): What a new workspace can do on its free credit, and every limit of the API.
