CLAUDE LABJP
MEMORY — Claude Code closes a cluster of long-session memory leaks, including MCP stdio stderr piling up to 64 MB per server and LSP documents staying open indefinitelyTABLES — Very large markdown tables no longer stall rendering; tables over 200 rows now show the first 200 with a "… N more rows" noticeSPEED — Sessions carrying many deny/ask permission rules no longer lose seconds every turn: rule matchers are compiled once and cachedTOOLS — print/SDK sessions with many MCP tools get up to 7x faster tool rounds thanks to cached tool-pool assemblyARTIFACTS — Claude Code Artifacts turn session work into live, shareable web pages that update in place — useful for PR walkthroughs and dashboardsDEADLINE — Opus 4.7 fast mode is removed on July 24; speed: "fast" will error, so move to Opus 4.8 fast mode before thenMEMORY — Claude Code closes a cluster of long-session memory leaks, including MCP stdio stderr piling up to 64 MB per server and LSP documents staying open indefinitelyTABLES — Very large markdown tables no longer stall rendering; tables over 200 rows now show the first 200 with a "… N more rows" noticeSPEED — Sessions carrying many deny/ask permission rules no longer lose seconds every turn: rule matchers are compiled once and cachedTOOLS — print/SDK sessions with many MCP tools get up to 7x faster tool rounds thanks to cached tool-pool assemblyARTIFACTS — Claude Code Artifacts turn session work into live, shareable web pages that update in place — useful for PR walkthroughs and dashboardsDEADLINE — Opus 4.7 fast mode is removed on July 24; speed: "fast" will error, so move to Opus 4.8 fast mode before then
Articles/API & SDK
API & SDK/2026-06-14Advanced

Record Which Model Actually Answered — Attestation Logging for Headless Pipelines

Persist the model field and usage from every API response so you can detect when the served model differs from the one you requested, and reconcile per-model cost ahead of the usage credits change.

Claude API115headless12cost management7logging2Fable 53

Premium Article

Last month I reconciled my automated content pipeline's API bill against my estimate and found a few hundred yen I couldn't account for. The call count matched my logs. The token counts matched. Only the total was off. When I dug in, the culprit was that the model I had requested and the model that actually answered diverged on a small slice of requests. I was logging the output text and the token counts, but not which model produced the response — so pinpointing where the gap came from took me half a day.

If you run Claude headless, you may have hit something similar. I had assumed that because I pin model on every call, the response naturally comes from that pinned model. In reality, the model field inside the response is the one that gets billed, and it is not guaranteed to match the string you sent. This article walks through recording the served model on every call and reconciling it against both cost and quality, using the code I shipped into my own pipeline.

When the bill didn't match the estimate

My pipeline generates content for four sites and fires roughly 480 requests a day — about 14,000 calls a month. I was already storing each call's prompt, output, and input/output token counts as JSON Lines. Estimating "sum of input tokens × price + sum of output tokens × price" should have landed close to the invoice.

For June 2026 it didn't. The total ran higher than my estimate. Dividing back down to individual calls, a small fraction looked like they were billed at a higher rate than the model I thought I was using. My logs only held the requested model name, so I had no way to prove, after the fact, which model's rate each charge belonged to. That was the starting point.

The lesson is blunt: the model the response declares — not the one you requested — is the truth about cost. And starting June 15, the move to usage credits makes per-model rate differences flow straight into the bill. Being able to explain drift after the fact matters more now than it ever did.

The response already tells you which model answered

The Messages API response body has always included a model field and a usage object. This is not an echo of your request; it is the server declaring which model produced this response. Most implementations pull out the text and throw the rest away — but that is exactly where cost reconciliation lives.

import Anthropic from "@anthropic-ai/sdk";
 
const client = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });
 
const res = await client.messages.create({
  model: "claude-fable-5",          // the model I requested
  max_tokens: 4096,
  messages: [{ role: "user", content: "Draft an article for me" }],
});
 
console.log(res.model);             // the model that actually answered (billing basis)
console.log(res.usage);             // { input_tokens, output_tokens, ... }
console.log(res.id);                // a unique ID per request

res.model does not always equal the "claude-fable-5" I asked for. That is the point. When it matches, you're fine; when it differs, it becomes the entry point for asking why. Keep res.id too — it's the correlation key for support tickets and reproduction work.

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
An implementation that persists the response model field and usage on every call to catch drift between requested and served model
A reconciliation function that compares cost by actual served model after the move to usage credits
A monitoring gate that surfaces request-versus-reality drift early instead of at month end
Secure payment via Stripe · Cancel anytime

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Claude Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

Related Articles

API & SDK2026-07-05
Fable 5 Is Back Worldwide and Sonnet 5 Is the Default — Where Each of the Three Models Belongs in a Solo Automation Stack
With Fable 5 redeployed worldwide and Sonnet 5 now the default, solo automation suddenly has three capable top-tier models to reach for. Instead of ranking them, this piece assigns each a role and captures that in a policy object with a fallback ladder and run-level logging.
API & SDK2026-07-04
Reading the Claude apps gateway Announcement, I Rebuilt My Indie-Scale Control Plane
The self-hosted Claude apps gateway is a control-plane/data-plane separation you can scale down. Per-app cost attribution, model allowlists, and fail-closed spend caps, implemented as a small Cloudflare Workers proxy.
API & SDK2026-06-23
When Thinking Is Always On, Prefill Quietly Stops Working — Fixing Streaming and Token Budgets for Fable 5
Fable 5 thinks by default. Prefill no longer applies, the first streamed block isn't text, and max_tokens has to leave room for reasoning. Here is how I fixed those three broken assumptions in my own automated publishing pipeline.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →