What the example includes
- Streamed edits: Apply cumulative document revisions while the agent is still working, with or without visible tracked changes.
- Document sessions: Upload the DOCX once, use a session ID for every tool call, and clean up the session after each agent turn through the Vespper SDK.
- Document context: Send selected Word content and pasted images alongside the user’s request.
- Agent controls: Choose a model, stop an active run, and set the tracked-change author.
Demo
Prerequisites
- Microsoft Word desktop for macOS or Windows
- Node.js 22.13 or newer
- A Vespper account
- A model-provider API key for OpenAI, Anthropic, or Google
Set up the add-in
Get a Vespper API key
Sign up for Vespper, then create a key on the
API keys page. Copy the
sk_live_...
secret immediately; it is shown only once.Configure environment variables
Copy the environment template:Add your Vespper key and the key for the model provider you want to use:Only one model-provider key is required:
- macOS or Linux
- Windows PowerShell
.env
GPT 5.6 Sol is the default. Set
WORD_AGENT_MODEL to start with another
model:.env
Launch Word
https://localhost:3100, launches Word, and sideloads the add-in. If the
task pane does not open automatically, choose
Home → Add-ins → Vespper.Open https://localhost:3100/health and
confirm that both vespperConfigured and agentConfigured are true.Try an edit
- Open and save a Word document.
- Open the Vespper task pane.
- Ask for an edit, such as
Replace every occurrence of DFAT with Hello. - Optionally select document text or paste images into the prompt.
- When Track Changes is on, review the streamed edits under Review → Track Changes.
Vespper Agent.
How the integration works
The local API server opens a document session and auto-patches Mastra’s Vespper tools with thevespper SDK. The SDK supplies session, author, and
tracked-change metadata and retains each updated DOCX revision.
The add-in wraps the patched edit_document tool to parse edits while the model
is still producing its arguments. That wrapper adds the streaming batch ID and
edit index, while the SDK continues to handle the standard Vespper metadata.
Each committed revision is then sent to Word as an edit_applied event.
Development commands
View the complete example on GitHub
Browse the source code, manifest, and standalone README.

