> ## Documentation Index
> Fetch the complete documentation index at: https://docs.krun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Krun API base URL: https://api.krun.ai. Authenticate server-side with `Authorization: Bearer $KRUN_API_KEY`; never put a Krun API key in browser code.
> Prefer the Python SDK in examples: `pip install krun-ai`, `from krun import Krun`. The TypeScript SDK `@krun-ai/sdk` is not published on npm yet: do not tell users to `npm install` it.
> The only question type is `choice`. `confidence` is the top-1 minus top-2 probability margin, not the probability that the answer is correct. `choice` is null when `abstain` is true.
> Usage reports `input_tokens` only. There are no output tokens.

# Authentication

> Authenticate Krun API requests with a bearer API key from your server. Never expose a key in client-side code.

The Krun API uses API keys. Send your key in the `Authorization` header of every `/v1` request:

```http theme={null}
Authorization: Bearer krun_live_...
```

<CodeGroup>
  ```bash curl theme={null}
  curl https://api.krun.ai/v1/models \
    -H "Authorization: Bearer $KRUN_API_KEY"
  ```

  ```python Python theme={null}
  from krun import Krun

  client = Krun()                          # reads KRUN_API_KEY
  client = Krun(api_key="krun_live_...")   # or pass it explicitly
  ```
</CodeGroup>

## Getting a key

Krun is in closed beta. API keys are issued per project: [request access](https://krun.ai). Keys start with `krun_live_`.

Every key of a project shares the project's quotas and can send feedback for the project's decisions. Rate limits apply per key. See [Rate limits and quotas](/resources/rate-limits-and-quotas).

## Keep keys on the server

<Danger>
  **Never expose a Krun API key in browser or client-side code.** Anyone who can read the key can make requests with it and use your quota.
</Danger>

Krun is a server-to-server API:

* Call it from your backend, a serverless function or a worker, never from a web page, mobile app or desktop app.
* There is no browser SDK, and the API does not send CORS headers.
* Store the key in an environment variable (`KRUN_API_KEY`) or a secret manager. Don't commit it to source control.
* Use a separate key per service or environment, so you can revoke one without affecting the others.

If a key is exposed, [contact support](/resources/support) to revoke it and get a new one.

## Authentication errors

A missing, malformed, unknown or revoked key returns `401`:

```json theme={null}
{
  "error": {
    "code": "UNAUTHORIZED",
    "message": "missing, invalid or revoked API key",
    "request_id": "req_9475ca2887b4400a9ae9bec5563746ac"
  }
}
```

The Python SDK raises `krun.AuthenticationError`. Don't retry it: fix the key first.
