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
- Put your OpenAI key in
OPENAI_API_KEYand your Doconda key (dashboard → API keys) inDOCONDA_API_KEY. - Turn each tool into OpenAI’s
functionformat. - Run the loop: while the message has
tool_calls, run each tool and hand the result back.
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_revieworfailed(not charged).- Links expire after 5 minutes; the agent gets fresh ones with
get_document.
FAQ
Can I download the file on my server instead of passing the link?
Can I download the file on my server instead of passing the link?
Yes. With the
id the tool returns, doconda.documents.download(id, "docx") gives you the bytes.What if I want a PDF?
What if I want a PDF?
Ask for it in the message:
create_document accepts format: "pdf" (PDF only). A Word file always comes with its
PDF.Does it work with Azure OpenAI?
Does it work with Azure OpenAI?
Yes, the same code with
AzureOpenAI(). See Azure OpenAI.How much does it cost?
How much does it cost?
You pay per delivered document; creating from your own Markdown costs less than from a prompt. See
pricing.
Keep reading
- OpenAI: the full guide, also with OpenAI Codex.
- Quickstart.