Optimize existing app
Keep your framework. Choose an integration and see whether Caveman applied an optimization.
Add Caveman to an application or agent you already own. Keep your framework, model provider, and tool loop. Choose the integration that matches what you want to change.
Using Claude Code or Codex rather than building an application? Start with coding-agent setup.
Choose your framework#
Install middleware, run a streaming tool loop, and check whether compression happened.
Run a complete LangChain example with local compression and recovery.
Find OpenAI, Anthropic, Google, Mastra, Strands, and the other middleware entrypoints.
Call explicit compression, context, tool-search, or tracing APIs from your code.
Check what you want to optimize#
| Your situation | Start with | What changes |
|---|---|---|
| Tools return long logs or text to your agent | Framework middleware | Eligible tool-result text in the outbound request |
| You can change a provider base URL, but not the agent loop | Proxy integration | Supported traffic passes through a separately running proxy |
| You want to compress a specific payload yourself | SDK compression | Your code chooses what to compress and how to recover it |
| You need usage observations from an existing framework | Agent SDK adapters | Lifecycle hooks and normalized usage records |
| You are starting a new agent runtime | Agent SDK | Caveman owns the agent definition and execution |
What middleware does automatically#
Middleware selects eligible tool results before a provider call, asks the Caveman runtime to optimize them, and passes the accepted outbound copy to your existing provider client. When a lossy transform is supported, the native tool loop can retrieve the original. Your stored conversation stays yours.
It does not automatically route models, add memory, shorten every message, or optimize an entire project. In the Vercel integration, a chat without eligible text tool results can produce a valid answer without applying any compression. Structured object results, errors, and images are not text candidates in that adapter.
Follow one path to a working result#
The Vercel AI SDK guide includes the complete application, a small integration diff, and a local check using the real Caveman runtime with a fixture provider. Start in record mode, enable compression, and inspect the report before comparing token use.
Middleware packages are alpha. They call a separate runtime over HTTP; installing the npm package does not start that runtime. Read deployment before moving the application off your laptop.
A decision report answers whether middleware applied a transformation. It does not prove lower provider usage or a smaller bill. See how numbers are counted.