Gateway Keys
Understand what a Gateway Key is, then issue one, set it in a client, and revoke it when it is no longer needed.
A Gateway Key is the credential that tells AI Gateway which user and project a request comes from. You put this one key in your client instead of a Provider API key, and use it for both model calls and MCP tool calls.
What is a Gateway Key?
Section titled “What is a Gateway Key?”- It stands in for Provider keys. Provider API keys are stored only in the Gateway. You use a Gateway Key issued in your project to call models and MCP tools.
- It belongs to one project and one user. A key works only within the project that issued it. To use another project’s models or tools, issue a separate key there.
- Access follows the project settings. An administrator must assign you a seat and give you the
ai-userrole in the project. A key reaches only the models and MCP tools allowed in that project. - Treat it like a password. The secret is shown once, right after you issue it. If it is exposed, revoke it and issue a new one. Each key can have an expiry date.
The Gateway Keys page lists only your own keys. A project administrator can list and revoke other users’ keys from the administration screen. Anyone who holds the secret can send requests as you.
This page covers issuing, checking, configuring, and revoking keys. For the overall structure, see Introduction.
Before you start
Section titled “Before you start”- Your organization administrator must assign you a seat. Without a seat, the console opens but shows the You don’t have a seat notice, and model and MCP requests are refused.
- You need the
ai-userrole in the project where you will issue the key. When you open the project, Gateway Keys must appear in the top menu (GNB). If it is missing, ask a project administrator for the role. - Check that the project already allows the models, MCP servers, and toolsets you want to use. A key never reaches beyond the project that issued it.
The top menu places Gateway Keys here.
1. Issue a key
Section titled “1. Issue a key”Open the project and select Gateway Keys in the top menu. On the Gateway Keys page, use Issue key in the top right to open the Issue gateway key dialog.

Key name (1) is required and accepts up to 128 characters. Name it after where it is used. Expiry date is optional; leave it blank for a key that never expires. A time in the past is rejected, and if the date and time cannot be read, the field shows an error.
Use Issue key (2) to switch the dialog to One-time secret. Its title is the key name you just chose, and the key itself is shown below it.

Press Copy secret (1) to copy the key. The button changes to Copied. When you close this screen with Close, the key is gone for good; only the Preview column in the list remains. If you close it without copying, revoke that key and issue a new one. The key starts with agw_.
2. Check the keys you issued
Section titled “2. Check the keys you issued”The list shows only the keys you issued in this project.

The key you just issued is added to the bottom of the list, as number 1 shows. Preview is the first 12 characters of the key; check that Status is Active. Last used is when this key last authenticated successfully, and updates can lag by up to 5 minutes.
A key past its expiry date turns Expired and stops authenticating. Expired keys stay in the list, so revoke them if you want the list clean.
At this point you have a key ready for a client. If Status is Active and you stored the secret, continue to the next step.
You can practice the whole flow in the demo below. Press Play to open the dialog, enter a name, issue the key, copy the secret, and close the dialog; the new key is added to the bottom of the list, which the console lists by creation date. The demo runs locally and issues no real key.
3. Set the key in a client
Section titled “3. Set the key in a client”Put the key into the client that uses it. The examples in this manual read it from the AI_GATEWAY_API_KEY environment variable.
export AI_GATEWAY_API_KEY='<your Gateway Key>'To continue the quick start, go to Set up an AI agent or Set up MCP.
- AI clients and SDKs: AI agent setup guide
- MCP clients: from step 2 of Connecting MCP clients
- SDK examples: OpenAI SDK, Anthropic SDK
If a client can only read the key from a settings file, keep that file out of Git.
4. Revoke a key
Section titled “4. Revoke a key”If a key leaks or is no longer used, press Revoke on its row, then select Revoke key in Revoke this gateway key?. Revoking cannot be undone, and clients that authenticated with it immediately receive Authentication failed. (401).
The key disappears from the list. Issue a new key and update the client.
Things to keep in mind
Section titled “Things to keep in mind”- You may hold at most 10 active keys per project at a time. Expired keys do not count. Issuing beyond that fails, so revoke keys you no longer use first.
- A key belongs to the project and the user that issued it. To use another project’s models or MCP servers, issue a key in that project.
- A key is a secret. Never put the value itself in source code, a repository, or a shared screenshot.
- A key stops authenticating when the account is deactivated or the permission is removed from the project.
When a key does not work
Section titled “When a key does not work”| Symptom | What to check |
|---|---|
Authentication failed. (401) | The value starts with agw_, Status is Active, and the client runs in the environment where you set the key. Revoked and expired keys get this error. |
| Models, MCP servers, or toolsets are missing | The key was issued in the right project, and that project allows the models and tools you want. |
| Gateway Keys shows “Gateway keys could not be loaded” | Select Try again. Check that you can manage your own keys in that project. |
For errors raised by an MCP client, see Troubleshooting MCP.