API keys
Create, list and revoke the credentials your servers and notebooks use.
Credentials for the organization. These endpoints need a signed-in session; keys cannot manage keys. The free plan allows 5 active keys.
In an organization a key belongs to the workspace but answers to the person who created it. When they are removed or leave, their keys are revoked. While they are a viewer, their keys only read (403 read_only_role on a write) and work fully again once they are a member. Keys in a personal workspace are the account's own.
#The API key object
The secret appears once, in the response that creates the key. Afterwards only the prefix identifies it.
Attributes
key_ identifier.live or test; part of the key's prefix.The first characters of the secret, for recognising it.
Empty means the key can do everything. Otherwise read, write, or resource:read / resource:write for models, predictions, explanations, analyses, insights, projects, or organization. write includes read. A call outside the list is 403 insufficient_scope.
Updated on every authenticated request.
The account that created the key. null for a key made before this was recorded or by an account that no longer exists.
That account's name and email. They stay after the person leaves, so an admin can see whose keys were revoked.
Only on creation.
{
"object": "api_key",
"id": "key_6f2a151d6e1cd7ca3c8f",
"name": "CI pipeline",
"environment": "live",
"prefix": "km_live_EXAM",
"scopes": [],
"last_used_at": null,
"expires_at": "2027-01-29T22:40:22.818479Z",
"revoked_at": null,
"created_at": "2026-10-31T22:40:22.819488Z",
"created_by_user_id": "usr_99d45281ca85b8a7cc92",
"created_by_name": "Kaimei Demo",
"created_by_email": "demo@kaimei.ai",
"secret": "km_live_EXAMPLEnotARealKeyUseYourOwn0000"
}#List API keys
/v1/api-keysSession token onlyEvery key in the organization, newest first, including revoked and expired ones. Returns a bare array, not a page.
Query parameters
A user_id. Only the keys that account created here, revoked ones included, also after the person has left.
Returns
client.auth.login(email="you@example.com", password="...")
for key in client.api_keys.list():
print(key.name, key.prefix, key.environment, key.last_used_at, key.revoked_at)curl https://api.kaimei.ai/v1/api-keys \
-H "Authorization: Bearer $SESSION_TOKEN"[
{
"object": "api_key",
"id": "key_6f2a151d6e1cd7ca3c8f",
"name": "CI pipeline",
"environment": "live",
"prefix": "km_live_EXAM",
"scopes": [],
"last_used_at": null,
"expires_at": "2027-01-29T22:40:22.818479Z",
"revoked_at": null,
"created_at": "2026-10-31T22:40:22.819488Z",
"created_by_user_id": "usr_99d45281ca85b8a7cc92",
"created_by_name": "Kaimei Demo",
"created_by_email": "demo@kaimei.ai"
},
{
"object": "api_key",
"id": "key_9df225436f5149d1494c",
"name": "Notebook",
"environment": "test",
"prefix": "km_test_T8aL",
"scopes": [],
"last_used_at": "2026-10-31T22:40:22.813671Z",
"expires_at": null,
"revoked_at": null,
"created_at": "2026-10-31T22:37:25.380781Z",
"created_by_user_id": "usr_99d45281ca85b8a7cc92",
"created_by_name": "Kaimei Demo",
"created_by_email": "demo@kaimei.ai"
}
]#Create an API key
/v1/api-keysSession token onlyCreate a key and return its secret once. The key acts in the organization the session is working in. Counts against the API keys quota and the hourly limit (20 on the free plan). A viewer cannot create one (403 read_only_role).
Body parameters
1 to 120 characters.
live or test.Empty can do everything. Otherwise read, write, or models:read and the same form for the other resources. An unknown scope is 400 invalid_scope.
1 to 3650. Omit for a key that does not expire.
Returns
secret. 201.key = client.api_keys.create(name="CI pipeline", environment="live", expires_in_days=90)
print(key.secret) # store it now; it is not shown againcurl https://api.kaimei.ai/v1/api-keys \
-H "Authorization: Bearer $SESSION_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name": "CI pipeline", "environment": "live", "expires_in_days": 90}'{
"object": "api_key",
"id": "key_6f2a151d6e1cd7ca3c8f",
"name": "CI pipeline",
"environment": "live",
"prefix": "km_live_EXAM",
"scopes": [],
"last_used_at": null,
"expires_at": "2027-01-29T22:40:22.818479Z",
"revoked_at": null,
"created_at": "2026-10-31T22:40:22.819488Z",
"created_by_user_id": "usr_99d45281ca85b8a7cc92",
"created_by_name": "Kaimei Demo",
"created_by_email": "demo@kaimei.ai",
"secret": "km_live_EXAMPLEnotARealKeyUseYourOwn0000"
}#Revoke an API key
/v1/api-keys/{key_id}Session token onlyRevoke a key immediately. Requests with it fail with 401 invalid_api_key from then on. The record stays in the list with revoked_at set. A member may revoke the keys they created, and an owner or admin any key (403 admin_required otherwise). Revoking your own key works whatever your role, a viewer's or a paused organization's included, so a leaked key can always be stopped. A key is also revoked when the person who created it leaves the organization.
Path parameters
Returns
client.api_keys.revoke("key_6f2a151d6e1cd7ca3c8f")curl -X DELETE https://api.kaimei.ai/v1/api-keys/key_6f2a151d6e1cd7ca3c8f \
-H "Authorization: Bearer $SESSION_TOKEN"{
"id": "key_6f2a151d6e1cd7ca3c8f",
"object": "api_key",
"deleted": true
}