From data to a shareable single page: model-drafted reports

APIKeyAnthropicFree · Updated 2026-11-22 · 8 min read

Laptop and phone side by side on a cafe table beside a folder
A single HTML file reads well on any screen.

People who build tools for sending decks and PDFs to clients have noticed an unexpected trend: users increasingly upload single HTML files produced by chat assistants instead. A self-contained page can hold text, tables, simple charts and interactive sections, opens in any browser, and is easier to update than a slide deck. For many weekly updates and project summaries, HTML is quietly becoming the default format.

This guide is for developers and analysts who want to produce such reports from their own scripts rather than by copying from a chat window. It shows a repeatable approach: keep your data and numbers in code, let a language model write the prose and structure, assemble a single file with inline styles, check it before sending, and decide how to share it. The examples use a free OpenAI-compatible endpoint, but the method works with any model.

Frequently asked questions

What is a self-contained HTML report?

A single .html file with its styles, and optionally its scripts and images, embedded inside. It needs no server and no external files, so it can be emailed, attached or uploaded and still display correctly.

Why use HTML instead of PDF or slides?

HTML reflows on phones, supports links, collapsible sections and simple interactivity, and is easy to generate from code. PDF is better for fixed layouts and printing; slides are better for live presentations.

Should the model calculate the numbers in the report?

No. Compute totals, averages and changes in code and pass the results to the model. Models make arithmetic slips and may round inconsistently. The model's job is to explain the numbers, not produce them.

How does a model-written page differ from a template?

A template has fixed structure and fills in values. A model can adapt the narrative, highlight what changed and phrase it for the audience. A good setup combines both: a template for the frame, the model for the prose.

Is it safe to open HTML a model generated?

Generated HTML can contain scripts or links you did not intend. For reports you send to others, strip scripts unless you need them, check links and review the file. Treat it like any untrusted input.

Which is better for report prose, Claude or a free open model?

Claude and other large commercial models usually write more polished, better-organised prose and follow complex style guides more reliably. A smaller open model is adequate for routine status updates, especially with a clear template and examples.

Can a report include charts without external libraries?

Yes. Simple bar charts can be drawn with inline SVG or styled HTML elements generated in your code. This keeps the file self-contained and avoids loading scripts from the internet.

How large can the model's output be on the free endpoint?

An answer can be up to 16,000 tokens, within a 32,000-token context. That is enough for a long report section. For larger reports, generate sections separately and assemble them in code.

Step by step

  1. Compute the facts — Load your data and calculate every figure the report will mention in code, then put them in a compact JSON block.
  2. Prompt for a fragment — Ask the model for an HTML fragment using a short list of allowed tags and only the numbers you supplied.
  3. Sanitise the output — Clean the fragment with an allow-list sanitiser such as nh3 and escape every other value you insert.
  4. Assemble the page — Insert the cleaned fragment into a fixed page shell with inline styles and any code-generated charts.
  5. Check and send — Verify numbers against the JSON, open the file at phone width, read it once yourself, then share it.

Why single-file HTML is winning for updates

Decks are designed for a speaker; PDFs are designed for paper. Most client updates are read alone, on a laptop or a phone, often in a hurry. An HTML page fits that reading situation: it scrolls naturally, adapts to screen width, and can hide detail behind expandable sections so the summary stays short.

It is also the format language models produce most fluently. They have seen vast amounts of HTML and CSS, so asking for a clean, readable page is a request they handle well. The craft is in controlling what goes in and checking what comes out.

One file, no hosting

Because everything is inline, the file can travel as an attachment and still render. No server, no broken image links, no dependency on a CDN that might be blocked on the recipient's network.

Easy to diff and version

HTML is text, so reports can live in version control. You can see what changed between this week and last week line by line, which is impossible with binary slide formats.

Keep facts in code, prose in the model

The most common failure of model-written reports is wrong numbers presented beautifully. Avoid it by design: your script loads the data, computes every figure the report will mention, and passes them to the model as a compact JSON block. The prompt instructs the model to use only those values and never to compute new ones.

This division also makes reports reproducible. Rerunning with the same data gives the same figures, even if the wording varies. Reviewers check numbers against the JSON, not against the model's arithmetic.

Give the model the audience

A report for an engineering lead and one for a client executive use the same numbers differently. State the audience and the decision they need to make. That single line shapes the narrative more than any formatting instruction.

  • Compute totals, percentages and period-over-period changes in code.
  • Round values once, in code, to the precision you want displayed.
  • Pass labels and units explicitly, so the model does not guess them.
  • Include a short list of notable events the model should mention.
Workbench with measured boards and a glue pot
Numbers come from code; the model supplies the joinery of prose.

Generating the body with a constrained prompt

Ask the model for an HTML fragment, not a full page, using a small set of allowed tags. Your code wraps the fragment in a fixed page shell with your styles. This keeps branding consistent and stops the model from inventing its own CSS or pulling in external fonts and scripts.

The example sends computed metrics to free-ai on the keyless endpoint and asks for a fragment limited to headings, paragraphs, lists and tables.

Section by section for long reports

For multi-part reports, request each section separately with only the data it needs. Smaller prompts are more reliable, easier to retry and stay well inside the context window.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.apikeyanthropicfree.com/v1", api_key="free")

metrics = {
    "period": "Week 46",
    "tickets_closed": 128, "tickets_closed_prev": 104,
    "median_response_hours": 3.2, "median_response_hours_prev": 4.1,
    "notable": ["Migrated billing service", "Two incidents, both resolved same day"],
}

prompt = (
    "Write the body of a weekly status report for a client project manager. "
    "Use ONLY the numbers in the JSON; do not calculate new numbers. "
    "Output an HTML fragment using only <h2>, <p>, <ul>, <li>, <table>, <tr>, <th>, <td>, <strong>. "
    "No <html>, <head>, <style> or <script>.\n" + json.dumps(metrics)
)

r = client.chat.completions.create(
    model="free-ai",
    messages=[{"role": "user", "content": prompt}],
    temperature=0.3,
    max_tokens=2000,
)
fragment = r.choices[0].message.content.strip().strip("`").removeprefix("html").strip()
open("fragment.html", "w", encoding="utf-8").write(fragment)

Sanitising and assembling the final file

Never paste model output straight into a page you send to others. Even with clear instructions, a model may emit a script tag, an inline event handler or a link to somewhere unexpected. Run the fragment through an HTML sanitiser with an allow-list of tags and attributes, then insert it into your shell.

The older bleach library is deprecated; nh3 is a fast, maintained allow-list sanitiser with a similar idea and a very small API, which is all this step needs.

Escape anything that is not the fragment

Titles, client names and labels inserted by your code should be escaped with html.escape. The sanitiser protects the model's fragment; escaping protects everything else.

Inline SVG charts from code

If you need a chart, generate a simple SVG bar chart in Python from the same metrics and insert it after sanitising the fragment. Code-drawn charts are exact; model-drawn ones are not.

Retry on malformed fragments

If the fragment is empty or obviously broken, retry once with a stricter instruction before falling back to a plain template.

# pip install nh3
import html
import nh3

ALLOWED = {"h2", "p", "ul", "li", "table", "tr", "th", "td", "strong"}
fragment = open("fragment.html", encoding="utf-8").read()
clean = nh3.clean(fragment, tags=ALLOWED, attributes={})

title = "Week 46 status"
page = f"""<!doctype html>
<html lang="en"><head><meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{html.escape(title)}</title>
<style>
body{{font:16px/1.55 system-ui,sans-serif;max-width:760px;margin:2rem auto;padding:0 16px;color:#1d1d1f;background:#fff}}
table{{border-collapse:collapse;width:100%}}th,td{{border:1px solid #ddd;padding:6px 8px;text-align:left}}
</style></head><body>
<h1>{html.escape(title)}</h1>
{clean}
</body></html>"""
open("report.html", "w", encoding="utf-8").write(page)
print("wrote report.html")
Sieve catching stones over a bowl of clean water
Sanitise generated markup before it reaches a reader.

Checking the report before it goes out

A quick automated pass catches most issues. Verify that every number in the rendered text appears in your metrics JSON, that the file contains no script tags after sanitising, and that it opens cleanly at phone width. Then a human reads it once. That human read is not optional for anything client-facing.

A simple regular expression that extracts numbers from the text and compares them against the set of allowed values is enough to flag invented figures. It will produce some false alarms for dates and section numbers; that is fine for a review aid.

Look for tone problems

Models sometimes overstate good news or soften bad news. Read for claims like significantly improved or minor issue and check they match the data. Adjust the prompt to ask for neutral, factual phrasing.

Test on a phone

Open the file on a narrow screen. Wide tables are the usual problem; wrap them in a scrollable container or split them. A report people cannot read on their phone often goes unread.

Sharing options and their trade-offs

Once the file exists, there are several ways to deliver it, each with different visibility and control.

Mind what is in the file

A single file is easy to forward. Do not include internal notes, raw data or other clients' names. Generate a separate internal version if you need extra detail.

Keep an archive copy

Save every sent report with its metrics JSON in a dated folder. If a client asks what was reported in a given week, you can show the exact file and the data behind it, which is far better than regenerating it and getting different wording.

  • Email attachment: simple, no hosting, but some mail systems block HTML attachments.
  • Shared drive: access controlled by your organisation, though some drives preview HTML as source.
  • Static hosting with a private link: renders well, but anyone with the link can view it.
  • Document-sharing tools with analytics: show who opened what, which some clients dislike.
  • Convert to PDF: a browser's print to PDF keeps a fixed copy for archives.
Printed page with a red pen and a propped smartphone
One human read and a phone check before anything goes out.

Running it on a free endpoint, and when to upgrade

For weekly reports from a script, a free OpenAI-compatible endpoint is often sufficient. The keyless API at https://api.apikeyanthropicfree.com/v1 serves free-ai, an independent open-weight model of about 35B parameters, with CORS open and no account. This site is not affiliated with Anthropic, and free-ai is not Claude.

If reports must follow a demanding house style, synthesise long documents or handle subtle client communication, a commercial model such as Claude will usually do noticeably better, and the pipeline above works unchanged with a different base URL and key. For the general risks of rendering generated markup on a website rather than in a file, the same sanitising principles apply. To fit reporting jobs alongside other team usage, see sharing per-IP limits across a team, and for presenting music or creative drafts the same way, composing music with a text model.

Data sensitivity decides the provider

Status metrics without client names are low risk on a free, logged endpoint. Reports containing personal data or confidential figures belong with a provider whose data terms you have reviewed, or a model you host.

Try the free API

Send a test prompt from the chat box on the home page: no key, no account and no card, only the published per-IP limits.

Read also