Skip to main content

Module inference

Module inference 

Source
Expand description

OpenRouter inference key management. OpenRouter inference key management.

Creates OpenRouter child keys per user and persists them in the users table. The stable key hash is stored alongside the secret so that keys can be invalidated via the OpenRouter API, DELETE /keys/{hash}. We leverage the OpenRouter API to put credit cap and refresh windows on the keys.

Constants§

OPENROUTER_API_URL
The base URL for the OpenRouter key-management API.

Functions§

get_inference_key
Return the user’s existing inference key, or create a new one.
invalidate_inference_key
Invalidate a user’s inference key, either by Firebase UID or username.