These endpoints manage proxy keys (the ms- prefixed keys used for AI inference requests). Use them to create, list, update, and delete keys programmatically.
These endpoints require a billing key (mk- prefix) for authentication, not a proxy key. Billing keys are created in Dashboard → Billing Keys .
List keys
GET https://modelswitch.io/api/keys
Authentication: Authorization: Bearer mk-YOUR_BILLING_KEY
Returns all proxy keys on your account.
curl https://modelswitch.io/api/keys \
-H "Authorization: Bearer mk-YOUR_BILLING_KEY"
Response:
{
"keys" : [{
"id" : 1 ,
"name" : "Production" ,
"prefix" : "ms-abc1xxxx" ,
"active" : true ,
"createdAt" : "2024-01-01T00:00:00Z"
}]
}
List of proxy key objects. Unique key ID. Use this in update and delete requests.
Human-readable label for the key.
First characters of the key (e.g., ms-abc1xxxx). The full key value is not returned after creation.
Whether the key is currently active. Inactive keys return 403 on inference requests.
ISO 8601 timestamp of when the key was created.
Create a key
POST https://modelswitch.io/api/keys
Authentication: Authorization: Bearer mk-YOUR_BILLING_KEY
A descriptive label for the key (e.g., "Production", "CI/CD").
Optional expiry date in ISO 8601 format (e.g., "2025-12-31T00:00:00Z"). If omitted, the key does not expire.
curl -X POST https://modelswitch.io/api/keys \
-H "Content-Type: application/json" \
-H "Authorization: Bearer mk-YOUR_BILLING_KEY" \
-d '{"name": "Production", "expires_at": "2025-12-31T00:00:00Z"}'
Response:
{
"id" : 1 ,
"key" : "ms-xxxxxxxxxxxxxxxx"
}
The full key value is returned only once at creation. Copy it immediately — it cannot be retrieved again. If you lose a key, deactivate it and create a new one.
Update a key
PUT https://modelswitch.io/api/keys/{id}
Authentication: Authorization: Bearer mk-YOUR_BILLING_KEY
The ID of the key to update, from the list keys response.
Set to false to deactivate the key without deleting it.
curl -X PUT https://modelswitch.io/api/keys/1 \
-H "Content-Type: application/json" \
-H "Authorization: Bearer mk-YOUR_BILLING_KEY" \
-d '{"name": "New Name", "active": false}'
Delete a key
DELETE https://modelswitch.io/api/keys/{id}
Authentication: Authorization: Bearer mk-YOUR_BILLING_KEY
The ID of the key to delete.
curl -X DELETE https://modelswitch.io/api/keys/1 \
-H "Authorization: Bearer mk-YOUR_BILLING_KEY"
Deleting a key is permanent. Any requests using the deleted key will immediately return 401 Unauthorized. To temporarily suspend a key, use update with "active": false instead.
Billing keys (mk-)
Billing keys (mk- prefix) are used to authenticate account management API requests — the endpoints under /api/* such as balance, usage, transactions, and key management itself.
Billing keys are created using your session JWT (obtained from logging in), not with another billing key.
List billing keys
GET https://modelswitch.io/api/billing-keys
Authentication: Authorization: Bearer YOUR_JWT_TOKEN
curl https://modelswitch.io/api/billing-keys \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Response:
{
"keys" : [{
"id" : 1 ,
"name" : "Automation" ,
"prefix" : "mk-abc1xxxx" ,
"active" : true ,
"createdAt" : "2024-01-01T00:00:00Z"
}]
}
Create a billing key
POST https://modelswitch.io/api/billing-keys
Authentication: Authorization: Bearer YOUR_JWT_TOKEN
A descriptive label for the billing key.
Optional expiry date in ISO 8601 format. If omitted, the key does not expire.
curl -X POST https://modelswitch.io/api/billing-keys \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-d '{"name": "Automation"}'
Response:
{
"id" : 1 ,
"key" : "mk-xxxxxxxxxxxxxxxx" ,
"prefix" : "mk-xxxxxxxx"
}
The full key value is returned only once. Copy it immediately — it cannot be retrieved again.
Delete a billing key
DELETE https://modelswitch.io/api/billing-keys/{id}
Authentication: Authorization: Bearer YOUR_JWT_TOKEN
curl -X DELETE https://modelswitch.io/api/billing-keys/1 \
-H "Authorization: Bearer YOUR_JWT_TOKEN"
Response: {"status": "deleted"}