> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doconda.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to make an LLM return an Office file

> How to get an LLM like GPT, Claude or Gemini to return a real Word, PowerPoint or Excel file instead of text.

An LLM returns text, not files. To get a Word, PowerPoint or Excel file, ask the model for the content in Markdown and
pass it to Doconda with the `format` you want (`docx`, `pptx`, `xlsx` or `pdf`). Or give your agent Doconda's tools
with `doconda.tools()` and let it create the file itself.

## The problem in practice

* The model answers with Markdown or a code block, not a `.docx` you can download.
* If you ask it to write the code that builds the file, you have to run it and debug whatever fails.
* A file that is generated without errors can still open badly: overflowing tables, text that doesn't fit the slide.
* Each format (Word, PowerPoint, Excel) needs its own library and its own code.

## The solution with Doconda

With the text your LLM already returned:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  from pathlib import Path
  from doconda import Doconda

  doconda = Doconda()  # reads the key from DOCONDA_API_KEY
  markdown = "# Q3 report\n\n## Sales\n\n- Up 12%"  # your LLM's answer
  doc = doconda.documents.create(format="pptx", content={"markdown": markdown})
  Path("report.pptx").write_bytes(doconda.documents.download(doc["id"], "pptx"))
  ```

  ```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  import { writeFile } from "node:fs/promises"
  import { Doconda } from "@doconda/sdk"

  const doconda = new Doconda()
  const markdown = "# Q3 report\n\n## Sales\n\n- Up 12%" // your LLM's answer
  const doc = await doconda.documents.create({ format: "pptx", content: { markdown } })
  await writeFile("report.pptx", await doconda.documents.download(doc.id, "pptx"))
  ```
</CodeGroup>

Or as a tool for your agent, for any model with function calling. Each one has `name`, `description`,
`input_schema` (JSON Schema) and `run(args)`:

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  tools = doconda.tools()
  ```

  ```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  const tools = doconda.tools()
  ```
</CodeGroup>

How to connect them on each platform: [Doconda in your agent](/en/agents/introduction).

## What you get back

* The file you asked for; Word, PowerPoint and Excel also come with their PDF.
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed` (not charged).
* A report (`documents.report(id)`) with anything worth checking before you send it.
* With tools, your agent gets a short summary (status and links) it can pass on to the user.

## FAQ

<AccordionGroup>
  <Accordion title="Can ChatGPT or Claude generate a .docx file from the API?">
    The model's answer is text. Ask it for the content in Markdown and turn it into a `.docx` with
    `documents.create(format="docx", content={"markdown": ...})`, or let the agent call the `create_document` tool.
  </Accordion>

  <Accordion title="How do I generate a PowerPoint with an LLM?">
    Use `format="pptx"` with your LLM's Markdown in `content`. With no content of your own, describe the presentation
    in `prompt` and Doconda writes it. It comes out in 16:9 and with its PDF.
  </Accordion>

  <Accordion title="Does it work with my agent framework?">
    Yes. There is an MCP server, SDK tools for Claude, OpenAI, Gemini, Bedrock, Vertex AI and the AI SDK, and the REST
    API. The full list is in [Doconda in your agent](/en/agents/introduction).
  </Accordion>
</AccordionGroup>

## Keep reading

* [Doconda in your agent](/en/agents/introduction): MCP, SDK tools and API.
* [Create](/en/guides/create) and [Review](/en/guides/review).
* [Python SDK](/en/sdk/python) and [TypeScript SDK](/en/sdk/introduction).
* [Examples on GitHub](https://github.com/B-C-Software/doconda-examples).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.