AI
Anthropic Files API won't cut costs, but prompt caching might
A hands-on test reveals that uploading documents once saves developer time but not money—while caching cuts billed tokens to a third.
The New Stack
Anthropic recently moved its Files API and computer-use toolset out of beta, offering developers a way to upload files once and reference them by ID instead of pasting content into every request. But a practical experiment shows the feature won't slash your bill the way you might hope.
How the test worked#
To compare approaches, an engineer built a scenario mimicking real-world use: a developer support bot answering questions about a fictional invoicing company's API reference. The 1,200-word reference covered authentication, webhooks, rate limits, and other standard API details. Five test questions had specific, verifiable answers buried in that document—including subtle details like "token scopes can't be edited after creation" and "separate rate limits apply to bulk endpoints."
The same five questions ran through three different setups on Claude 3.5 Sonnet, tracking token costs and answer accuracy:
- Arm 1: Pasted the full reference into every request
- Arm 2: Uploaded the reference once via Files API, referenced it by ID in each request
- Arm 3: Pasted the reference once into the system prompt with prompt caching enabled
The results#
All three approaches nailed every answer, catching the nuanced details that matter. But token economics told a different story.
The Files API (Arm 2) slightly exceeded the cost of pasting (Arm 1). While the document itself consumed roughly 3,050 input tokens per question either way, referencing by file ID added about 25 tokens of overhead per request—meaning Arm 2 burned an extra 125 tokens across five queries. No amount of volume changes that equation.
Prompt caching (Arm 3) behaved like the Files API was advertised: it billed the 2,990-token document as a cache write (25% premium) on the first request, then treated it as a cheap cache read (~one-tenth normal rate) for the next four. Across five queries, this cut total billed input to roughly one-third compared to pasting.
When to use each#
The takeaway is that Files API and prompt caching solve different problems—not the same one.
Use the Files API when:
- You need to manage files you can't easily paste (PDFs, images)
- You want centralized file storage with expiration controls

