Give your team Claude Code and Codex without sharing provider keys
The fastest way to roll out a coding agent is to paste one OpenAI or Anthropic API key into a team wiki. It is also the hardest setup to undo: you can't revoke one person, you can't tell who spent what, and rotating the key breaks everyone at once. An AI gateway fixes this by giving every developer and every service its own key, while the provider key stays in one place.
TL;DR: With the Langfuse AI Gateway, admins store provider connections once, and clients get gateway keys. User keys belong to one developer, record that developer on every call, and stop working when they leave the organization. Service account keys belong to the organization, for CI and shared services. Keys can expire, are revoked immediately, can carry team or cost-center metadata, and can't read any other Langfuse data. Creating and revoking keys is recorded in the audit log.
![]()
Three kinds of keys
The gateway separates the key that reaches the provider from the keys clients hold:
| Key | Held by | Purpose |
|---|---|---|
| Provider connection | Only the gateway | Calls your model provider on your account |
| User key | One developer | Coding agents and local development |
| Service account key | A CI job or a service | Pipelines and shared services that must outlive any one person |
Because clients never see the provider connection's API key, you can rotate it without touching any client, and revoke one person's access without affecting anyone else. The provider still bills model usage to your provider account. See keys and connections.
Per-developer keys for coding agents
Every gateway user creates their own key under AI Gateway → Gateway keys and pastes it into their agent's configuration. For Claude Code, that is ANTHROPIC_AUTH_TOKEN next to the gateway base URL. For Codex, it is the env_key of a custom provider. The coding agent guides show the exact setup for each agent.
What makes user keys suitable for a team rollout:
- Every call is attributed. A user key always records its owner's email as the trace user, and clients can't override it.
- Access ends with membership. A user key stops working when its owner leaves the organization, changes to a role that can't call the gateway, or deletes their account. No cleanup is needed.
- People don't need project access. The AI Gateway organization role lets someone call the gateway, manage their own keys, and see their own usage, without seeing any Langfuse project. See roles and permissions.
Viewers can't create gateway keys. Give developers the AI Gateway, Member, Admin, or Owner role.
Service account keys for CI and shared services
Owners and admins can issue a key as Service account instead of My user. A service account key:
- keeps working when people join or leave, because it belongs to the organization;
- uses its own name as the trace user, so name it after what uses it, such as
CI release pipeline; - accepts a
langfuse-user-idheader, so a shared service can forward the end user it is acting for.
Use one service account key per pipeline or service. That keeps cost per service visible and lets you revoke one without touching the others.
Expiry, revocation, and audit
- Expiry is optional on any key, and useful for contractors and temporary projects.
- Revocation takes effect immediately.
- Audit logs record creating and revoking keys, so security reviews can answer who had access and when. See audit logs.
- Scope is limited to the gateway: a gateway key can't read or write traces, prompts, or any other Langfuse data.
Attribute keys to teams and cost centers
When you create a key, add metadata such as team: platform or cost_center: 4711. The gateway attaches it to every generation recorded with that key, under langfuse.gateway.api_key.metadata.<key>, and request headers can't override it. Filter traces and custom dashboards on it to see cost per team.
To change metadata later, select Edit key in AI Gateway → Gateway keys. Whoever manages a key can edit it, so developers set the metadata on their own user keys. For cost centers that must be admin-approved, use service account keys, which only admins and owners create, or review the metadata on user keys. For a full cost-attribution setup, see FinOps for AI.
Limit which models keys can call
By default, a key can call every model enabled on your provider connections. To keep expensive or unapproved models out for everyone, turn them off per connection. To narrow one key, add model patterns such as openai-prod:* when you create it or with Edit key. See restrict models per API key and control which models your company can use.
A rollout checklist
- Add provider connections and choose the ingestion mode in AI Gateway → Overview.
- Turn off models you don't want used, and plan which keys get model patterns.
- Invite developers with the AI Gateway role, and ask each to create their own key.
- Issue one service account key per CI pipeline and shared service, with team metadata.
- Remove any shared provider keys from wikis,
.envfiles, and CI secrets, and rotate the provider key once everyone has moved.
FAQ
What happens to a developer's gateway key when they leave?
It stops working as soon as they lose gateway access, for example when they are removed from the organization. Service account keys are not affected by membership changes, so shared services keep running.
How do I rotate the OpenAI or Anthropic key?
Update the provider connection in AI Gateway → Connections & Models → Connections. Clients hold gateway keys, not the provider key, so no client configuration changes.
Can a gateway key read my Langfuse traces?
No. A gateway key can only call the gateway. Reading traces requires Langfuse project API keys or a role with project access.