Docs / API reference
Keys and scopes API
Give each engagement or service its own key, open it to just the models and source addresses that job needs, and retire it when the work wraps up. Five routes under https://api.pentestllm.ai/v1 do this, and every one of them wants an admin key: you create that key once in the console, it administers the account, and it can neither call a model nor mint a second admin key.
Routes
| Route | Does | Statuses |
|---|---|---|
GET /v1/keys | List keys, newest first | 200, 401, 403 |
POST /v1/keys | Mint a key | 201, 400, 401, 403, 409 |
GET /v1/keys/{key_id} | Read one key | 200, 401, 404 |
PATCH /v1/keys/{key_id} | Change, pause or resume | 200, 400, 401, 404, 409 |
DELETE /v1/keys/{key_id} | Revoke for good | 200, 401, 404 |
The schema names the admin key as the only accepted credential on all five. Whether a signed-in console session works on them too, the OpenAPI document does not say.
List keys
GET /v1/keys answers data, an array of keys with the newest first. Paused and revoked keys stay hidden unless you add include_revoked=true. Sending a key that is not an admin key earns 403 forbidden; one that fails to authenticate earns 401 invalid_api_key.
Mint a key
POST /v1/keys takes a JSON object in which only name is required. The spend and session fields are covered in depth on Spend limits, and the redaction and guardrail fields on Redaction and guardrails. The console’s own field names, such as rate_limit_rpm or budget_micro, are accepted as well.
| Field | Type | Notes |
|---|---|---|
name | string, required | From 1 to 64 characters. |
environment | live or test | Defaults to live. |
format | native, claude, gpt, gemini, deepseek or glm | How the secret is shaped, for tools that insist on a vendor prefix. Defaults to native, the sk-ptl- form. The shape does not limit which models the key can call. |
scope | api | The single value this route takes. |
allowed_models | array or null | At most 100 model ids. Anything outside the list is refused. |
allowed_ips | array or null | At most 50 IPv4 or IPv6 addresses or CIDR ranges. Calls from elsewhere get 403 ip_not_allowed. |
expires_at | integer | A future moment in Unix milliseconds. |
rpm | integer | Requests a minute, 1 to 600; more on request. |
tpm | integer | Tokens a minute, 1 to 50,000,000. |
concurrency | integer | Calls in flight together, 1 to 50. |
monthly_cap_usd | number | Recurring dollar cap per period. |
spend_limit_period | daily, weekly or monthly | The period of that cap. |
budget_usd | number | A prepaid allowance for this key alone. |
user_budget_usd | number | A cap for each end user of the key. |
user_budget_period | daily, weekly or monthly | The period of that cap. |
session_max_requests | integer | Calls one session may make per sliding hour. |
session_max_spend_usd | number | Dollars one session may spend per UTC day. |
loop_guard | boolean | Stop a session that repeats itself. |
routing | cheapest, fastest or throughput | The order a model's routes are tried in. The price stays the same. |
fallback_models | array | Up to 5 ids or aliases, tried in turn when the named model fails before a byte is sent. |
response_cache_ttl | integer or null | The response cache is on by default; 60 to 86,400 seconds, or null or 0 to switch it off. |
context_overflow | error or middle-out | Defaults to error. |
retain_bodies | boolean | Hold request bodies for 7 days so they can be replayed. |
redact | off, secrets or secrets_pii | Off by default. |
guardrails | object or null | The key's own checks, layered over the organization default. |
Success is 201 carrying key, the whole secret, beside data, the key’s metadata. Store the secret straight away: no later call returns it. A field out of range or a body that is not a JSON object is 400 invalid_request. Asking for an admin scope is 403 forbidden, and 403 key_unavailable means new keys are switched off for the account. Fifty active keys is the ceiling; one more gets 409 limit_reached.
Read one key
GET /v1/keys/{key_id} returns data for one key. The id is the twelve characters that follow the environment inside the secret, drawn from digits and lower-case letters other than i, l, o and u. The object holds name, key_prefix (the part safe to display), environment, scope (api or admin), status (active or revoked), each limit under its stored name in micro-dollars or counts, the allowlists, and the times created_at, updated_at, last_used_at (refreshed at most once a minute), revoked_at and expires_at, all Unix milliseconds. An id your organization does not own is 404 not_found.
Change, pause or revoke
PATCH /v1/keys/{key_id} accepts the same settings as creation, and a null on most of them clears it. Setting status to revoked pauses the key; setting it to active resumes it. A budget can never drop under what the key has already spent against it (400 budget_below_spent); a null budget removes it, and a budget set again counts from zero. A key retired through DELETE answers 409 key_deleted to any change.
DELETE /v1/keys/{key_id} retires the key for good and returns it in its final state. There is no undo.
Example
curl "https://api.pentestllm.ai/v1/keys?include_revoked=true" \ -H "Authorization: Bearer sk-ptl-live-…"Put an admin key in the header. Per-key spend and the per-user split live on Usage and receipts.
Questions
Can an admin key run a model or mint another admin key?
Neither. It exists to manage the account, so a model call with it is refused, and the create route accepts scope api only. A fresh admin key is made in the console.
I lost a secret. Can a GET return it?
No. The full secret comes back once, in the create response. Every later read carries metadata and the short key_prefix; reveal_available only reports whether the console can display the key again.
Is pausing a key the same as deleting it?
No. A PATCH with status revoked pauses the key and status active brings it back. DELETE retires it permanently, and the requests it already made stay readable in your usage records.
Read next
- MCP servers
- Log export
- Invoices
- Billing details
- Statement signing key
- Usage and signed receipts
- Spend limits and balance
- Redaction and guardrails
- Sessions
- Embeddings, rerank and moderation
- Batch files
- Batches
- Status and proof feeds
- Count tokens
- Usage by app
- App sign-in keys
- Webhook deliveries
- Docs: connect in two minutes