+

Generate Word, Excel, PowerPoint and PDF
with Mistral

Code

Python or TypeScript

Mistral writes. Doconda lays out.

Connect Doconda with Mistral function calling and in Le Chat and get finished, editable, reviewed Word, Excel, PowerPoint and PDF files.

  1. 01Install the SDKpip install doconda or npm install @doconda/sdk, and your API key.
  2. 02Give your agent the toolsDoconda's tools, in Mistral's format.
  3. 03Your agent delivers the fileYour agent gets the link to the reviewed file.
import { Mistral } from "@mistralai/mistralai"
import { Doconda } from "@doconda/sdk"

const mistral = new Mistral({ apiKey: process.env.MISTRAL_API_KEY })
const docondaTools = new Doconda().tools()
const tools = docondaTools.map((t) => ({ type: "function" as const, function: { name: t.name, description: t.description, parameters: t.inputSchema } }))
const messages: any[] = [{ role: "user", content: "Redacta un memo para el equipo: la oficina cierra el viernes" }]

while (true) {
  const res = await mistral.chat.complete({ model: "mistral-large-latest", messages, tools })
  const message = res.choices[0]?.message
  if (!message) break
  messages.push(message)
  if (!message.toolCalls?.length) {
    console.log(message.content)
    break
  }
  for (const call of message.toolCalls) {
    const args = typeof call.function.arguments === "string" ? JSON.parse(call.function.arguments) : call.function.arguments
    const result = await docondaTools.find((t) => t.name === call.function.name)!.run(args)
    messages.push({ role: "tool", name: call.function.name, toolCallId: call.id, content: JSON.stringify(result) })
  }
}

FAQ

Common questions

01 / 03

How do I generate a Word file with Mistral?

Pass Doconda's tools to Mistral function calling; when the model uses them, you get the Word file and its PDF.

The document API for AI agents, ready for production.