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
- Put your Doconda API key (dashboard → API keys) in
DOCONDA_API_KEYand your model provider’s key in its usual variable (here,ANTHROPIC_API_KEY; any AI SDK provider works). - Install the dependencies:
npm install ai @ai-sdk/anthropic @ai-sdk/react @doconda/sdk. - Create the chat route (server side) and the page:
.docx and PDF links. The
tools run in your route, so the API key never reaches the browser.
What you get back
The tool returns this summary to the model:links: the file (docx,pptxorxlsx) and its PDF, or the PDF alone withformat: "pdf".- Links expire after 5 minutes. If the user comes back later, the model calls
get_documentfor fresh ones. status:readyorfailed. A failed document isn’t charged.
FAQ
Can I use the AI SDK MCP client instead?
Can I use the AI SDK MCP client instead?
Yes:
createMCPClient from @ai-sdk/mcp against https://api.eu.doconda.com/mcp, with your key in
Authorization: Bearer. See AI SDK.Does it work with OpenAI, Gemini or Bedrock?
Does it work with OpenAI, Gemini or Bedrock?
Yes. Change
model: the tools are the same with any AI SDK provider.How much does it cost?
How much does it cost?
Each document is billed to the key’s project: €0.50 from a prompt at
standard, €0.15 at fast. See
pricing.