- Client
- SME Enterprise News
- Industry
- other
- Duration
- Live (built 2025)
The problem
Every article needs more than its body: an excerpt that earns the click, a title shaped for search without becoming clickbait, and a meta description that fits a character budget. The work is repetitive and constrained, and it is the first thing to be rushed when there are articles to get out.
The approach
We added three generation actions inside the existing author workflow, each attached to the field it fills. The editor writes the article, presses Generate with AI on a field, and the returned text lands in that field as an editable value. Nothing is saved or published by generation. Posts default to draft and reach published only when a person does it. The model drafts; the editor decides. Because a paid model endpoint can become someone else's bill, it sits behind authentication, rate limiting and CSRF validation.
The outcome
Live. AI-assisted generation is active inside the editorial workflow. Three actions sit on the fields they fill, so a poor result costs one field rather than an article. Generated text is never written to the database by the generation step itself, and reaching a reader is a separate action a person takes. No usage, time-saving or traffic figures are published, because none are supplied.
Challenges
Any route that calls a paid model can be made expensive by someone who is not you. This one is reachable only behind authentication, a sliding-window rate limit in Upstash Redis (ten requests per ten seconds, and five per fifteen minutes on authentication) and CSRF validation. Length targets in a prompt are guidance, not a contract, so the schema validates independently of the prompt. The prompt shapes the output and the validation decides what may be saved. When one model provider was dropped, the provider abstraction contained the call site but not the migration: the dependency came out of the manifest and the old route was rewritten to return a gone response pointing at the working endpoint.
What was built
- — Separate generation actions for the excerpt
- — the SEO title and the meta description
- — each scoped to one field
- — Generated text arrives in the form field
- — where the editor rewrites or replaces it before saving
- — Authentication
- — sliding-window rate limiting and CSRF validation in front of every generation call
- — Schema validation rejects an SEO title above 60 characters and a meta description above 160
- — Violations reported to Sentry rather than silently absorbed
- — Model provider chosen by environment configuration
- — behind a module rather than called from the route
- — Mock provider that returns plausible output without network calls
- — for building the interface without API spend