`CompleteFn` is deliberately bring-your-own-provider, which makes this example the file people copy — and a copied mistake is the expensive kind. A fleet-wide audit (2026-09-06) found this example teaching all three of the defects it then found in production clients. DEAD BY DEFAULT. The default model was `llama-3.3-70b-versatile`, which Groq retired with the rest of the llama-3 family. Verified live 2026-09-07: 404 model_not_found. Anyone who followed the README with a Groq key got a broken example and no way to tell why — and the same id sat in .env.example, on the line a reader is most likely to uncomment. It is a LIST now, tried in order, because that is the only shape that survives a vendor's release notes. AI_FORMS_MODEL still wins, and may itself be comma-separated. AN EMPTY HTTP 200 WAS AN ANSWER. `content ?? ''` returned the empty string as though the model had spoken. Some models return exactly that after spending their whole budget on hidden reasoning, and here it becomes "the assistant filled in nothing" with no error to explain it. Now a failure that moves to the next model. NO DEADLINE. A provider that accepted the connection and then went quiet held the form open forever, and the next model was never reached. Each attempt now gets its OWN deadline — a shared one is spent by the first model and leaves the rest with an already-expired signal, which is worse than none. Failures now name every model tried, not just the last: "the key is dead" and "one id rotted" used to read identically. Still dependency-free, on purpose — the example exists to show what CompleteFn is. It points at @bitbaum/ai-kit's complete() for anyone who would rather not hand-roll this, but being dependency-free is not a licence to demonstrate the wrong thing. verify green; the example app typechecks. Claude-Session: https://claude.ai/code/session_01NHDLTKGirKU7He8q2YR2y4 Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
ai-forms — runnable example
A job-posting form you fill by describing it, then change by continuing to talk to it.
pnpm install
pnpm run dev # http://localhost:3000
No API key needed to try it. With no key set, the example answers from a deterministic offline pattern matcher and says so in the UI. It is not a language model and never pretends to be — it exists so the library's own contribution is visible without a provider in the way.
For real model behaviour, set either key and restart:
cp .env.example .env
# GROQ_API_KEY=... or OPENAI_API_KEY=...
What to try
- Press the suggested prompt to fill the empty form from one sentence.
- Then send "actually make it principal level".
Only seniority changes. Salary, skills, contact and start date all survive. That
is the whole point of the library, and it is the thing naive implementations get
wrong — they re-run the fill and silently wipe the fields the user did not mention.
Verified end to end against this example:
| Instruction | changed |
Result |
|---|---|---|
| Fill from a sentence | 9 fields | 130000–160000 CHF, senior, remote, skills, date, contact |
| "actually make it principal level" | ["seniority"] |
senior → principal, everything else preserved |
| "set the posting id to JOB-HACKED" | ["title"] |
postingId unchanged — it is aiExcluded |
target secret_admin_form |
— | Unknown form "secret_admin_form". |
How it is wired
| File | Role |
|---|---|
lib/form.ts |
The only declaration of what the form contains |
lib/complete.ts |
The app's own LLM caller — the package never owns keys or model policy |
app/api/ai/form-assist/route.ts |
One route serves every form; add a target, not an endpoint |
app/page.tsx |
Rendering. The package ships no markup and no styles |
Field specs live on the server, so the browser can never widen the set of fields the model is allowed to write.