I keep seeing the same failure: an agent hits a retry loop or a tool error, keeps calling the model, and nothing stops it until the bill arrives. Callbacks and token counters inside the process help, but they die with the process and they trust the agent to stop itself.
I built a small proxy, Valta, that sits outside the agent. You point ChatOpenAI at it and use a virtual key instead of your OpenAI key. Before each call it checks your per-run, daily and monthly caps. If the call would go over, it returns a 402 and nothing reaches OpenAI. If it can’t decide, it also sends nothing.
It looks like this:
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4.1",
base_url="https://valta.co/v1",
api_key="vk_live_...", # virtual key, not your OpenAI key
max_tokens=500, # set this, it's used to estimate cost
default_headers={"X-Valta-Run-Id": run_id}, # groups calls into one run
)
Limits to know about:
- Non-streaming only for now (streaming returns a 400).
- Chat Completions only, not the Responses API, so if your langchain-openai version uses Responses, turn that off.
- The per-run cap is keyed on the run id header, so a loop that sends a fresh id each time only gets caught by the daily and monthly caps.
I’m looking for 5 people running LangChain or LangGraph agents who want to try this on a real workload. I’ll set it up with you myself, it’s free, and what I want back is honest feedback on where it breaks.
If you’ve had a runaway bill or you’re worried about one, reply with your setup (framework, rough monthly spend, what went wrong) and I’ll reply to everyone.
And a question for everyone: where do you enforce limits today, in the agent, in a gateway like LiteLLM, or just with provider-side budgets?
Debo, solo founder. Valta | Hard spend limits for AI agents