Skip to main content
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"
  }]
}
keys
array
List of proxy key objects.

Create a key

POST https://modelswitch.io/api/keys
Authentication: Authorization: Bearer mk-YOUR_BILLING_KEY
name
string
required
A descriptive label for the key (e.g., "Production", "CI/CD").
expires_at
string
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
id
integer
required
The ID of the key to update, from the list keys response.
name
string
New label for the key.
active
boolean
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
id
integer
required
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
name
string
required
A descriptive label for the billing key.
expires_at
string
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"}