Before you start
You need:- A LangWatch account with a project.
- One provider credential under Settings > Model Providers, for example your OpenAI API key. The gateway uses the credentials already configured there. See Providers.
- The
virtualKeys:createpermission in the project. Team Member and Team Admin hold it by default. See RBAC.
1. Create a virtual key
- Open AI Gateway > Virtual Keys and click New virtual key.
- Enter a name, for example
acme-support-agent. - Keep Ownership on Project. Traces and costs of this key land in the selected project.
- Optionally set a Budget, for example
$50per month. The key is blocked at the limit. - Keep Provider access on All providers, or select the providers this key may reach.
- Click Create.

The New virtual key drawer: name, ownership on the project, a $50 monthly budget with the inherited organization budget below it, and provider access.
vk-lw-01HZX9N.

The secret dialog, shown once, with a copy button and a usage example for the OpenAI SDK.
2. Send a request
Point the OpenAI SDK at the gateway and use the virtual key as the API key. Name the model asprovider/model, for example openai/gpt-5-mini. A bare gpt-5-mini also works when one of the key’s providers serves it.
base_url="https://gateway.langwatch.ai" and the virtual key as api_key. The SDK sends the key in the X-Api-Key header, which the gateway accepts. See Python SDK and TypeScript SDK.
3. Open the trace
Open Trace Explorer in the project you selected under Ownership. The request appears as agen_ai.chat span with the model, the tokens, the cost and these attributes:

One gateway request in Trace Explorer: duration, cost, tokens and model in the header, the gateway attributes under Metadata.
4. See the spend
Open AI Gateway > Usage for total spend, requests, cost per request, top virtual keys and top models over the selected period. The Virtual Keys list shows a Spent this month column per key, and clicking it opens Usage filtered to that key.
AI Gateway > Usage over the last 30 days: the four tiles, the top virtual keys and the top models.