A model key for each agent
Give each agent its own key at your AI gateway, with the cost limit of the agent, and revoke it with the agent.
This page is a draft. The code exists, and not all of it has been run for this page yet. The page says what was checked.
What it shows
- You connect your AI gateway to LumoAuth: LiteLLM, Portkey, Kong AI Gateway or Cloudflare AI Gateway.
- LumoAuth creates a key at the gateway for each active agent. It copies the cost limit of the agent onto the key.
- You issue the key on the page of the agent and give its value to the agent, which sends it with each model call.
- You suspend the agent. LumoAuth deletes its key at the gateway, so the next model call of the agent fails.
The gateway then counts the spending of each agent separately. There is no code in this recipe: you set it up in the portal, and there is no API that returns the value of a key.
Before you start
- An account at one of the gateways, with a credential that can create keys: the master key of a LiteLLM proxy, a Portkey admin API key, a Konnect access token, or a Cloudflare API token that can create tokens.
- The gateway must have a public
https://address. LumoAuth refuses private and loopback addresses. - Connecting a gateway uses the same plan feature as the agent trace integrations. Check that your plan includes them in the plans matrix.
- The permission
settings.manageto connect the gateway, andagents.editto issue a key.
Set it up in the portal
The steps use LiteLLM. The forms of the other gateways ask for their own fields.
- Give the agent a cost limit first, because LumoAuth copies it when it creates the key. Open the agent under AI Agents, Agents, click Edit agent, and fill in Monthly cost limit under Budget and limits.
- Open Settings, Integrations, Agent ecosystem. Under AI gateways, choose LiteLLM. The portal may ask for your password again.
- Enter a Name, the Proxy base URL and the Master key of your proxy. Team ID, Default max budget (USD) and Budget duration are optional.
- Leave Enable this connection switched on, and click Add connection.
- On the saved connection, click Test connection. An error of the gateway is shown on the page.
- Open the agent again and go to AI gateway keys. Click Issue gateway key and confirm your identity.
- Copy the value of the key, and give it to the agent as its LiteLLM key. The page shows the value once.
These steps were written from the docs. Nobody has followed them for this page yet. The names of the pages, fields and buttons were read in the portal, up to the empty AI gateway keys section of an agent. No gateway account was available, so no connection was saved and no key was created.
Check the result
- The AI gateway keys section of the agent lists one key for each gateway, with its key ID and status. It never shows a value.
- In LiteLLM, the virtual key of the agent has the agent ID in
metadata.lumo_agent_id, and its spending is separate from that of other agents. - Click Suspend on the page of the agent. The key gets the status of a revoked key, and LiteLLM refuses the next call with it.
- The audit log records
ai_gateway.keys_issuedwhen you issue a key andai_gateway.key_revokedwhen the kill switch deletes it.
Limits
- The value of a key is shown once, to a person who is signed in to the portal. No API returns it.
- A key that LumoAuth created by itself, for a new agent or a new gateway, was never shown to anyone. To get a value, click Issue new keys: LumoAuth revokes the current key and creates a new one.
- The spending at the gateway does not reach the budget of the agent in LumoAuth by itself. Report it through the usage API.
- When the gateway cannot be reached, a revoked key stays Revocation pending and may still work until LumoAuth reaches the gateway.