Now live New models for transcription and text-to-speech. AssemblyAI-STT-3.7 AssemblyAI-TTS-1
Insights & Use Cases

How to build a veterinary AI scribe: from exam audio to SOAP note

A Python tutorial for vet software teams: Vet Mode transcription, speaker labels, a schema-bound SOAP note through LLM Gateway, and checks that send doubtful lines back to the vet.

Abstract green cylinder illustration

Written by

Kelsey Foster

Published on

23 November 2026

A general speech model can hear a vet say Zydax and write Xanax. Both are real drugs, the sentence still reads fine, and the error lands in the medical record looking correct. That's the failure a veterinary AI scribe has to be built around, and it's why the transcription layer matters more than the prompt that writes the note.

If you run a clinic, you buy a scribe. If you build practice management software, a telehealth app or a clinic platform, you probably want the scribe inside your product, writing to your data model. This tutorial is for the second group. You'll build a Python veterinary AI scribe that takes an exam recording and produces a draft SOAP note a veterinarian can review and sign:

  1. Transcribe the exam with Vet Mode and speaker labels.
  2. Number every utterance so the note can cite its sources.
  3. Draft the SOAP note through LLM Gateway, bound to a JSON schema.
  4. Check the draft against the transcript and flag anything the vet needs to look at.

The full code is in the companion repo, kelsey-aai/veterinary-ai-scribe. For the design side (why vet visits behave differently from human ones, and what the record has to preserve), read ambient scribes for veterinary and legal first. This post is the code.

What a veterinary AI scribe does

A veterinary AI scribe records an exam or a dictation and drafts the structured record from it, usually a SOAP note: Subjective, Objective, Assessment and Plan. The veterinarian reviews the draft, edits it and signs it. The scribe never signs anything.

Vet visits make three parts of that harder than in human medicine:

  • The patient doesn't talk. Everything in Subjective comes secondhand from an owner, who reports what they saw and often guesses at what it means. The note has to keep "the owner thinks he ate something" separate from what the vet found on exam.
  • The room is loud and crowded. A vet, a technician and an owner talk over each other while someone restrains a patient that's barking or scrabbling on the table. You need speaker diarization to know who said what.
  • The vocabulary is its own. Vet drug brands like Cerenia, Heartgard and Apoquel rarely show up in human speech data, and some sound like human drugs. A model that hasn't been tuned for them will misspell them or swap in the human drug.

The pipeline

Stage What does it Why it matters for vet audio
Transcribe AssemblyAI-STT-3.7 with domain="veterinary-v1" Vet Mode corrects animal medication names, procedures and conditions
Separate speakers speaker_labels=True Keeps the owner's report apart from the vet's findings
Bias toward your formulary keyterms_prompt Catches clinic-specific drugs, breeds and procedures
Draft the note LLM Gateway with a JSON schema Every line cites the utterances it came from
Check Plain Python Lines without a source and drug names not in the transcript become review flags

Both halves run on one AssemblyAI API key: pre-recorded speech-to-text for the transcript and LLM Gateway for the note. There's no second vendor to add for the LLM step.

Transcribe Vet Exams With Vet Mode

Turn on Vet Mode with one parameter and get speaker-labeled transcripts of your exam recordings. Sign up and run your first transcript today.

Sign up free

Before you start

You need Python 3.9 or later and an AssemblyAI API key. New accounts get $50 in free credits for the speech APIs, which covers the transcription step. LLM Gateway isn't included in the free credits, so add a card to your account before the drafting step will run.

git clone https://github.com/kelsey-aai/veterinary-ai-scribe.git
cd veterinary-ai-scribe
python3 -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
export ASSEMBLYAI_API_KEY=<your-key>

You'll also need a recording. Use a real exam recorded with the owner's consent, or role-play one with a colleague. The scribe takes a local file or a public URL.

Step 1: Transcribe the exam with Vet Mode and speaker labels

Vet Mode is a beta add-on you turn on with one parameter, domain="veterinary-v1". Per the Veterinary Mode docs, it improves accuracy on veterinary terminology such as animal medication names, procedures and conditions. On pre-recorded audio it runs on AssemblyAI-STT-3.7 and Universal-2. This scribe uses AssemblyAI-STT-3.7:

from __future__ import annotations

import sys

import assemblyai as aai
from assemblyai.prerecorded.v2 import Transcriber, Transcript, TranscriptionConfig


def transcribe(audio: str, keyterms: list[str] | None) -> Transcript:
    config = TranscriptionConfig(
        speech_models=["assemblyai-stt-3-7"],
        language_detection=True,
        domain="veterinary-v1",  # Vet Mode (beta)
        speaker_labels=True,
        keyterms_prompt=keyterms,
    )
    transcript = Transcriber().transcribe(audio, config)
    if transcript.status == aai.TranscriptStatus.error:
        sys.exit(f"Transcription failed: {transcript.error}")
    return transcript

Three settings do the work here:

  • domain="veterinary-v1" runs the Vet Mode correction pass on the transcript.
  • speaker_labels=True splits the transcript into utterances with a speaker label (A, B, C) on each, so the next step knows who reported what.
  • keyterms_prompt takes a list of terms to bias toward. AssemblyAI-STT-3.7 accepts up to 1,000 words or phrases, with a maximum of 6 words per phrase.

Vet Mode handles common veterinary vocabulary. Keyterms handle what's specific to a clinic: its formulary, the compounded products it stocks, the breeds it sees most. Keep the list scoped to the visits you're transcribing. A 900-term list "just in case" can push the model toward a term you supplied and away from the one the vet said, which is the trap described in when keyterm prompting backfires. The repo ships a short starter file:

Apoquel
Bravecto
Cytopoint
Cerenia
Heartgard

For the full Vet Mode setup, including how it pairs with keyterms on species and breed names, see the veterinary transcription API guide.

Step 2: Number the utterances

A SOAP note is only trustworthy if a reviewer can check where each line came from. So before the transcript goes to the LLM, the scribe gives every utterance a number and a timestamp:

def number_utterances(transcript: Transcript) -> list[dict]:
    if not transcript.utterances:
        sys.exit("The transcript has no utterances. Was speaker_labels enabled?")
    return [
        {"index": i, "speaker": u.speaker, "start": u.start, "text": u.text}
        for i, u in enumerate(transcript.utterances)
    ]


def format_for_llm(utterances: list[dict]) -> str:
    return "\n".join(
        f"[{u['index']}] {ms_to_clock(u['start'])} Speaker {u['speaker']}: {u['text']}"
        for u in utterances
    )

The model sees lines like [14] 04:51 Speaker A: I'm going to give her an injection of Cerenia today. and is told to cite those numbers. Later, the checker turns them back into timestamps, so the vet can click from a line in the note to the moment in the exam.

Step 3: Draft the SOAP note with LLM Gateway

LLM Gateway is an OpenAI-compatible endpoint for models from Anthropic, OpenAI, Google and others, billed through the same AssemblyAI account. This scribe uses claude-sonnet-4-6 and structured outputs, so the response has to match a JSON schema you define.

The schema is where the vet-specific design lives. Each Subjective line records its source, so an owner's guess can't turn into a clinical finding. Each line in every section carries the utterance numbers it came from. Medications get their own list with dose, route, frequency and duration, and anything nobody said is written as "not stated":

SOAP_SCHEMA = {
    "type": "object",
    "properties": {
        "speaker_roles": {...},   # Speaker A = veterinarian, B = owner, ...
        "patient": {...},         # name, species, breed, age, sex, weight
        "subjective": {"type": "array", "items": _evidence_line({"source": {"type": "string", "enum": SOURCES}})},
        "objective": {"type": "array", "items": _evidence_line()},
        "assessment": {"type": "array", "items": _evidence_line()},
        "plan": {"type": "array", "items": _evidence_line()},
        "medications": {...},     # name, dose, route, frequency, duration + utterances
        "review_flags": {"type": "array", "items": _evidence_line()},
    },
    ...
}

(That's an excerpt. The full schema is in soap_schema.py in the repo.)

The system prompt sets the rules the schema can't enforce: use only what's in the transcript, cite utterance numbers, keep what the owner reported attributed to the owner, leave Assessment empty if the vet didn't state one, copy drug names exactly as transcribed, and flag ambiguity instead of guessing.

Then the call itself:

def draft_soap_note(transcript_text: str, model: str) -> dict:
    gateway = aai.LLMGateway()
    completion = gateway.chat.completions.create(
        model=model,
        messages=[
            {"role": "system", "content": SYSTEM_PROMPT},
            {"role": "user", "content": USER_PROMPT.format(transcript=transcript_text)},
        ],
        response_format={
            "type": "json_schema",
            "json_schema": {"name": "vet_soap_note", "schema": SOAP_SCHEMA, "strict": True},
        },
        post_processing_steps=[{"type": "json-repair"}],
        temperature=0,
        max_tokens=4000,
    )
    return json.loads(completion.choices[0].message.content)

post_processing_steps=[{"type": "json-repair"}] has the Gateway fix small JSON errors such as trailing commas before the response comes back. temperature=0 keeps the drafting as repeatable as the model allows. To try a different model, change one string; any model on the available models page that supports response_format works with the same code. The guide to choosing an LLM for structured extraction covers how to compare them on your own transcripts.

Step 4: Check the note against the transcript

The schema fixes the note's shape. To check its content, the scribe runs one more pass in plain Python against the transcript and adds review flags for three things:

def check_note(note: dict, utterances: list[dict]) -> dict:
    """Flag note lines a reviewer must look at before signing."""
    valid = {u["index"] for u in utterances}
    transcript_lower = " ".join(u["text"] for u in utterances).lower()
    checks = []

    for section in ("subjective", "objective", "assessment", "plan", "medications"):
        for line in note[section]:
            cited = line["utterances"]
            label = line.get("name") or line["text"]
            if not cited:
                checks.append({"text": f"{section}: no source utterance cited for '{label}'", "utterances": []})
            elif any(i not in valid for i in cited):
                checks.append({"text": f"{section}: cites an utterance that doesn't exist for '{label}'", "utterances": []})

    for med in note["medications"]:
        if med["name"].lower() not in transcript_lower:
            checks.append({
                "text": f"Drug name '{med['name']}' doesn't appear in the transcript. Confirm it against the audio.",
                "utterances": med["utterances"],
            })

    note["review_flags"] = note["review_flags"] + checks
    return note
  1. A line with no source. If the model can't point to an utterance, the line goes to review.
  2. A citation that doesn't exist. A cited utterance number outside the transcript is a sign the model invented the line.
  3. A drug name that isn't in the transcript. If the model "corrected" a drug name, normalized a brand to a generic or added one nobody said, it gets flagged.

Be clear about what that third check can and can't do. It catches drug names the LLM wrote that aren't in the transcript. It can't catch a word the transcript itself got wrong. If the transcript says Xanax, the note will say Xanax and pass the check. That's the error Vet Mode and your keyterms list are there to prevent, and it's why the vet's review stays in the loop.

Run the whole thing:

python scribe.py exam.mp3 --keyterms keyterms.example.txt

The scribe writes three files to output/: transcript.md (the numbered transcript), note.json (the structured note) and note.md, a readable draft with timestamps after every line and a "Review before signing" section at the bottom. Already have a transcript? --transcript-id re-drafts the note without paying to transcribe again, which makes prompt changes cheap to test.

Hear Vet Mode On Your Own Audio

Upload an exam recording in the playground and see how speaker labels and veterinary terms come back before you write any code.

Try playground

Taking it to production

Go live during the exam

This tutorial transcribes after the visit, which is how most scribes work: the vet records, then reviews the note between appointments. If you want the transcript to fill in while the exam runs, Vet Mode also works on streaming with AssemblyAI-STT-3.7-Realtime, AssemblyAI-STT-3.7-Realtime-Agent and Universal-3.6 Pro Realtime. You set domain to "veterinary-v1" as a connection parameter when you open the WebSocket, and the streaming Veterinary Mode docs show the setup. The SOAP step stays the same: send the finished transcript to LLM Gateway when the session ends.

Write to the practice management system

The scribe produces JSON on purpose. Mapping note.json into your PIMS or EHR fields is your integration layer's job, and the structured shape turns it into a field mapping. Keep the utterance citations when you store the note. Vet records move between general practices, specialists and emergency clinics, and the next reader may have no other context for where a line came from.

Handle consent and client data

Record only with the owner's consent, and follow your clinic's and your jurisdiction's rules for recording and storing client conversations. Decide up front how long you keep audio and transcripts. You can delete a transcript you no longer need with the delete transcript endpoint.

Know what it costs

All prices are pay-as-you-go list prices from the pricing page:

Component Price
AssemblyAI-STT-3.7 (pre-recorded) $0.21/hr
Vet Mode add-on $0.15/hr
Speaker diarization $0.02/hr
Keyterms prompting (optional) $0.05/hr
Transcription total $0.38/hr, or $0.43/hr with keyterms
SOAP note with claude-sonnet-4-6 on LLM Gateway $3 per 1M input tokens, $15 per 1M output tokens

Finished vet scribes are mostly sold per veterinarian per month. Here, transcription is billed per hour of audio, so your cost follows exam minutes, which matters if you're adding a scribe to software that serves hundreds of practices.

Where to take it next

The pipeline here is the same one behind a human-medicine scribe, with three vet-specific changes: Vet Mode in place of Medical Mode, a Subjective section that tracks who reported each line, and a check that keeps the LLM from inventing drug names. If your product also serves human clinics, the AI medical note-taker build shows the same pattern with domain="medical-v1", and the AI scribes use case page covers the wider building blocks.

From here, the work that pays off is evaluation on your own exams. Record a set of real visits with consent, have vets mark every error in the drafts, and sort the errors by layer: transcript (fix with keyterms), attribution (fix in the prompt) or note structure (fix in the schema). The citations make that sorting fast, because every bad line points at the utterance it came from.

Build Your Veterinary AI Scribe

Get an API key, clone the repo and turn your first exam recording into a draft SOAP note with Vet Mode and LLM Gateway.

Sign up free

Frequently Asked Questions (FAQs)

What is a veterinary AI scribe?

A veterinary AI scribe is software that records a vet exam or dictation and drafts the medical record from it, usually as a SOAP note. The veterinarian reviews, edits and signs the draft, and stays responsible for the final record. Products such as Scribenote, ScribbleVet, CoVet and VetRec sell finished scribes to clinics; software teams build their own on a speech-to-text API and an LLM.

How do I build an ambient scribe for veterinary consultations?

Transcribe the consultation with a veterinary-tuned speech model and speaker diarization, then send the speaker-labeled transcript to an LLM with a schema for the note. With AssemblyAI, that's domain="veterinary-v1" and speaker_labels=True on AssemblyAI-STT-3.7, then LLM Gateway with structured outputs. Add checks that flag note lines without a source in the transcript, and keep the veterinarian's review as the final step.

What does SOAP mean in veterinary medicine?

SOAP stands for Subjective, Objective, Assessment and Plan, the four sections of a standard clinical note. In vet medicine, Subjective is the history the owner reports, Objective is the exam findings and test results, Assessment is the veterinarian's impression and Plan is treatment, client instructions and follow-up.

Can I use a human medical transcription model for vet exams?

You can, but it's tuned for the wrong vocabulary. Human-medicine models can swap veterinary drugs for similar-sounding human ones, such as writing Xanax for Zydax. AssemblyAI's Medical Mode (domain="medical-v1") targets human medication names; Vet Mode (domain="veterinary-v1") targets veterinary terminology, so use Vet Mode for animal patients.

Does Vet Mode work in real time?

Yes. Vet Mode is in beta on streaming with AssemblyAI-STT-3.7-Realtime, AssemblyAI-STT-3.7-Realtime-Agent and Universal-3.6 Pro Realtime. You set domain to "veterinary-v1" as a connection parameter when you open the WebSocket, and you can combine it with streaming diarization and keyterms prompting.

How much does it cost to run a veterinary AI scribe on AssemblyAI?

Transcription with AssemblyAI-STT-3.7, Vet Mode and speaker diarization costs $0.38 per hour of audio at list price, or $0.43 per hour with keyterms prompting. The SOAP note is billed separately by LLM Gateway per token; claude-sonnet-4-6 is $3 per million input tokens and $15 per million output tokens. New accounts get $50 in free credits for the speech APIs, which don't cover LLM Gateway.