Controlling costs when building with AI
After hitting OpenAI billing limits broke its early AI features, incident.io built per-prompt cost attribution into its Go LLM abstraction, using reflection to capture each prompt's type name alongside token usage and emitting it to Grafana metrics and Postgres records for BI. Separate OpenAI projects per feature, mapped from source file patterns and provisioned with Terraform, give each surface its own billing limit to contain runaway spend. Daily Slack spend reports, per-message cost and latency in dev, backfill cost predictions from historical runs, and eval suites that report their cost keep spend visible to developers and let teams model feature costs before launch.
Related posts
- Everything We Talked About at O11yDay London 2026
Honeycomb mediumAdeptAcross ten sessions at O11yDay London, the recurring bottleneck was not writing code but reviewing it, operating agents in production, and proving the spend is worth it. Speakers described instrumenting AI agents like any other production system: OpenTelemetry pipelines repaired to expose hidden Claude Agent SDK subagents, per-conversation Agent Timelines showing tokens and cost (about $1.70 and seven minutes for one review), and anomaly detection that tied a failure spike to a switch from per-PR to per-commit review. Concrete findings include roughly 80% of merged PRs at Honeycomb having no human-driven changes (prompting a rule that two developers must participate, one of whom may be a machine), Fin's measured wins from enforcing Claude Code configuration (brief mode cut output tokens ~20%, a hard nudge to cheaper models saved 7.4%), and HelloFresh seeing restores 20% faster but over 10% of investigations stalling. Corey Quinn closed by treating AI cost as an observability problem: put cost, price at time of request, and whether the result was accepted on every span, share one request ID across retries, use the OpenTelemetry GenAI semantic conventions, and enforce spend limits outside the agent loop.
- LLM Cost Optimization: 3 Patterns to Cut LLM Token Spend
Honeycomb mediumAdeptLLM token spend is best reduced by using traces to find three waste patterns: repeated input context that doesn't improve results, retry storms and runaway agent loops, and output tokens that don't lift outcomes. For each, compare expensive and normal cohorts on high-cardinality attributes (prompt version, model, workflow step, tenant, retries) and apply targeted fixes such as filtering retrieval, summarizing history, retry limits, tighter termination conditions and structured outputs. Treat every cost cut as a production change: baseline cost per successful outcome, change one pattern at a time, and roll back if quality guardrails like completion, acceptance or parsing success regress.
- Optimizing LLM prompts for low latency
incident.io mediumAdeptincident.io cut latency of an LLM prompt that plans Grafana dashboards for incident investigations from 11s to under 2.3s without changing its behaviour, mainly by shrinking output tokens. Dropping JSON reasoning fields halved output tokens (315 to 170) and saved about 40% latency. Replacing JSON dashboard definitions with a compact custom format cut input from 15k to 2k tokens but saved only about 20%. A terse non-JSON output format cut output tokens by a further 70% and latency by 60%, though the team held back from shipping it because models are more familiar with JSON and quality could suffer in subtle ways.
- Comparing token economics across 42 AI models
Neon mediumAdept
A synthetic workload of 100 support tickets (20 scenarios × 5 tone variants) was run through 42 models via Neon AI Gateway, with responses graded on seven checks including JSON validity, correct classification and escalation, and policy compliance. GPT-5 Nano had the lowest cost per usable response and finished in about 3 minutes. GPT-5.5 Pro cost about $8.34 and took 57 minutes, GPT-5.3 Codex had the highest pass rate at 82%, and Llama 3.1 8B was fastest but passed only 34%. Catalog price alone misleads, because token volume and failure rate drive the real cost per unit of work. A projection of one 1M-token agent task per engineer per day shows roughly an 86× spend gap between moderately cheap and moderately expensive models. The harness uses one Neon branch per model, created with --no-compute, plus a Python runner, Postgres result tables, a Next.js report and a scheduled GitHub Actions workflow.
- Introducing Spend Management: Spending limits and alerts for Cloudflare
Cloudflare mediumAdeptCloudflare Spend Management, now in beta for pay-as-you-go customers, lets users set spending limits and alert thresholds on Workers and Durable Objects, automatically pausing billable invocations when a cap is hit. Static assets keep serving. Limits can be configured via dashboard, cf CLI or REST API. Under the hood, a two-stage metering pipeline aggregates usage into one-minute and then five-minute windows, and an account-partitioned Usage Engine with local state and a WAL feeds a Rating Engine. The Rating Engine applies allowances and pricing, tolerating out-of-order subscription data by holding usage as pending. Caps propagate asynchronously through Quicksilver so enforcement uses local state off the request path, with roughly 10-minute lag today and a goal of under a minute.