Shipping a Claude application
Why this lesson
Section titled “Why this lesson”This is the track closer. Lessons 1 to 11 gave you the smallest primitive (1), the production-side request and response patterns (2), the model selection (3), the three tool layers (4 to 6), the cost-and-staleness levers (7), the agent loop (8), the canonical patterns (9), durable instructions and a worked harness (10), and the spawn-and-hosted-harness primitives (11). This lesson is what changes when the result is running for real users behind a deploy.
Five disciplines carry the work from prototype to production: cost monitoring, latency budgets, eval-set discipline, rollout discipline, and lifecycle handling. Each one has a small Anthropic surface area you already know (the usage fields, the Admin API, the deprecation policy), and each maps back to one or more earlier lessons. The closing artifact is a single rollout checklist that ties the track together.
Discipline 1: Cost monitoring
Section titled “Discipline 1: Cost monitoring”Two layers cover production cost visibility: the per-call telemetry on the usage object you have already been logging since lesson 2, and the organization-level usage and cost reports in the Admin API for cross-call aggregation.
Per-call telemetry (review)
Section titled “Per-call telemetry (review)”Every response from the Messages API carries a usage object with the fields lessons 2 and 7 introduced: input_tokens, output_tokens, cache_creation_input_tokens, cache_read_input_tokens, and (for compaction-enabled requests) usage.iterations. The identity: total input tokens equal the cache-read tokens plus the cache-creation tokens plus the plain input tokens. The production logging shape pairs all of those with request_id (lesson 2), model, stop_reason, and latency. The cache-hit ratio (cache_read_input_tokens over total input) is the single most useful number you can track per workload; on a well-cached production stack with stable prefixes, the large majority of input tokens should be cache reads.
For server tools (lesson 5), the usage object reports per-tool counts (for example, server_tool_use.web_search_requests). When compaction is on, the per-iteration breakdown lives in the usage object's iterations list, and the top-level input and output token counts do not include the compaction step.
Organization-level: the usage and cost reports
Section titled “Organization-level: the usage and cost reports”Per-call logs tell you what one call cost; the organization reports tell you what everything cost, matched against your bill. The docs now offer two versions. The newer Usage and Cost Analytics API is the one they recommend for new integrations; it reports token usage and cost for your organization, broken down by the dimensions you choose, including the user or service account behind each request. The older Usage and Cost API is labeled legacy and remains supported, so an existing integration keeps working while you plan the move; the docs include a migration section.
Both have the same shape:
- A usage endpoint: token counts, which you can filter and group by model, workspace, API key, service tier, context window, data residency, and speed.
- A cost endpoint: costs in US dollars, reported in cents as decimal strings.
- Time buckets by the minute, the hour, or the day (the older cost endpoint reports by day only), so the same call serves a live dashboard and a monthly finance report.
Both are part of the Admin API, so they need an Admin API key (or another admin credential), distinct from the standard API keys you use for the Messages API. Only organization admins can create one, and individual Console accounts must set up an organization first. The table below lists the paths, headers, and limits; a minimal daily-usage call to the newer API follows it.
| As of November 2026 | Usage and Cost Analytics API (recommended for new integrations) | Usage and Cost API (legacy, still supported) |
|---|---|---|
| Status | Beta; send the anthropic-beta: analytics-usage-cost-2026-08-24 header on every request | No beta header |
| Usage endpoint | GET /v1/organizations/analytics/usage | GET /v1/organizations/usage_report/messages |
| Cost endpoint | GET /v1/organizations/analytics/cost | GET /v1/organizations/cost_report |
| Time buckets | time_bucket_width of 1m, 1h, or 1d, on both endpoints; no default (omit it for whole-range totals) | bucket_width of 1m (60 to 1,440 buckets), 1h (24 to 168), 1d (7 to 31), default 1d; cost endpoint is 1d only |
| Range limits | starting_at on or after January 1, 2026 and within the last 365 days; at most 31 days per request; at most 24 hours with 1m buckets | Any date range, paged forward by bucket |
| Grouping | Up to five group_by[] dimensions, including actor (the user or service account), model, workspace_id, api_key_id, service_tier, context_window, inference_geo, speed; the cost endpoint adds cost_type and token_type | Usage: model, workspace_id, api_key_id, service_tier, context_window, inference_geo, speed. Cost: workspace_id or description |
| Data freshness | Every response carries data_refreshed_at; data typically refreshes within 4 hours and can take up to 24 hours; values can be revised until about 7 days after the end of the calendar month | Typically within 5 minutes of request completion; polling once per minute is supported for sustained use |
| Priority Tier | Appears on the usage endpoint with service_tier: "priority" and zero token cost (the commitment is billed separately) | Not included in the cost endpoint; track it through the usage endpoint |
| Claude Platform on AWS | Both endpoints available (per AWS region, with AWS authentication) | Not available |
| Pagination | limit counts rows (1 to 1,000, default 20) | has_more and next_page; limit counts buckets |
| Admin API key prefix | sk-ant-admin01-... | sk-ant-admin01-... |
| API version header in the docs' examples | anthropic-version: 2026-10-21 | anthropic-version: 2026-10-21 |
| Sources | Usage and Cost Analytics API, Usage and Cost API |
curl --globoff "https://api.anthropic.com/v1/organizations/analytics/usage?\starting_at=2026-10-01T00:00:00Z&\ending_at=2026-10-08T00:00:00Z&\time_bucket_width=1d&\group_by[]=model&\limit=100" \ --header "anthropic-version: 2026-10-21" \ --header "anthropic-beta: analytics-usage-cost-2026-08-24" \ --header "x-api-key: $ANTHROPIC_ADMIN_KEY"Two operational facts worth memorizing. Data freshness differs between the two (the table has the current values): the legacy reports show new usage within minutes; the newer reports refresh within hours, and every response says how current it is. So the organization reports are for dashboards, chargebacks, and reconciliation, not for real-time alerting. Your per-call telemetry is the real-time signal. Totals can still move: late events and reconciliation can revise recent numbers, so close a month's books only after the docs' revision window has passed.
Two caveats from the docs: Priority Tier commitments are billed separately, so that spend never shows up as token cost in the cost reports (track Priority Tier traffic in the usage report instead); and platform availability differs: the legacy endpoints are not available on Claude Platform on AWS, while the newer API is. Several observability partners ship ready-to-use integrations against these reports if you would rather not build dashboards yourself; the docs list them.
The four cost levers (recap)
Section titled “The four cost levers (recap)”The four production cost levers from earlier lessons:
- Model selection (lesson 3): the cheapest model that passes evaluation. Start where the docs point, then let evaluation move you down a tier; reach for the fastest and cheapest tier on light, high-volume work.
- Effort dial (lesson 3): per-call token spend. Defaults differ by model, so set the level explicitly per workload, and let the evaluation set choose it.
- Prompt caching (lesson 7): cache writes cost a little more than normal input, and cache reads cost a small fraction of it (the table below has the multipliers). Cache the system plus tool stack at minimum.
- Batches (lesson 2): a steep discount in exchange for asynchronous results, and most batches finish in under an hour. Right for evaluations, content moderation, bulk non-interactive workloads.
| Cost lever (as of November 2026) | Current value | Source |
|---|---|---|
| Cache write, 5-minute duration | 1.25x the base input price | Pricing |
| Cache write, 1-hour duration | 2x the base input price | Pricing |
| Cache read (hit) | 0.1x the base input price on most models; 0.05x on Claude Opus 5.5 and Claude Sonnet 5.5; 0.025x on Claude Fable 5.2, Claude Mythos 5.2, Claude Fable 5.1 and Claude Mythos 5.1 | Pricing |
| Batch API | 50 percent off both input and output tokens; most batches finish in less than 1 hour | Pricing, Batch processing |
| Per-model prices and default effort | See lesson 3's table and the Models overview | Models overview |
Add the per-subagent model from lesson 11 (the cost lever applied per-step in orchestrator-worker patterns) and you have the full production-cost picture.
Discipline 2: Latency budgets
Section titled “Discipline 2: Latency budgets”Define budgets per surface, not per call. A chat UI cares about time-to-first-token (TTFT); a batch worker cares about end-to-end throughput; an agent loop cares about steps-times-per-step latency.
The levers from earlier lessons:
- Streaming (lesson 2): perceptually shrinks TTFT to milliseconds even on long responses; required for any chat UI on a long generation.
- Effort dial (lesson 3): higher effort means more tokens, more time. A lower effort level on a fast tier is the standard latency win for chat; lesson 3's table lists the docs' recommended starting points per model.
- Prompt caching (lesson 7): cache hits cut both TTFT and total spend; with a cached prefix, only the post-breakpoint tail is processed.
- Routing (lesson 9 pattern 2): send easy queries to a smaller faster model.
- Batches API (lesson 2): when latency does not matter at all, batches trade speed for a large discount; most finish in under an hour.
- Parallelization with Subagents (lessons 9 and 11): concurrent subagents reduce wall-clock dramatically on workloads with independent subtasks.
The single discipline that ties them together: never tune latency without a budget. Decide what TTFT is acceptable for the surface (200 milliseconds for typing-assist; 1 to 2 seconds for chat first-token; 30 seconds for a long generation if streaming; minutes for a batched workload) and treat budget breaches as a per-incident bug.
Discipline 3: Eval-set discipline
Section titled “Discipline 3: Eval-set discipline”The rule from lesson 3 carries through: build a held-out test set, run candidate changes against it, pick the cheapest configuration that passes. Lesson 9 pattern 5 (evaluator-optimizer) describes the loop. Track 21 lesson 7 "LLMOps" is the deeper provider-agnostic playbook for the discipline as a whole.
What "passes" means is workload-specific: a structured-output task uses field accuracy or JSON-schema conformance; a summarization task uses ROUGE or a human-rubric LLM judge; an agent loop uses task completion rate. Pick the metric per workload, not per model.
What changes in production specifically: the eval set is the gate, not a one-off. Every model swap, every effort-dial change, every prompt edit, every tool addition runs through it before traffic shifts. The earlier you build it, the more changes it lets you ship safely.
Discipline 4: Rollout
Section titled “Discipline 4: Rollout”Four moves cover the rollout layer:
- Feature flags. Model name, system prompt, tool list, cache_control placement, MCP server list (lesson 6), and Subagent configurations (lesson 11) all sit behind flags. A model swap is a config change, not a deploy.
- Canary. Route 1 percent of traffic to the new configuration; watch the eval set live (the evaluation in production lesson from Track 21 LLMOps); promote to 10 percent, then 100 percent. Tolerated quality regressions caught at 1 percent are infinitely cheaper than the same regressions caught at 100 percent.
- A/B against the current production configuration. Run both for a fixed window; score live responses on your held-out set; pick the cheapest that passes. This is the same discipline lesson 3 recommended for model selection, applied to every change.
- Rollback plan documented and rehearsed. The flag should toggle back in one motion. The request_id logging from lesson 2 is what makes incident response possible: Anthropic Support needs the request_id to find a specific failed call, and your own logs need it to correlate the call with your application's request.
Every Claude call in production logs (at minimum): request_id, model, stop_reason, usage.input_tokens, usage.output_tokens, usage.cache_read_input_tokens, usage.cache_creation_input_tokens, and request latency. Pair with feature_flag_state and your application's user_id and session_id. That logging shape is what makes every later disposition (cost reconciliation, incident response, rollout decisions) tractable.
Discipline 5: Lifecycle handling
Section titled “Discipline 5: Lifecycle handling”Anthropic publishes a deprecation policy with a clean lifecycle. The four states: Active (fully supported and recommended), Legacy (no more updates; might be deprecated later), Deprecated (still functional but a retirement date is set), Retired (requests fail).
Two facts to plan against. At least 60 days notice before retirement for publicly released models, per the docs: "Anthropic notifies customers with active deployments for models with upcoming retirements, providing at least 60 days’ notice before model retirement for publicly released models." Pinned model IDs are the production discipline (lesson 3): newer models use a dateless ID that is already a pinned snapshot; older models use the date-suffixed canonical ID for production stability.
The audit path from the docs: in the Claude Console Usage page, click the Export button, review the CSV for usage by API key and model, locate any deprecated model in use, migrate before the retirement date. The model deprecations page at platform.claude.com/docs/en/about-claude/model-deprecations lists every model's current state, its retirement date, and the recommended replacement.
Parameters have a lifecycle too, and so does the API itself. The sampling parameters (temperature, top_p, and top_k) were first rejected at non-default values on newer models; then a new API version removed them for every model, so sending any of them returns a 400 error. Omit them; use prompting to guide behavior (the prompt-engineering best-practices page is canonical for the patterns). The lesson for production: pin the API version header the way you pin the model ID, and read the migration guide before you move it.
| Lifecycle detail (as of November 2026) | Per the docs |
|---|---|
Sampling parameters temperature, top_p, top_k | Removed in API version 2026-10-21: a request that sends any of them returns a 400 error, even at the default value. On the earlier 2023-06-01 version they return a 400 error when set to a non-default value on Claude 4.7 and later models. |
| Current API version in the docs' examples | anthropic-version: 2026-10-21 |
| Where to check status and retirement dates | The Model status table on the model deprecations page |
| Sources | Model deprecations, Migrating to API version 2026-10-21 |
The rollout checklist
Section titled “The rollout checklist”A single checklist that pulls lessons 1 to 11 into shippable form. Treat it as a deploy gate, not aspirational:
- Smallest primitive solid (lesson 1): every code path constructs the Messages API request correctly; iterate the content array, never index it.
- Production-side patterns (lesson 2): streaming on user-facing surfaces; batches for bulk non-interactive; full stop_reason dispatch; request_id logged on every call.
- Model and effort chosen by eval (lesson 3): start where the docs point, then let evaluation move you down a tier where the data supports it; effort set explicitly per workload, because defaults differ by model.
- Tools deliberate (lessons 4 to 6): custom tools where the logic is yours; server tools where Anthropic provides; MCP for third-party catalogs; denylist destructive operations; sandbox computer-use; tool descriptions tight enough to produce correct calls.
- Caching live (lesson 7): cache_control on the system prompt and stable tool definitions at minimum; cache-hit ratio monitored in the production dashboard.
- Context-management posture chosen (lesson 7): compaction opted in for sessions that will run long; tool result clearing for tool-heavy agent loops; the system prompt cached at the end so it survives compaction.
- Agent loop disciplines (lesson 8): hard max_iterations cap; explicit stop_reason dispatch (no silent fall-through); tool inventory is the safety surface area.
- Pattern chosen by decision tree (lesson 9): the simplest pattern that fits the task, not the most sophisticated.
- Skills and harness chosen (lesson 10): durable instructions in .claude/skills/ or uploaded via the Skills API; CLAUDE.md committed where appropriate; security audit on any third-party Skill.
- Right primitive per workload (lesson 11): self-built lesson 8 loop for control and ZDR; Subagents for orchestrator-workers and parallelization; Managed Agents for long-running asynchronous work when ZDR is not a constraint.
- Cost dashboards live (this lesson): organization usage and cost reports integrated; cache-hit ratio plus per-model spend plus per-workspace allocation visible; alerts on per-feature budget breaches.
- Latency budget defined and tracked (this lesson): per-surface TTFT and full-response targets; breaches treated as incidents.
- Eval set as deploy gate (this lesson, and Track 21 lesson 7): every change passes evaluation before traffic shifts.
- Feature flags plus canary plus rollback (this lesson): model name plus system prompt plus tool list behind flags; canary at 1 percent then 10 percent then 100 percent; rollback rehearsed.
- Deprecation watch (this lesson): subscribed to Anthropic notifications; Console Usage Export reviewed quarterly; migration runway sized for the 60-day notice window; API version pinned.
Why this matters when you use Claude
Section titled “Why this matters when you use Claude”A working prototype and a shipped application are different problems. The prototype proves the model can do the thing; the shipped application proves you can keep the thing running reliably under real traffic, at a cost that pays back the value, with the ability to upgrade and roll back without taking the service down. The five disciplines here are not gold-plating; they are the difference between a model integration that lasts and one that quietly degrades over months.
The track is now closed. Lesson 1 had you make a call. Lesson 12 ships the application that the call ended up being part of.
What you should remember
Section titled “What you should remember”- Per-call telemetry on every Claude response. Log request_id, model, stop_reason, usage.input_tokens, usage.output_tokens, usage.cache_creation_input_tokens, usage.cache_read_input_tokens, usage.iterations (when compaction is enabled), and request latency. The cache-hit ratio is the single most useful production metric.
- Organization usage and cost reports live in the Admin API: a usage endpoint for token counts and a cost endpoint for dollars, with minute, hour, or day buckets, grouped by model, workspace, API key, and more. The newer Usage and Cost Analytics API is recommended for new integrations; the older Usage and Cost API is legacy and still supported. Both need an Admin API key, distinct from regular API keys.
- Freshness differs between the two APIs. Use per-call telemetry for real-time alerts and the reports for dashboards and reconciliation.
- Priority Tier commitments are billed separately, so track Priority Tier traffic in the usage report. Platform availability differs between the two APIs (the table lists it). Individual Console accounts must set up an organization first.
- Latency budgets per surface, not per call. Streaming for chat; effort dial for the cost-quality-latency triangle; cache hits cut TTFT; routing sends easy queries to faster models; Subagents parallelize independent subtasks; Batches are the "I do not care about latency" lever.
- Eval-set discipline. Build a held-out test set, run candidate changes against it before shipping. The same discipline lesson 3 used for model selection applies to every prompt change, tool addition, and configuration tweak. Track 21 lesson 7, on LLMOps, is the deeper playbook.
- Rollout four moves: feature flags (model plus prompt plus tool list behind a flag), canary (1 percent then 10 percent then 100 percent), A/B against current production, documented and rehearsed rollback. request_id logging makes incident response tractable.
- Anthropic deprecation policy: Active, then Legacy, then Deprecated, then Retired. At least 60 days notice for publicly released models. Audit via Console Usage Export. Pinned model IDs for production (newer models are dateless and already pinned; older ones use the date-suffixed form). The model deprecations page lists each model's state and retirement date.
- Parameters and API versions have a lifecycle too. The sampling parameters (temperature, top_p, top_k) are gone in the newest API version and return a 400 error; omit them and use prompting. Pin the API version header and read the migration guide before moving it.
- The rollout checklist pulls lessons 1 to 11 into a single deploy gate: smallest primitive solid, production patterns (streaming plus batches plus stop_reason plus request_id), model plus effort by eval, tools deliberate, caching plus compaction plus clearing chosen, agent loop disciplines, pattern by decision tree, Skills and harness chosen, primitive per workload (self-built loop or Subagents or Managed Agents), cost dashboards live, latency budget tracked, eval set as deploy gate, feature flags plus canary plus rollback, deprecation watch.
Lesson 1 had you make a call. Lesson 12 ships the application. The track is closed.