Several monitors showing analytics charts on a desk, illustrating tracking AI coding agent spend with the Langfuse AI Gateway
Photo by Jakub Żerdzicki on Unsplash · source · credits

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.

Flow from developer tool to Langfuse AI Gateway to the model provider, with a trace recorded
How a request travels, based on Langfuse's core-concepts page. Illustration, not a screenshot.

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.
Chart of Langfuse AI Gateway beta rate limits per plan: Hobby 100, Core 500, Pro Team Enterprise 10,000 requests per minute
Rate limits as documented by Langfuse on 5 Nov 2026; they can change during the beta.

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

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.

About the author

Suraj Kumar builds and edits AIUseFlow, a directory of AI tools for vibe coders, agent builders and creators. News summaries are written in our own words and link to the original reporting. How we rank tools.

Get the weekly stack

Rank movers and new AI tools for builders, once a week. Free, no spam, unsubscribe anytime.