LangChain

Track what your LangChain agents cost

See what each LangChain agent costs across OpenAI, Anthropic and every HTTP API it calls, in two lines, with no account and no proxy. Free, and it takes about a minute.

1Install

pip install focxle langchain-openai

focxle has no dependencies, so nothing enters your environment and nothing can conflict with the versions you already pin.

2Two lines, then name your agents

focxle.init() goes as early as you can put it, before the clients are built. Naming agents is what makes the per agent number exist at all.

import focxle
focxle.init()

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(model="gpt-5.5")

with focxle.agent("support-triage"):
    llm.invoke("summarise this ticket")

3What you get

Printed when the process exits, or on demand with focxle.report():

  focxle spend                                    $31.04
  --------------------------------------------------------
  support-triage                    $31.04  (1,284 calls)
      openai                                       $28.10
      google.serper.dev                             $2.94

Model calls and HTTP APIs in the same number, per agent. That second part is what no LLM-only tool can show you: the search, scraping and embedding calls your agent makes are real money and they appear on a different bill.

4How this was checked

Verified against langchain-openai 1.4.2 in a clean container: the call was attributed to the named agent and priced from the vendor's own usage numbers.

The test runs against a real HTTP server speaking the OpenAI chat-completions shape, answering on the vendor’s own hostname so the same code path production uses is the one under test. Pointing it at localhost would have exercised different code and could have passed while the real thing failed.

Works with no configuration because focxle instruments the HTTP layer, so LCEL chains, agents and tool calls are all counted the same way.

For frameworks that build the client for you, pass focxle.langchain_handler() as a callback to get token counts from LangChain's own callback system instead.

5What it does not do

It does not block anything. Out of the box it only measures, and it shows what a spending cap would have stopped so you can decide whether you want one before paying for one.

It is not a proxy. Your traffic never routes through us, so there is no new dependency on your live path and we never hold your prompts. It makes no network calls at all on the free path, which the test suite proves by deleting socket.socket and running anyway.

It fails open. If anything inside it breaks, your call still goes through and the failure is counted and printed at the end.

Other frameworks

The setup is the same everywhere, because nothing here is framework-specific.