Skip to main content
POST /word/generate produces professional .docx output from a natural-language prompt. The agent handles heading hierarchy, line spacing, tables, images, footnotes, tracked changes, and complex layouts — all without you defining a template. Use it to automate proposals, contracts, business reports, letters, and any document you’d otherwise draft by hand. The agent auto-accepts its own inline diff on the backend, so edits apply immediately — no manual review step required.

Request parameters

prompt
string
required
Natural-language description of the document you want. Up to 10,000 characters. Describe the purpose, audience, tone, and structure. Explicit hints like “use two-column layout” or “legal/contractual tone” are respected.
run_id
string
Resume an existing run. Pass the run_id from a previous response to add sections, change tone, or update content in the existing document.
init_file
string
file_id of an existing .docx to edit in-place. Upload the file first with POST /files (purpose: "init"). The agent inspects the document structure and applies targeted edits.
context_files
array
Reference files the agent can cite in the document. Each entry is a file_id. The agent uses these as sources and can insert inline links.
image_assets
array
Images to embed in the document. Each entry is an object with image_id and tags. Upload images first with POST /images. If your prompt references images but none are attached, the preflight validator rejects the request upfront.
async
boolean
default:"false"
Set to true to run the job asynchronously. The response returns a task_id immediately. Use webhook_url to receive the result, or poll GET /tasks/{task_id}.
webhook_url
string
URL to receive a POST when the async job completes. See Webhooks.
file_name
string
Override the default output filename.
idempotency_key
string
Supply a unique key to safely retry requests without producing duplicate runs.

Quickstart

1

Generate a document

Send a prompt describing the document. The response includes a download_url for the finished .docx.
import requests

API = "https://backend.overtenai.com/api/v1"
KEY = "sk_live_..."

resp = requests.post(
    f"{API}/word/generate",
    headers={"Authorization": f"Bearer {KEY}"},
    json={
        "prompt": (
            "Write a formal acceptance letter for an engineering manager role "
            "at Acme Corp dated April 17, 2026. Signed by Jane Smith."
        ),
    },
)
print(resp.json()["download_url"])
2

Download the file

Fetch the download_url to retrieve the .docx. The URL is a signed link valid for 1 hour.

Response shape

A successful synchronous response looks like this:
{
  "run_id": "run_def456",
  "status": "completed",
  "download_url": "https://storage.overtenai.com/...",
  "summary": "3-paragraph acceptance letter with right-aligned date, sign-off block, and header.",
  "credits_used": 28,
  "duration_ms": 11450
}
FieldDescription
run_idUse this to resume the run or export to another format.
download_urlSigned URL for the .docx file. Valid for 1 hour.
summaryAgent’s description of what it built.
credits_usedCredits deducted for this call.

Common use cases

Reports

import requests

API = "https://backend.overtenai.com/api/v1"
headers = {"Authorization": f"Bearer sk_live_..."}

prompt = """
Produce a 4-page Q3 business review report for Acme SaaS:
- Executive summary (2 paragraphs)
- Revenue & growth (analysis paragraphs, one bullet list)
- Product highlights (3 subsections)
- Q4 priorities

Tone: professional, concise. Use Heading 1/2 hierarchy.
"""

resp = requests.post(f"{API}/word/generate", headers=headers, json={"prompt": prompt})
print(resp.json()["download_url"])
The agent writes in sections with a clean heading hierarchy, 1.15 line spacing, and an accent color on H1s.

Letters and memos

prompt = (
    "Write a formal termination letter. "
    "Recipient: Mr. John Doe, Senior Consultant, Acme LLC, 123 Broadway, NY 10001. "
    "Reason: ending of contract at end of current term (June 30, 2026). "
    "Tone: polite, firm. "
    "Include sign-off for Jane Smith, CEO."
)
resp = requests.post(f"{API}/word/generate", headers=headers, json={"prompt": prompt})

Editing an existing document

Upload your draft first, then pass init_file to edit in-place.
# 1. Upload
upload = requests.post(
    f"{API}/files",
    headers=headers,
    files={"file": open("draft_contract.docx", "rb")},
    data={"purpose": "init"},
).json()

# 2. Edit
resp = requests.post(f"{API}/word/generate", headers=headers, json={
    "prompt": "Replace the payment terms section with net-30 payment terms.",
    "init_file": upload["file_id"],
})
print(resp.json()["download_url"])
When editing, the agent inspects the document, generates a targeted change plan, auto-accepts the diff, and returns the updated .docx.

Including images

Upload images first, then reference them by image_id. Use tags to tell the agent where to place each image.
hero = requests.post(
    f"{API}/images",
    headers=headers,
    files={"file": open("logo.png", "rb")},
    data={"tags": '["logo"]'},
).json()

resp = requests.post(f"{API}/word/generate", headers=headers, json={
    "prompt": "Draft a company prospectus with our logo at the top",
    "image_assets": [{"image_id": hero["image_id"], "tags": ["logo"]}],
})

Iterating with run_id

Pass run_id to resume the same document across multiple turns.
# Turn 1 — draft
r1 = requests.post(f"{API}/word/generate", headers=headers, json={
    "prompt": "Draft a 3-section vendor proposal for a cloud migration project. Sections: Overview, Scope, Pricing.",
}).json()

# Turn 2 — refine tone
r2 = requests.post(f"{API}/word/generate", headers=headers, json={
    "run_id": r1["run_id"],
    "prompt": "Make the pricing section more concise and add a payment schedule table.",
}).json()

Exporting to other formats

Convert a completed run to PDF, HTML, plain text, or ODT using POST /runs/{run_id}/export.
export = requests.post(
    f"{API}/runs/{run_id}/export",
    headers=headers,
    json={"format": "pdf"},
)
print(export.json()["download_url"])
Supported export formats for Word runs: pdf, html, txt, odt.

Writing quality

The agent is tuned to produce senior professional prose. It avoids overused words (“leverage”, “utilize”, “robust”, “seamless”), filler transitions (“Furthermore”, “Moreover”, “In summary”), and clichéd phrases. If you need a specific tone, state it explicitly in your prompt — “formal academic”, “conversational but direct”, or “legal/contractual” — and the agent follows it.

Things to be aware of

  • Table of contents is not supported. If your prompt asks for a TOC, the agent skips it and notes the omission in summary.
  • Long documents (more than 5 pages) are built page-by-page. Add “first page preview only” to your prompt if you want a quick draft for review.
  • Short iteration with run_id is cheaper than starting over. Use follow-up turns to refine rather than regenerating from scratch.

Tips for better results

Specify the document’s purpose, audience, and tone upfront. “Write a one-page executive summary for a Series B investor audience, formal tone” gives the agent enough context to choose the right structure, vocabulary, and formatting automatically.
  • Break large documents into sections: draft one section at a time using run_id to build iteratively.
  • Use explicit structural hints for complex layouts: “use a two-column layout for the analysis section”, “start the chapter with a drop cap”.
  • For legal or compliance documents, specify the governing jurisdiction and any required clauses.
  • Ask for async: true on documents longer than 4 pages to avoid timeouts.
  • Runs and tasksrun_id lifecycle, task polling, and status values
  • Async vs sync — when to use async: true and how to handle results
  • Preflight — validate your request before committing credits
  • Credits — how generation costs are calculated