AI access with LiteLLM: sell API keys with a budget
An AI access product gives each customer a virtual key on your LiteLLM gateway. The customer points any OpenAI compatible tool at your gateway address with that key. NexoVirt creates the key when the order is placed, blocks it when the service is suspended, unblocks it on resume, deletes it with the service and shows the customer what they spent. It is a provisioning module for a service product and is part of the shop feature.
Connect a gateway
Section titled “Connect a gateway”- Open Settings > AI gateways, or AI > Gateways in the sidebar once a gateway exists.
- Choose Add and fill in LiteLLM URL (the address of the gateway, for example
https://llm.example.com), Master key and a Name. - Save. NexoVirt tests the connection and shows the number of keys on the gateway.
The master key is stored encrypted, is write-only (it is never shown again) and never reaches the browser or a customer. The gateway list (AI > Gateways) shows each gateway’s LiteLLM Version and its Models. Under AI > Keys you see every virtual key of your gateways.
Create the product
Section titled “Create the product”Create a service product (see Service & free products), open its Provisioning tab and pick your gateway. Then choose how the customer pays:
- Flat price with included budget: the product price is the price for a period, and Included budget (USD per period) is the model cost the key may use in it. The budget starts again with every paid renewal.
- Pay per use: the customer pays for what they use. Price per 1 USD of model cost is what you charge for every 1 USD the models cost, so a price of 1.20 earns you 0.20 on each dollar of usage. The product price itself is an optional base fee.
Allowed models is a comma separated list of model names. Empty means every model on the gateway.
What customers see
Section titled “What customers see”On the service page in the portal the AI usage card shows:
- the spend this period (flat: against the included budget with a bar; pay per use: the spend, what was Charged and how long the balance lasts, Balance lasts about N days),
- a table of Model, Requests, Tokens and Spend, and a chart of the Last 30 days,
- Your API key with the Base URL to copy and the key ending.
The key itself is shown once: Show key reveals it after the order (copy it right away). New key replaces the key with a fresh one, and the old key stops working at once. A customer can create a new key up to five times per hour. You see the same card on the service page under Shop > Services, without the key buttons.
Usage is read from the gateway every few minutes, so the card can be a little behind.
When the balance runs out (pay per use)
Section titled “When the balance runs out (pay per use)”The cost of the models is booked to the customer balance once a day, in whole cents. NexoVirt also limits the key to what the balance can still pay for. When the balance is used up the service is suspended and the key is blocked; the portal asks the customer to top up and sends an email. After a top-up the service resumes by itself and the key works again. A warning email goes out when the balance lasts about a day or less.
Create a key for a customer
Section titled “Create a key for a customer”You can also give a customer a key directly, without an order: Create key for customer on AI > Keys or on a gateway’s page opens a dialog with:
- Connection (only when you have several gateways) and Customer.
- Product: one of your AI products (it sets the budget and models), Free: no billing, or Own price.
- For Free and Own price: Budget (USD) (empty = no limit) and Allowed models (comma separated, empty = all).
- For Own price: Price per period and Billing period (Monthly, Every 3 months, Every 6 months, Yearly).
- For a product or an own price: Paid until and Renew from the customer’s balance. Nothing is charged now.
The new key is shown once to the customer on their service page (Show key), never to you. A reseller’s customer needs a product of that reseller.
Link existing keys
Section titled “Link existing keys”You can sell an existing key without changing it: on AI > Keys, choose Link to customer on a key that is not linked, pick the customer and the Product: one of your products, Free: no billing (the customer just owns it; nothing is billed, renewed or suspended for payment) or Own price (renews from the customer’s balance like a product). With a product or an own price, Next renewal is the date it is paid until; nothing is charged now. The key keeps working as before; NexoVirt does not know the key text, so the customer sees the key ending only and can create a new key when they need the text.
Security
Section titled “Security”- Only the hash of a virtual key is stored in NexoVirt. The key text is held encrypted until the customer has revealed it, then removed.
- The master key is encrypted, write-only and never shown.
- Keys are bound to one service. A suspended service has a blocked key; a deleted service has its key deleted.
- Customers see only their own keys and usage. An administrator who is signed in as the customer cannot reveal or replace the key.
NexoVirt is developed and designed by Nucez Software, your partner for custom software and web design.