Reseller API
If you sell access to models under your own brand, the reseller API lets your server create keys for your customers, move balance onto them and revoke them — without a browser and without your account session.
The management key
A management key starts with rk-mf-. Create it on API keys, under Management key; it is shown once and only a hash is kept. It authenticates the reseller endpoints and nothing else: it cannot call a model, so a leak cannot be spent on tokens. Keep it on your server, never in a browser bundle or a mobile app.
Send it as a bearer token:
Authorization: Bearer rk-mf-…
Creating a new management key revokes the previous one immediately. Revoking it from the dashboard stops every reseller call at once; keys your customers already hold keep working, because they are ordinary API keys on your account.
Endpoints
| Method and path | What it does |
|---|---|
GET /v1/reseller/keys | List the keys on your account with cap, spend and limits |
POST /v1/reseller/keys | Create a key and return it once |
POST /v1/reseller/keys/:id/revoke | Revoke a key and return its unspent cap to your balance |
POST /v1/reseller/transfer | Move balance from your account onto a key's cap |
All four answer JSON. Errors use the same envelope as the model API: {"error":{"message":"…"}}, with 401 for a bad or revoked management key, 402 when your balance is too low, 404 for a key that is not yours and 409 when you hit the 25-key limit.
Create a key
curl https://api.mafiallm.com/v1/reseller/keys \
-H "Authorization: Bearer $MAFIALLM_MGMT_KEY" \
-H "content-type: application/json" \
-d '{"name":"customer-42","cap_usd":10,"at_once":4,"per_minute":60}'
The answer contains the raw key once, plus its id:
{"id":"key_9f2c1ab34d5e","key":"sk-mf-…","cap":10,"at_once":4,"per_minute":60,"once":true}
Store the key, hand it to your customer, and keep the id — it is what you use to top the key up or revoke it later. name is capped at 40 characters. cap_usd defaults to 0 (no cap of its own, spending your balance), at_once is 1–100 and defaults to 20, per_minute is 1–10000 and defaults to 200.
List keys
curl https://api.mafiallm.com/v1/reseller/keys \
-H "Authorization: Bearer $MAFIALLM_MGMT_KEY"
{"data":[{"id":"key_9f2c1ab34d5e","name":"customer-42","key":"sk-mf-abcd…wxyz",
"cap":10,"spent":1.24,"at_once":4,"per_minute":60,
"created_at":"2026-12-02T09:14:00.000Z","last_used":"2026-12-02T10:02:11.000Z",
"revoked":false,"disabled":false}]}
The key itself is returned masked; the raw value exists only in the create response.
Move balance onto a key
curl https://api.mafiallm.com/v1/reseller/transfer \
-H "Authorization: Bearer $MAFIALLM_MGMT_KEY" \
-H "content-type: application/json" \
-d '{"key_id":"key_9f2c1ab34d5e","amount_usd":5}'
{"ok":true,"moved":5,"key_cap":15}
The amount leaves your account balance and is added to the key's cap in one step, so a key's cap can grow over time as the customer pays you. A transfer larger than your balance answers 402 and moves nothing.
Revoke a key
curl -X POST https://api.mafiallm.com/v1/reseller/keys/key_9f2c1ab34d5e/revoke \
-H "Authorization: Bearer $MAFIALLM_MGMT_KEY"
{"ok":true,"refunded":3.76}
Revoking stops the key at once and returns whatever is left of its cap — cap minus spend — to your balance. Revoking twice is safe: the second call answers 200 with refunded: 0.
What your customers get
Your customers use the key exactly like any other MafiaLLM key: the same /v1 base URL, the same OpenAI and Anthropic formats, the same models and prices. Their usage shows up in your Usage page under each key's name, which is what you bill against.