Key management API
Create keys and manage limits and restrictions in code
If it’s necessary to issue keys separately for each customer or service, then instead of using a console, the keys can be created through APIs. This way, limits and restrictions can be set for each key.
Creating a management key
The key management API requires a management key. Choose Management key as the purpose on The new keyboard interface in the console.
- The management key cannot be used to invoke the model. The general key, on the other hand, cannot be used to invoke the key management API.
- The administrative keys cannot be created, changed, or deleted through the API. They can only be done through the console.
- Also, assign IP addresses and expiration dates that can be used for administrative purposes.
Create key
curl https://alprouter.com/api/v1/keys \
-H "Authorization: Bearer alp-management-key" \
-H "Content-Type: application/json" \
-d '{
"name": "customer A",
"limit": 50,
"allowed_models": ["anthropic/*"],
"allowed_ips": ["203.0.113.0/24"],
"expires_at": "2027-12-31T23:59:59+09:00"
}'The response from key is new. This response can only be seen once, so save it right away. data.id will be used later, when this key needs to be fixed or deleted.
| Item | Value | Explanation/Description |
|---|---|---|
name | Text/Text | It’s important to write down the child’s name when creating it. |
limit | Numbers · Null | The maximum amount that can be transferred using this key (in dollars). If it’s “null”, there is no limit. |
disabled | true · false | Let’s take a pause for a moment. |
allowed_models | List · null | It’s a model that allows for such operations. It’s possible to use asterisks, just like in “anthropic/*”. |
allowed_ips | List · null | IP addresses or bandwidth that can be used |
expires_at | Vision · null | After this time passes, the key will stop working. |
Viewing, fixing, removing
# List (100per page, ?offset=100for the next page)
curl https://alprouter.com/api/v1/keys -H "Authorization: Bearer alp-management-key"
# Increase the spending limit and pause the key. Only supplied values change
curl -X PATCH https://alprouter.com/api/v1/keys/key-id \
-H "Authorization: Bearer alp-management-key" \
-H "Content-Type: application/json" \
-d '{"limit": 100, "disabled": true}'
# Delete. Deleted keys stop working immediately
curl -X DELETE https://alprouter.com/api/v1/keys/key-id -H "Authorization: Bearer alp-management-key"- In list and detail responses,
usageis the amount spent with the key (USD), andlimit_remainingis its remaining limit. - The original key can no longer be seen. In
label, only a few characters before and after the key are displayed. - You can create up to 50 accounts per user.
- What was done through the API is also recorded in the console’s security logs.