Skip to content
All posts

Building agents-hub · Part 8 of 9 · AI Engineering

Claude-quality documents on an Azure key

I wanted the Docs agent to make PDFs as good as Claude does, with only an Azure OpenAI key. Copy the recipe, not the model: a sandbox, a playbook, style kits and real photos.

Photo of Kush Ahuja

Kush Ahuja

· 2 min read

When Claude makes a PDF, it looks designed. My agent’s first PDFs looked generated. I only had an Azure OpenAI key, and the goal was simple to say: make them as good as Claude’s.

The insight was that Claude’s documents are not good because of the model alone. They come from a recipe: code running in a sandbox with real document libraries, following a written playbook. The recipe can be copied without copying the model.

Probe before you plan

Before writing any agent code, I ran a live probe on our Azure resource using the Responses API code interpreter. It made a PDF and a DOCX, downloaded both, uploaded a PDF back and changed its title in place with PyMuPDF. All over plain fetch, no SDK. The sandbox ships reportlab, WeasyPrint, PyMuPDF, pdfplumber, python-docx, openpyxl, pandas and matplotlib. It does not have LibreOffice, so old Office formats go through Google Drive for conversion.

The playbook is the training

No fine-tuning. "Training" here means a written playbook plus helper scripts the agent loads into its sandbox: how to set margins, pick type sizes, lay out tables, check the output. Customers have a handful of samples at most, which is far too few to train on, but plenty to learn a look from.

Style kits: "make it in office style"

Customers upload a few of their own documents per category. The agent learns a style kit once per upload: a short profile of labelled lines (Page, Title, Headings, Body text, Accent colours, Logo, Header, Footer, Tables, Numbers and dates, Tone), plus the colours, fonts and logo. It comes from exact measurements of the files and the model looking at page one.

  • Measurements beat guesses. A learned margin was wrong until margins were computed from everything drawn on the page, not just the text.
  • Every line is editable, and the customer’s edits survive the next learn.
  • A kit is picked by name in the message. Only when someone describes a look without a known name does one small model call map it ("office style" becomes the Work kit).

Live data from outside the sandbox

The sandbox has no internet, so reports about stock prices or the news had nothing real to work with. The agent got server-side tools instead: public finance endpoints for prices, Google News RSS for headlines, a search tool and a page reader. They are free and keyless, and unofficial, which means rate limits. One request for all symbols, a 60 second cache and a second host on retry keep it stable.

Real photos, or no photo

Asked for a cafe guide, the model drew fake coffee cups. Now a find_images tool fetches a named place’s own Google Maps photos, and Creative Commons photos from Openverse or Wikimedia for everything else. Each one prints its credit line underneath. If there is no real photo, there is no picture. Never a drawn stand-in.

A typical job costs about ₹5 to ₹10 and takes one to four minutes. That is why long jobs needed a design of their own, which is part 6 of this series.