The notebook
Blog.
notes from real projects
Practical writing on Laravel, AI engineering, token costs, SaaS architecture, and the technology decisions that make software cheaper to run and easier to grow.
AI & LLMs
20 posts
22 Jun 2026
AI & LLMs
Per-User Token Budgets: Controlling LLM Costs in Your SaaS
Provider dashboards tell you what you spent, not who spent it. How I meter tokens per tenant in Laravel with middleware, soft and hard quotas, budget alerts and graceful degradation.
→
15 Jun 2026
AI & LLMs
Cutting LLM Token Costs in Production: A 2026 Field Guide
The five levers I apply to cut LLM API bills in production — prompt caching, model routing, batching, context compaction and output caps — ranked by effort-to-savings.
→
01 May 2026
AI & LLMs
Reliable JSON from LLMs: Structured Output Patterns That Hold Up
The technique post underpinning every document-AI and integration project: native structured-output/JSON-schema modes vs the tool-call trick, validate-and-retry loops, enum constraints to ki...
→
28 Apr 2026
AI & LLMs
Invoice Data Extraction with LLMs: Beyond OCR in 2026
Why vision LLMs beat template-based OCR (reading text vs understanding which number is the total), a production pattern of JSON-schema extraction plus confidence-based human review, and the...
→
25 Apr 2026
AI & LLMs
Adding AI Features to an Existing SaaS: An Architecture Checklist
The retrofit checklist I run on Laravel codebases: queue-based LLM calls (never inline in requests), timeout and fallback paths for provider outages, per-tenant cost ceilings, PII scrubbing...
→
19 Apr 2026
AI & LLMs
LLM Guardrails in Production: Surviving Drift and Bad Outputs
Runtime reliability engineering as distinct from pre-launch evals: schema validation with retry loops, input sanitisation against prompt injection, fallback chains when a provider degrades,...
→
16 Apr 2026
AI & LLMs
LLM Evals Without an ML Team: A Practical Setup for Small Teams
How a two-person team ships tested AI features: a golden dataset of 200-500 real (not synthetic) examples, assertion-style checks plus LLM-as-judge with its known biases, wired into CI the s...
→
13 Apr 2026
AI & LLMs
Human-in-the-Loop AI Agents: Approval Gates That Actually Work
Where to place approval steps in agent workflows (outbound emails, invoice postings, CRM writes) using confidence thresholds, action whitelists, and audit trails — so automation saves time w...
→
10 Apr 2026
AI & LLMs
AI Agents vs Workflow Automation: A Decision Guide for SMBs
A framework for when a deterministic queue/cron pipeline beats an agent and vice versa — variability, judgment, and natural-language inputs are the agent signals — with honest failure-mode a...
→
07 Apr 2026
AI & LLMs
RAG vs Long Context: When You Don't Need a Vector Database
With million-token context windows and prompt caching, corpora under a few hundred pages are often cheaper and more accurate stuffed into context than retrieved — I give the cost/latency cro...
→
04 Apr 2026
AI & LLMs
Why RAG Fails in Production (and How to Fix Retrieval First)
Roughly 73% of RAG failures are retrieval, not generation — a debugging checklist from client projects: inspect retrieved chunks before blaming the model, fix chunking (semantic over fixed-s...
→
01 Apr 2026
AI & LLMs
Small Models First: Why Cheap LLMs Handle 80% of SaaS AI Features
An escalation architecture I use: default every request to a Haiku/Flash-class model at cents per million tokens, escalate to a frontier model only on validation failure or low confidence —...
→