static audit · 2026-10-25T20:31:23.322Z

anthropics/anthropic-sdk-python

110 source files scanned · 4 LLM call site(s) · ~2% of LLM spend looks recoverable (static heuristics · repo looks like a library)

Library/SDK layout detected (Python package "anthropic" is an LLM SDK/framework): call sites are most likely pass-through wrappers where the caller chooses the model and prompt, so findings are downgraded one level and the estimate is discounted.

badge   ![TokenZero audit](https://tokenzero.sh/v1/badge/audit/aud_jcYNJMRkPOiSGlY1OWiAKg.svg)

repo badge   [![LLM spend audited by TokenZero](https://tokenzero.sh/v1/badge/repo/anthropics/anthropic-sdk-python.svg)](https://tokenzero.sh/audit/anthropics/anthropic-sdk-python)

Models referenced

none detected

Findings

SeverityWhereFindingEst.
lowsrc/anthropic/lib/threads/_beta_threads.py:344LLM call inside a loop
Per-item calls repeat the full prompt prefix for every element. If items are independent and latency-tolerant, the provider Batch API is 50% cheaper; if the prefix is shared, caching pays off immediately.
Fix: Batch where possible; otherwise keep the shared prefix cache-formatted (TokenZero does this automatically).
25%
lowsrc/anthropic/lib/threads/_beta_threads.py:345LLM call inside a loop
Per-item calls repeat the full prompt prefix for every element. If items are independent and latency-tolerant, the provider Batch API is 50% cheaper; if the prefix is shared, caching pays off immediately.
Fix: Batch where possible; otherwise keep the shared prefix cache-formatted (TokenZero does this automatically).
25%
lowsrc/anthropic/lib/threads/_beta_threads.py:557LLM call inside a loop
Per-item calls repeat the full prompt prefix for every element. If items are independent and latency-tolerant, the provider Batch API is 50% cheaper; if the prefix is shared, caching pays off immediately.
Fix: Batch where possible; otherwise keep the shared prefix cache-formatted (TokenZero does this automatically).
25%
lowsrc/anthropic/lib/threads/_beta_threads.py:558LLM call inside a loop
Per-item calls repeat the full prompt prefix for every element. If items are independent and latency-tolerant, the provider Batch API is 50% cheaper; if the prefix is shared, caching pays off immediately.
Fix: Batch where possible; otherwise keep the shared prefix cache-formatted (TokenZero does this automatically).
25%

Fix all of it with one line

OPENAI_BASE_URL=https://tokenzero.sh/v1
ANTHROPIC_BASE_URL=https://tokenzero.sh

Keys pass through untouched. Cache formatting and exact caching are on by default; cascade routing stays opt-in. How it works