Authorization header.
POST /api/v3/keys. Existing keys can be listed and revoked through the same endpoint family.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Authenticate API requests with a bearer token.
Authorization header.
Authorization: Bearer $LIGHTON_API_KEY
POST /api/v3/keys. Existing keys can be listed and revoked through the same endpoint family.
from lighton import ApiKey, LightOn
with LightOn() as client: # reads LIGHTON_API_KEY from the environment
# Omitting expires_at creates a key that never expires
key = ApiKey(name="ci-pipeline").create(client)
print(key.id, key.key.get_secret_value()) # the secret is shown once, store it now
# List the keys you already have, then revoke this one
for existing in ApiKey.list(client):
print(existing.id, existing.name, existing.prefix)
key.delete()
import os
import requests
headers = {"Authorization": f"Bearer {os.environ['LIGHTON_API_KEY']}"}
# expires_at is required: null creates a key that never expires
response = requests.post(
"https://api.lighton.ai/api/v3/keys",
headers=headers,
json={"name": "ci-pipeline", "expires_at": None},
)
key = response.json()
print(key["id"], key["key"]) # the full key is returned only here, store it now
# Revoke it when it is no longer needed
response = requests.delete(
f"https://api.lighton.ai/api/v3/keys/{key['id']}",
headers=headers,
)
print(response.status_code) # 204
# Create a key. The full `key` value is in this response and nowhere else.
curl https://api.lighton.ai/api/v3/keys \
-H "Authorization: Bearer $LIGHTON_API_KEY" \
-H "Content-Type: application/json" \
-d '{"name": "ci-pipeline", "expires_at": null}'
# Revoke it (204 No Content)
curl -X DELETE https://api.lighton.ai/api/v3/keys/$KEY_ID \
-H "Authorization: Bearer $LIGHTON_API_KEY"
| Status | Meaning |
|---|---|
401 | Missing or invalid API key |
403 | Key exists but lacks permission for this resource |
429 | Rate limit exceeded |