> For the complete documentation index, see [llms.txt](https://docs.kontinent.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kontinent.ai/overview/authentication.md).

# Authentication

Every data-plane request authenticates with a bearer token:

```
Authorization: Bearer sk-kt-<43 base62 chars>
```

## Key facts

* Keys are **49 characters** total (`sk-kt-` plus 43 base62 characters).
* A key is shown **exactly once** at creation. Only a SHA-256 hash is stored. Kontinent cannot recover a lost key, so store it securely.
* Keys **do not expire**. Revoke them from the dashboard; revocation takes effect within about **30 seconds** (the auth cache TTL).
* Every request is scoped to the key's **organization**, which owns the credit balance, rate limit, and usage attribution.

{% hint style="warning" %}
Treat a `sk-kt-` key like a password. Anyone holding it can spend your organization's credits. Prefer environment variables or a secrets manager over committing keys to source control.
{% endhint %}

## Using the key

{% tabs %}
{% tab title="TypeScript" %}

```typescript
const client = new OpenAI({
  baseURL: "https://api.kontinent.ai/v1",
  apiKey: process.env.KONTINENT_API_KEY,
});
```

{% endtab %}

{% tab title="Python" %}

```python
client = OpenAI(
    base_url="https://api.kontinent.ai/v1",
    api_key=os.environ["KONTINENT_API_KEY"],
)
```

{% endtab %}

{% tab title="curl" %}

```bash
curl https://api.kontinent.ai/v1/models \
  -H "Authorization: Bearer $KONTINENT_API_KEY"
```

{% endtab %}
{% endtabs %}

## When authentication fails

A bad or revoked key returns `401` with code `invalid_api_key`. **Do not retry.** The outcome will not change until you supply a valid key.

| Status | `code`                 | What it means                                                    |
| ------ | ---------------------- | ---------------------------------------------------------------- |
| `401`  | `invalid_api_key`      | Bad or revoked key. Fix the credential; retrying won't help.     |
| `402`  | `insufficient_credits` | The key is valid, but the organization's balance is exhausted.   |
| `502`  | `upstream_auth_error`  | A provider rejected **our** credentials, not yours. Our problem. |

See [Handling errors](/features/errors.md) for the full taxonomy.

## Related

{% content-ref url="/pages/lu40tWXSSYv1E99p9B1Z" %}
[Rate limits & credits](/features/rate-limits.md)
{% endcontent-ref %}

{% content-ref url="/pages/gJyUCtzhTvMq5MNXJfuc" %}
[API reference](/reference/api-reference.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.kontinent.ai/overview/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
