Get started

Authentication

Send your API key in a header, manage keys from the dashboard, and keep them off the browser.

On this page

Send your key

Every request needs an API key, sent in either of these headers:

HeaderValueSent by
AuthorizationBearer sk-kalsenti-…The OpenAI SDK
x-api-keysk-kalsenti-…The Anthropic SDK

Both work on every endpoint, whichever format it speaks. If a request has both, only Authorization is read, so it has to be the Bearer form.

curl https://gateway.kalsenti.ai/v1/models \
  -H "Authorization: Bearer $KALSENTI_API_KEY"

What a key looks like

Keys start with sk-kalsenti-, followed by a long random string. The Developer page lists each key by its name and its first 20 characters, so you can tell them apart without showing the whole key.

Anything that doesn’t start with sk-kalsenti-, or is longer than 256 characters, is refused straight away.

Create, reveal, rotate and revoke

Keys live on the Developer page. Each one shows when it was created and roughly when it was last used.

ActionWhat it doesAsks who you are
CreateMakes a new key with a name of up to 64 characters. You can have 20 active keys at once.After two hours
RevealShows a key again, so you can copy it to another server. A key that can’t be shown says so, and rotating it gives one that can.After two hours
RotateGives the key a new secret and keeps its name. The old secret stops working within about a minute.After two hours
RevokeStops the key for good, within about a minute. It can’t be undone.Never, so a leaked key can be stopped quickly

Rotating has no overlap period: once the old secret stops, only the new one works. To change keys without any failed requests, create a second key, move your servers to it, then revoke the first.

When we ask who you are

Creating, revealing and rotating a key all hand out a working secret, so if it’s been more than two hours since you signed in, the dashboard asks you to confirm it’s you first:

  • with a code from your authenticator app, if you’ve turned on two-factor authentication;
  • otherwise with your password;
  • or, if you sign in with GitHub or Google and have no password, by signing in again.

Confirming unlocks these actions for two more hours, and each one you take restarts that time. After five wrong answers you’ll need to wait 15 minutes before trying again. Revoking never asks.

Keep keys on your server

Anyone who has one of your keys can spend your credit. Treat keys like passwords:

  • Call the API from your own server, never from a web page or a mobile app. The API doesn’t accept requests from other websites’ pages, so browsers block them anyway.
  • Keep keys in environment variables or a secrets manager, out of your code and your repository.
  • Use one key for each app or environment. You can then rotate or revoke one without touching the rest, and the Usage page shows which key made each request.
  • If a key might have leaked, revoke it straight away and create a new one. If someone else may have used your account, email support@kalsenti.ai.

When a key is refused

A missing, malformed, revoked or unknown key gets a 401, in the same format as the endpoint you called. The message never says which of these it was.

{
  "error": {
    "message": "Invalid API key",
    "type": "invalid_request_error",
    "param": null,
    "code": "invalid_api_key"
  }
}

A key you’ve just revoked or rotated can still work for up to a minute before it’s refused. If a key you expect to work is refused, check it on the Developer page, and that nothing has trimmed or wrapped it.

Check a key
curl -i https://gateway.kalsenti.ai/v1/models -H "Authorization: Bearer $KALSENTI_API_KEY"