Revision · Part 3: AI Content Generation
Part 3 is where quill earns its name: the blog grows a writing assistant that streams drafts, titles, summaries, and tags into the editor. The lesson is that production AI is less about the prompt and more about the plumbing around it — because a server-side AI call sits on a shared request path, costs real money per token, and can fail slowly.
What this part covered
Section titled “What this part covered”- Server-side generation — a Rust module that calls the Claude API with
reqwest, with prompts for drafting, titling, summarizing, and tagging, returning typed structured output and handling secrets properly. - Streaming end-to-end — the model’s tokens flow over the Part 2 SSE pipe so the writer watches text appear live instead of staring at a spinner, which means wiring two streams together and handling partial output and cancellation.
- Background jobs off the request path — longer generations run as async tasks on a worker binary backed by a queue, with retries, timeouts, and idempotency, so a slow model never ties up a web worker.
- Guardrails and cost control — input size limits, output caps, per-user rate limits, and a response cache so the same request never pays twice, protecting a paid and abusable endpoint.
- Treat the integration’s shape as the durable lesson — the code targets Anthropic’s Messages API with streaming; model ids, limits, and pricing move, so the auth header, streaming events, token accounting, and retry shape are what you’re actually learning.
The takeaway
Section titled “The takeaway”Part 3’s answer to the thread is to treat every external call as hostile and expensive: even a fast, reliable dependency should be designed against as if it will be slow, fail, and cost money, because at scale it eventually does all three. That mindset — timeouts, retries, caching, backpressure — is identical whether the dependency is an LLM, a payment processor, or another team’s service. Next, Part 4 gives quill a spine with Redis, Docker, and Kubernetes.