
Langfuse AI Gateway: Track Claude Code and Codex Spend Per Developer
Also available in Hindi: यह लेख हिंदी में पढ़ें
Langfuse launched its AI Gateway in public beta on 4 November 2026. It sits between your coding agents and OpenAI or Anthropic: each teammate gets their own gateway key, the real provider key stays inside Langfuse, and every call is recorded with its cost. For a team that already uses Claude Code or Codex, that answers two awkward questions at once: who is spending what, and how do we stop passing API keys around? Below: the setup, what you get, and the beta limits Langfuse documents. Checked against Langfuse's docs on 5 November 2026.
What the gateway does
Your tool sends its normal OpenAI or Anthropic request to a Langfuse URL instead of the provider. Langfuse forwards it using a provider credential an admin stored, and records the call as a generation. You change only the base URL and the key. The gateway serves the native OpenAI Responses, OpenAI Chat Completions and Anthropic Messages formats, with streaming, and does not translate between them. The provider still bills model usage to your own account.
Set it up in three steps
1. Admin. Under Organization settings → AI Gateway, add the OpenAI and Anthropic credentials, choose which models gateway keys may call, pick the project that receives traces, and invite the team.
2. Each developer. Create a gateway key in the same settings page. Keys can have an expiry, and revoking one takes effect immediately. A user key stops working when that person leaves the organization.
3. Point the tool at the gateway. For Claude Code (Langfuse says version 2.1 or later), log out of any existing Claude login first, because a leftover login can cause a 401 for conflicting credentials. Then set:
export ANTHROPIC_BASE_URL="https://gateway.cloud.langfuse.com/anthropic"
export ANTHROPIC_AUTH_TOKEN="<your-gateway-key>"
unset ANTHROPIC_API_KEY
Langfuse's example has no /v1 on the Anthropic URL. Anthropic's own gateway guide confirms the pattern: ANTHROPIC_BASE_URL for the address and ANTHROPIC_AUTH_TOKEN for a bearer credential. Keep gateway keys out of a project's committed .claude/settings.json.
For Codex (CLI 0.157 or later), export LANGFUSE_GATEWAY_KEY, then add this to ~/.codex/config.toml:
model_provider = "langfuse"
[model_providers.langfuse]
name = "Langfuse AI Gateway"
base_url = "https://gateway.cloud.langfuse.com/openai/v1"
env_key = "LANGFUSE_GATEWAY_KEY"
wire_api = "responses"
These are the Cloud host Langfuse shows in its docs. Langfuse Cloud regions (EU, US, JP and HIPAA) each have their own host, so use the one for your region.
What you can see
The Analytics tab shows total cost, requests and tokens, cost over time, and the top users, keys and models, plus an alert for models without a price. Add key metadata such as team: platform and it is attached to every call from that key. Codex turns are grouped into one trace automatically; Claude Code, OpenCode and Pi give one trace per model call by default.
Tracing has two main modes. USAGE is the default: it records the model, token usage, cost and latency without prompts or outputs. FULL also records inputs and outputs, so settle that with whoever owns privacy before enabling it.
Beta limits to read first
Langfuse's own known-limitations page is candid, and it matters if you want to trust the numbers:
| Issue | What Langfuse says |
|---|---|
| Cost bugs | Failed or cancelled OpenAI-route calls get estimated cost (long cancelled Codex calls showed about $6 each); OpenAI cache-write tokens priced at $0; Anthropic 1-hour cache writes priced 37.5% too low. Fixes in progress. |
| Large calls | Input over 5 MiB is not recorded; output over 1 MiB is partial. |
| Missing features | No retries, fallbacks or caching; no websockets; decision models return 404. |
| Rate limits (Cloud) | 100 requests/min on Hobby, 500 on Core, 10,000 on Pro, Team and Enterprise. |
Each recorded generation is also a billable unit on Langfuse, and requests are capped at 600 seconds per call.
Our take
This is useful if your problem is shared access and cost visibility for coding agents. It is not a reason to route production traffic yet: the cost figures have known bugs, there are no fallbacks, and every request now depends on one more service. Start with a small pilot, compare Langfuse's totals with your provider invoice, and keep your own key for urgent work.
One policy point: OpenAI's updated usage policy says services that give third parties access to its models need approval from 20 November. An internal gateway for your own staff is the unclear category in that rule, and neither Langfuse's docs nor OpenAI address it directly, so check before relying on it for OpenAI models.
Sources
- Langfuse AI Gateway public beta (changelog, 4 Nov 2026)
- Langfuse: Trace Claude Desktop and Claude Code with the AI Gateway (beta)
- Langfuse: Trace OpenAI Codex with the AI Gateway (beta)
- Langfuse: How the AI Gateway works (beta)
- Langfuse: known limitations of the AI Gateway beta
- Anthropic: Connect Claude Code to an LLM gateway
FAQ
Does the Langfuse AI Gateway replace my OpenAI or Anthropic key?
No. An admin stores your own provider key in Langfuse, and each developer uses a separate gateway key. The provider still bills you directly for model usage.
Can I use it with both Claude Code and Codex?
Yes, if you add both an Anthropic and an OpenAI credential. Claude Code goes through the Anthropic route and Codex through the OpenAI route; the gateway does not convert between the two formats.
Is it free?
Not entirely. Langfuse says each recorded generation is a billable unit, and your provider bills model usage separately. Check your Langfuse plan before a team-wide rollout.
Can I self-host it?
Langfuse says a self-hosted open-source gateway is available. Read its docs for the self-hosted limits, since the figures above are for Langfuse Cloud.