Skip to main content
Turn doconda.tools() into AI SDK tools with tool() and jsonSchema(), and pass them to streamText in your chat route. When the user asks for a document, the model calls create_document and writes the download link into its answer, which useChat renders.

Add file generation to the chatbot

  1. Put your Doconda API key (dashboard → API keys) in DOCONDA_API_KEY and your model provider’s key in its usual variable (here, ANTHROPIC_API_KEY; any AI SDK provider works).
  2. Install the dependencies: npm install ai @ai-sdk/anthropic @ai-sdk/react @doconda/sdk.
  3. Create the chat route (server side) and the page:
Ask “Make me a Word memo: the office is closed on Friday”, and the bot replies with the .docx and PDF links. The tools run in your route, so the API key never reaches the browser.
A tool call waits up to about 4 minutes for the document: about a minute at fast, a few minutes at standard; after that it returns the id and status for get_document. Set the route’s maxDuration (300 s above) within your hosting plan’s limit, or the function is cut off before the link arrives.

What you get back

The tool returns this summary to the model:
  • links: the file (docx, pptx or xlsx) and its PDF, or the PDF alone with format: "pdf".
  • Links expire after 5 minutes. If the user comes back later, the model calls get_document for fresh ones.
  • status: ready or failed. A failed document isn’t charged.

FAQ

Yes: createMCPClient from @ai-sdk/mcp against https://api.eu.doconda.com/mcp, with your key in Authorization: Bearer. See AI SDK.
Yes. Change model: the tools are the same with any AI SDK provider.
Each document is billed to the key’s project: €0.50 from a prompt at standard, €0.15 at fast. See pricing.
For a step-by-step build, see a Vercel AI SDK chatbot that returns a Word file.