Every AI cost-attribution tool I looked at works the same way. You point base_url at their gateway, they see every request before it happens, and in exchange you get real-time blocking if a call is about to blow your budget. That's a fair trade for a lot of teams.

It was not the trade I wanted.

I was building cost tooling for teams shipping LLM features, and the thing that kept nagging at me was uptime. The moment you route through a gateway, that gateway's reliability becomes your reliability. Every request now has a network hop it did not used to have, and a dependency that didn't used to exist. For teams that just want to know what a feature costs, not stop a call mid-flight, that felt like the wrong price to pay.

So instead of a proxy, I wrote a wrapper.

cognocient wraps the OpenAI and Anthropic Python SDKs directly. Your code does not change: you still call client.chat.completions.create() the exact way you always did. The wrapper times the call, then reports cost on a background thread after your real response has already come back. Nothing sits between your app and the provider. There is no new hop.

The part that actually took the most work was not the reporting logic; it was making sure a broken reporting endpoint can never take down anything real. If Cognocient's own ingestion API is slow, unreachable, or just gone, that failure has to be completely invisible to whatever you are building. No exception thrown into your app. No retry logic clogging up your real call. I wrote a test specifically for this, test_reporter_failure_isolation.py, that points the reporter at a dead host and checks the actual API call still comes back clean. Getting that test to pass is what convinced me the design held up, not the other way around.

What this gets you: per-call cost data, with tags for feature, team, or user if you want that breakdown later.

What it deliberately doesn't do: stop a call before it happens. If an agent is about to burn through your budget, this wrapper finds out after the fact, same as reading a billing dashboard would. If you actually need pre-call enforcement, a gateway like LiteLLM or Portkey does that well, and you should use one. This tool is for the specific case where you've already decided visibility matters more than blocking, and you don't want a proxy in the critical path to get it.

One real limitation right now: streaming responses are not reported yet. If most of your traffic is stream=True, this would not give you the full picture today. Non-streaming calls are solid. Streaming support is next.

```
from cognocient import CognocientOpenAI as OpenAI
client = OpenAI(api_key="sk-...", cognocient_key="sk-cog-...")

everything else works exactly like the SDK you already use

```

It's MIT licensed, early (v0.1.x), with signed provenance on the PyPI release. If you're already on a gateway and it's working, this probably isn't for you. If you've been putting off cost visibility specifically because you didn't want another dependency in the path, I'd genuinely like to hear whether this solves it or if I'm missing something.

GitHub: github.com/mandarvshinde/cognocient-python-wrapperPyPI: pip install cognocient