CLAUDE LABJP
FABLE5 — Claude Fable 5 launches (Jun 9): the first generally available Mythos-class model, beyond Opus, with 1M-token context, 128k output, and always-on adaptive thinkingFREE-WINDOW — Fable 5 is included free on Pro, Max, Team, and Enterprise through Jun 22; usage credits required from Jun 23. API pricing is $10/$50 per MTokSAFEGUARDS — Fable 5 falls back to Opus 4.8 on high-risk topics (under 5% of sessions); the unrestricted Mythos 5 is limited to vetted organizationsIPO — Anthropic confidentially files for an IPO (Jun 1), with a reported $65B raise, $965B valuation, and $47B annualized revenueBILLING — 3 days to the Jun 15 change: Agent SDK, headless Claude Code, GitHub Actions, and third-party agents move to API-rate monthly creditsPLATFORM — Claude Developer Platform adds Managed Agents scheduled deployments, vault env credentials, and session thread webhook eventsFABLE5 — Claude Fable 5 launches (Jun 9): the first generally available Mythos-class model, beyond Opus, with 1M-token context, 128k output, and always-on adaptive thinkingFREE-WINDOW — Fable 5 is included free on Pro, Max, Team, and Enterprise through Jun 22; usage credits required from Jun 23. API pricing is $10/$50 per MTokSAFEGUARDS — Fable 5 falls back to Opus 4.8 on high-risk topics (under 5% of sessions); the unrestricted Mythos 5 is limited to vetted organizationsIPO — Anthropic confidentially files for an IPO (Jun 1), with a reported $65B raise, $965B valuation, and $47B annualized revenueBILLING — 3 days to the Jun 15 change: Agent SDK, headless Claude Code, GitHub Actions, and third-party agents move to API-rate monthly creditsPLATFORM — Claude Developer Platform adds Managed Agents scheduled deployments, vault env credentials, and session thread webhook events
Articles/API & SDK
API & SDK/2026-06-12Intermediate

Handing Monthly Revenue CSVs to the Claude API Code Execution Tool — Files API Wiring, Container Reuse, and Billing Traps

How I moved monthly revenue-CSV reconciliation for four apps into the Claude API Code Execution tool — Files API integration, container reuse, the 5-minute billing minimum, and the file-preload charge that surprises almost everyone.

claude-api59code-execution2files-api3python21data-analysis

Premium Article

At the end of every month, my downloads folder fills up with CSVs. There is the financial report from App Store Connect, the estimated earnings export from AdMob, and then the reports from the three networks riding in my mediation stack — Unity Ads, Liftoff, and InMobi. The currencies do not match, the reporting periods do not match, and the column names certainly do not match. Reconciling them all into one trustworthy monthly number has been a fixture of my month-end for years.

I started building apps as an indie developer in 2014, beginning with a wallpaper app, and today I run four apps centered on wallpapers and relaxation content. Cumulative downloads passed 50 million along the way, which I am grateful for — but every bit of that growth added another report to the month-end pile. For a long time I handled the reconciliation with local pandas scripts, and for just as long I kept performing the same small repair: some network renames a column or shuffles its export layout, the script falls over on a missing key, I patch the column mapping, and the cycle repeats a month or two later. None of the individual fixes were hard. It was the recurrence that wore me down.

Earlier this year I moved this monthly closing work onto the Claude API Code Execution tool. The shape of the change matters: instead of pasting CSV contents into the prompt as tokens, the files travel into a sandboxed container as files, and pandas runs on the other side. Claude writes the code, executes it next to the data, and sends back only the conclusions. Actually wiring this up revealed a few gaps between the minimal examples in the documentation and what production use requires. Billing that starts the moment a file is attached — even if the tool never runs — and the pause_turn stop reason that surfaces mid-task are the two big ones. What follows is the working code, together with how to step over each of those gaps.

Why I Stopped Maintaining the Local Aggregation Scripts

To be clear, I did not replace everything, and I want to draw the boundary precisely because the boundary is the useful part. My daily KPI check still runs on the local pipeline I described in A Daily Revenue Pipeline for 4 Wallpaper Apps: 8 Weeks Running App Store Connect API + AdMob With Claude Code, and it runs reliably. When the input format is stable and the question is identical every morning — yesterday's revenue, by app, by network — a plain script is faster, cheaper, and easier to reason about. Nothing about the Code Execution tool changes that calculus.

What kept breaking was the monthly close, and the reason was structural rather than accidental. After I added Unity Ads, Liftoff, and InMobi to my mediation setup last year — and finished the payment profiles and W-8BEN paperwork that made their payouts real — the variety of incoming reports jumped from two formats to five. Revenue arrives in a mix of USD and JPY. One network cuts its reporting periods on calendar days, another on Pacific time. The same concept is called revenue in one file and estimated_earnings in another, and a column that existed in March quietly disappears in April. Code that absorbs this kind of naming drift case-by-case accumulates conditionals, and it becomes less readable with every patch. I knew the script had become a liability the day I hesitated to open it.

So I redrew the boundary. Stable, repetitive aggregation stays local; format-drifting, exploratory reconciliation goes to the sandbox. The reasoning is almost mechanical: the maintenance cost of a script is proportional to how often its input format changes. For inputs that never change, that cost rounds to zero and a script wins. For inputs that change every few months in unannounced ways, you are effectively rewriting the parser on a schedule — and letting Claude absorb the column-name drift at read time is simply cheaper than editing code every time a network ships a new export layout.

The second reason is context economy, and at this file size it is decisive. Paste a CSV into the message body and every row becomes billable input tokens that also crowd the context window. With the Code Execution tool plus the Files API, files load directly into the container and Claude reads them with pandas. The only things that land in your token budget are the code Claude writes and the printed output it chooses to show. For a monthly job that touches several megabytes of reports, this is not an optimization — it is the difference between the approach working and not working at all. I will put numbers on that in the billing section.

Where the Tool Stands Today — Old Tutorials Will Mislead You

The tool has been revised several times since its first public beta, and the gap between early write-ups and the current shape is now wide enough to cause real confusion. I lost a morning to this myself, so here is the sorted version.

  • code_execution_20250522 (legacy): the original Python-only release. Many tutorials still assume it, along with its code-execution-2025-05-22 beta header and its old single response-block format
  • code_execution_20250825 (current standard): adds Bash commands and file operations on top of Python, and is available on every supported model. The response format changed too — results now arrive as separate bash and text-editor block families
  • code_execution_20260120 (newest): adds REPL state persistence and programmatic tool calling from inside the sandbox, but only on newer generations such as Opus 4.5+ and Sonnet 4.5+. Haiku 4.5 stops at 20250825, which matters if you route cheap aggregation jobs to smaller models

The runtime, as of this writing, is a Linux container running Python 3.11 with 5GiB of memory, 5GiB of disk, and one CPU. The libraries that matter for reconciliation work are preinstalled — pandas, numpy, scipy, statsmodels for the analysis itself; matplotlib and seaborn for charts; openpyxl, xlsxwriter, and pyarrow for the file formats finance teams love. One constraint shapes everything else: the container has no internet access whatsoever. No pip install, no calling out to an exchange-rate API, no fetching a reference table from a URL. Whatever facts the analysis needs from the outside world must arrive in the prompt or in the uploaded files. The full specification lives in the official documentation.

One more practical note before the code: the current minimal examples run code execution without any beta header. The only beta flag you need is files-api-2025-04-14, and only when you bring the Files API into the picture. Update the anthropic package before you start — older SDK versions do not know the newer response types, and the resulting attribute errors look far more mysterious than they are.

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
Stop re-patching brittle local aggregation scripts — hand raw CSVs to a sandbox that handles the cleanup, joins, and charting
Walk away with working Python for Files API uploads, response-block parsing, and container reuse that you can run as-is
Avoid the traps that bite first, including billing that starts the moment files are attached, pause_turn handling, and expired containers
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-05-06
Claude API × Python in Practice: Building an AI Assistant with Tool Calling and Streaming
A practical guide to combining Claude API's Tool Use and Streaming in Python. Build a working AI assistant with real tool execution, complete source code included, plus a breakdown of the tricky parts that trip up most developers.
API & SDK2026-05-05
Let Claude Diagnose Its Own Tool Errors — Building a Self-Correction Loop with the Anthropic API
Learn how to handle Tool Use failures gracefully by feeding error details back to Claude using the is_error flag, enabling self-diagnosis and automatic retry. Includes working Python code and production antipatterns to avoid.
API & SDK2026-05-05
Building a 'Think-and-Search' AI Agent — Claude API Extended Thinking × Tool Use
A deep dive into combining Claude API Extended Thinking and Tool Use. Covers frequent errors, a complete research agent implementation in Python, plus cost estimation, timeout design, and error recovery for production use.
📚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 →