Skip to main content

Module gateway

Module gateway 

Source
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.

Structs§

EnsuredKey
A key from ensure_key.
IssuedKey
A personal key as issued.
KeyStore
The personal keys visdom holds, one per console, project and account.
KeyStoreLock
Held while a key is looked up, issued and stored; released when dropped.
ModelsError
Why the LLM gateway’s models could not be listed.
OpenProject
A project the developer may issue themselves a personal key for.

Constants§

MIN_KEY_SECONDS_LEFT
A key with less than this left is replaced rather than handed out.

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.
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). rejected is 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 for project_id. This revokes their previous one for that project.
key_store_path_in
llm_gateway_url
The LLM gateway’s public address, from the console’s settings.
models
The model aliases key may 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.