What you need
- A Next.js project with the App Router, on Node 20 or later.
- A Doconda API key in
DOCONDA_API_KEY. Create one in the dashboard, under API keys. - Your model provider’s key. This tutorial uses Anthropic (
ANTHROPIC_API_KEY); any AI SDK provider works.
Build the chat
1
Install the dependencies
2
Create the chat route
doconda.tools() returns Doconda’s tools (create_document, edit_document, convert_file, upload_file,
get_document…), each with a name, a description, a JSON Schema and run(). Wrap each one as an AI SDK tool
and pass them to streamText. Create app/api/chat/route.ts:app/api/chat/route.ts
3
Create the chat page
useChat sends the messages to /api/chat and renders the reply as it arrives. Replace app/page.tsx:app/page.tsx
4
Run it
http://localhost:3000 and type “Make me a welcome letter for a new client”.Result
The model callscreate_document with format: "docx". The tool waits until the file is ready and returns something
like this to the model:
get_document and gets fresh ones.
create_document waits up to about 4 minutes for the finished document: about a minute at quality: "fast", a few
minutes at standard. If it takes longer, it returns the id and status, and the model checks later with
get_document. If your host limits how long a request may run, raise that limit for this route to 300 s.run() doesn’t throw: it returns { error, message } (plus fields on a validation error),
so the model can read the problem and tell the user.
Next steps
Use the AI SDK guide
The full integration, also with the MCP client.
Call the TypeScript SDK directly
Every method, to call Doconda without an agent.
Browse the examples
Complete, runnable projects on GitHub.