Expand description
The AI Gateway, as a developer’s agent uses it: the console issues the developer a short-lived personal key for a project, and the agent calls the LLM gateway with it.
A new personal key revokes the developer’s previous one for that project, so a key is kept (in visdom’s own config directory, readable by the user only) and reused until shortly before it expires: sessions started side by side share it instead of cutting each other off. A kept key belongs to the account it was issued for and is not handed to another.
A subscription key (billing = subscription) is the other kind: it only
works with the developer’s own Claude subscription token, lives about 30
days, and a new one revokes nothing. Claude Code gets it once, in a header
fixed when it starts, so it is renewed a week before it expires, and the
older ones are kept until they expire for visdom logout to revoke.
Structs§
- Console
Settings - What the console’s settings say about the gateway.
- Ensured
Key - A key from
ensure_key. - Issued
Key - A personal key as issued.
- KeptKey
- A kept key, as
visdom logoutrevokes it. - KeyStore
- The personal keys
visdomholds, one per console, project and account. - KeyStore
Lock - Held while a key is looked up, issued and stored; released when dropped.
- Models
Error - Why the LLM gateway’s models could not be listed.
- Open
Project - A project the developer may issue themselves a personal key for.
- Project
Model - One alias of a project’s allow-list, as
GET /api/me/keyslists it.
Enums§
- Subscription
Traffic - Whether the gateway takes calls paid by a Claude subscription, as its
console publishes it (
subscriptionTrafficinGET /api/settings).
Constants§
- MIN_
KEY_ SECONDS_ LEFT - A key with less than this left is replaced rather than handed out.
- MIN_
SUBSCRIPTION_ KEY_ SECONDS_ LEFT - A subscription key with less than this left is replaced rather than handed out: a session started with it keeps it to its end. (Of a key that lives shorter than twice this, half its life.)
- SUBSCRIPTION_
TRAFFIC_ DENIED - The code the console and the gateway refuse subscription traffic with while the deployment denies it.
Functions§
- account_
of - Whose key it is: the issuer and subject of the developer’s access token. A key is the person’s, so one kept for somebody else who logged in on this machine before must not be handed out. Empty for a token that is not a readable JWT, which then cannot be told apart from another such token.
- console_
settings - The LLM gateway’s public address and whether it takes subscription traffic, from the console’s settings.
- ensure_
key - The developer’s key for
project_id: the stored one while it lasts, else a new one, which is then stored (a key that cannot be stored is an error).rejectedis a key the gateway no longer takes (revoked by a newer one issued elsewhere): the stored key is used only if it is another one. - issue_
key - Issue the developer a personal key of the kind
billingforproject_id. An ordinary key revokes their previous ordinary one for that project; a subscription key revokes nothing. - key_
store_ path_ in - models
- The model aliases
keymay call. This is also the proof that the LLM gateway answers and takes the key, before an agent is pointed at it. - open_
projects - The projects the developer may issue a personal key for.
- pick_
model - The model alias an agent should ask for: the configured one, else the first alias that looks made for that agent, else none (the agent’s own default, which the project must then allow).
- pick_
project - The project to use: the configured one (its slug, id or name), else the only one there is. Otherwise the choice is the developer’s, and the error names what to choose from.
- revoke_
kept - Revoke at their consoles the kept keys of the person whose access token
is
token(onvisdom logout, before the store is cleared). What could not be revoked is returned as warnings; such a key stays valid at the gateway until it expires. Keys of another account are not this token’s to revoke. - revoke_
key - Revoke the developer’s key
idat the console. A key the console no longer has (expired, or revoked already) is gone, which is what was asked.