I kept running into the same tradeoff building cost tooling for teams shipping LLM features. Every attribution tool in this space works the same way: you point base_url at a proxy, and it sees every call before it happens. That's genuinely useful if you want to block or downgrade a call before it fires. It also means the proxy's uptime is now your uptime, and you've added a network hop to every single request.

I wanted the attribution without touching the request path at all. So I wrote a wrapper instead.

Cognocient wraps the OpenAI and Anthropic Python clients directly. You still call client.chat.completions.create() exactly the way you always did. The wrapper times the call, then fires a cost report on a background thread after your real response has already returned to your code.

The part I actually spent the most time on wasn't the happy path, it was making sure a dead reporting endpoint can never touch your application. If Cognocient's ingestion API is slow, down, or just does not exist, that failure has to stay invisible to whatever you're building. No exception bubbling up, no retry pile-up blocking your real call. There is a test, test_reporter_failure_isolation.py, that specifically points the reporter at an unreachable host and asserts the actual API call still returns clean. Writing that test is what convinced me the design was sound, not the other way around.