Are you a developer or an admin?
The fastest path depends on which side of the rollout you’re on. Pick one before continuing:I'm a developer
Your admin already wired up the gateway and you got an SSO sign-in link or asked to install
langwatch.Skip ahead to Personal IDE keys: langwatch login --device provisions your virtual key automatically. You don’t need to set up providers, budgets, or routing.I'm an org admin
Your company just bought governance and you’re rolling it out for the team.Skip ahead to Admin setup: connect SSO, providers, and routing policies once, every developer auto-onboards from there.
You’ll need a LangWatch account, an organisation admin or project admin role, and at least one model provider (OpenAI, Anthropic, Azure OpenAI, Bedrock, Vertex, or Gemini) configured at Settings → Model Providers. If you haven’t set one up yet, start there, the AI Gateway reuses those credentials.
Python, TypeScript SDK
Drop-in for the OpenAI, Anthropic SDKs, swap
base_url and api_key.Use it from your coding assistant
Wire Claude Code, Codex, OpenCode, Cursor, or Aider through the gateway.
Core concepts
Virtual keys, budgets, ModelProvider gateway settings, routing policies, cache rules, fallback chains.
API reference
OpenAI-compatible
/v1/chat/completions + Anthropic-shape /v1/messages.1. Create a virtual key
- Open AI Gateway → Virtual Keys in the LangWatch app.
- Click New virtual key.
- Name it, e.g.
my-first-vk. - Select which provider credentials it may use. The first one becomes the primary; later ones become the fallback chain.
- (Optional) Attach a budget, pick a cache mode, attach guardrails.
- Click Create.
vk-lw-01HZX9K3M…) is displayed exactly once. Copy it now and store it in a secret manager. After you dismiss the dialog, LangWatch can never show it again, only the prefix vk-lw-01HZX9 remains visible in the list.
2. Call the gateway (OpenAI-compatible)
Usingcurl:
Using the OpenAI SDKs
Python:Anthropic-compatible (Claude SDK, Claude Code)
3. See the trace in LangWatch
Within ~30 seconds the request appears in the project the virtual key belongs to:- Messages view shows the prompt, response, tokens, cost, provider, cache outcome, and the full trace.
- Analytics aggregates across all VKs in the project.
- Evaluations can run on the traffic passing through the gateway.
| Attribute | Meaning |
|---|---|
langwatch.vk_id | Virtual key id. |
langwatch.project_id | Owning project. |
langwatch.team_id | Owning team. |
langwatch.org_id | Owning organisation. |
langwatch.principal_id | User or service account that made the call. |
gen_ai.usage.cache_read.input_tokens, gen_ai.usage.cache_creation.input_tokens | Cache economics (OTel GenAI semconv; zero when cache bypassed). |
langwatch.fallback.attempt | 0 on primary success, N for fallback attempts. |
4. Add a budget
Budgets live one level up from the key, they govern spend across whatever scope you attach them to.- Open AI Gateway → Budgets.
- Click New budget.
- Pick scope =
project, target = the project your VK is in. - Set window =
month, limit =$100,on_breach = block. - Save.
402 budget_exceeded. Flip on_breach to warn if you’d rather have a X-LangWatch-Budget-Warning header instead of a hard cut-off.
See Budgets for full scoping details.
Next steps
- Concepts: how VKs, budgets, guardrails, and fallback fit together.
- Fallback chains: survive provider outages with no code change.
- Caching passthrough: the load-bearing rule for keeping your 90% Anthropic cache discount.
- CLI Integrations: ship the gateway to every developer’s Claude Code, Codex, Cursor.