Document assistant
Create and revise editable structured templates with bounded model and render usage.
In Templates, open Create with document assistant, describe the document, and supply sample JSON and branding instructions. For an existing structured template, open its editor and choose Revise with document assistant. Revisions start from the saved template; save any manual changes first. HTML templates are not supported by this milestone.
The assistant proposes a draft, validates mappings, renders a PDF through the existing isolated renderer and inspects its text. It can revise once after inspection. It never saves over an existing template, publishes, emails documents or changes delivery settings. Choose Open editable draft for review, inspect every preview page, edit and save, then explicitly choose Publish when ready. Repeat API generation uses the approved template and version; the model is not called during document generation.
Operator configuration
Section titled “Operator configuration”Configure OPENAI_API_KEY and OPENAI_MODEL on the API service, plus:
AGENT_INPUT_USD_PER_MILLION: the model’s current input price in USD per million tokens.AGENT_OUTPUT_USD_PER_MILLION: its current output price, including reasoning tokens, in USD per million tokens.AGENT_RUN_BUDGET_USD: maximum reserved model spend per run, default0.25.
Prices must be positive, finite and kept current by the operator. Use the highest applicable input/output rate; cached-input discounts are deliberately ignored. Before each paid request, the service reserves a conservative UTF-8 byte bound on input tokens (with tool/framing allowance) plus the full output-token allowance. A request that would exceed the configured cap is not sent. Reservations are not refunded on errors or missing usage. Reported token usage and estimated cost are recorded separately from reservations. This cap depends on the configured prices accurately bounding provider charges; it is not an account-wide provider spending cap.
Model costs are separate from the $10/month Google Cloud hosting target. Hosting budget alerts do not stop spending. Each user-triggered run is limited to 10 host steps, two model calls, two renders, 2,500 output tokens per call and 45 seconds. One run per workspace is allowed at a time. There are no scheduled or event-triggered agent runs.
The model receives only the supplied instructions, sample, branding, selected workspace template and findings. Use synthetic or redacted samples. Server credentials are never included in prompts or results. Run records contain draft/sample content and usage in the workspace database; apply the same retention and access controls as other template records.
Browser account authentication is required; API keys cannot start or read assistant runs.
POST /v1/ai/runs accepts:
{ "id": "a-client-generated-uuid", "prompt": "Create a branded invoice with an item table", "branding": "Studio North, forest green, concise typography", "sample": { "recipient": { "name": "Example Customer" }, "items": [{ "quantity": 2, "unitPrice": 50 }], "total": 100 }}Optional templateId must belong to the current workspace. The optional unique id lets a client inspect or cancel while the POST is pending. POST waits for completion and returns id, status, proposed draft, findings, steps, renders, modelCalls, token counts, reservedUsd, actualUsd and usageComplete. Status is review, failed, cancelled or budget_exceeded. Only review means all preview checks completed; it does not mean approved or free of findings.
GET /v1/ai/runs/:id reads progress or the saved result. DELETE /v1/ai/runs/:id cancels a running request. Cancellation stops new tool calls; an already dispatched render may finish, and a provider may still charge for an interrupted request. Cross-instance cancellation is enforced by conditional checkpoint writes before starting each tool. Reported usage arriving after cancellation is retained without changing the cancelled status. Disconnecting the POST also cancels the local run. Runs are request-bound, not durable background jobs: process interruption does not replay paid calls. After 65 seconds, reads mark an abandoned run failed. Reservations remain in its last checkpoint.
The legacy POST /v1/ai/template now uses the same bounded pipeline and configuration but returns only the draft for compatibility. New clients should use /v1/ai/runs to show findings and usage.
What the checks cover
Section titled “What the checks cover”Missing or non-scalar template fields, values exceeding the renderer’s 500-character cell limit, text outside PDF page boundaries and pages without body text produce findings. Numeric invoice totals are checked only for items[].quantity × items[].unitPrice + tax − discount = total; tax and discount are optional numeric amounts. Other schemas and formatted currency strings require manual arithmetic review. The supplied sample is preserved, including an inconsistent total.
PDF text inspection cannot prove visual correctness: clipping within a page, overlapping elements, images, unusual reading order and every kind of overflow still require visual review. Preview inspection is limited to 30 pages. PDF upload extraction/OCR, Docling evaluation and business-event delivery workflows are follow-on work, not enabled here.