Skip to main content
The OpenAI API returns text, not files. Install doconda (or @doconda/sdk), pass doconda.tools() as tools in chat.completions.create and, when the model calls create_document, run it with run(): you get the Word file (.docx) and its PDF with their download links.

Steps

  1. Put your OpenAI key in OPENAI_API_KEY and your Doconda key (dashboard → API keys) in DOCONDA_API_KEY.
  2. Turn each tool into OpenAI’s function format.
  3. Run the loop: while the message has tool_calls, run each tool and hand the result back.
Already have the model’s text and don’t need an agent? Call doconda.documents.create(format="docx", content={"markdown": text}) directly with its answer.

What you get back

  • An editable Word file: the look lives in its styles (Normal, Heading 1…), so anything added later keeps the design.
  • status: ready, ready_with_warnings, needs_review or failed (not charged).
  • Links expire after 5 minutes; the agent gets fresh ones with get_document.

FAQ

Ask for it in the message: create_document accepts format: "pdf" (PDF only). A Word file always comes with its PDF.
Yes, the same code with AzureOpenAI(). See Azure OpenAI.
You pay per delivered document; creating from your own Markdown costs less than from a prompt. See pricing.

Keep reading