> For the complete documentation index, see [llms.txt](https://k-ai.gitbook.io/knowledge-ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://k-ai.gitbook.io/knowledge-ai/authentication/api-keys.md).

# Instance API keys

{% hint style="info" %}
**When to use:** see [Choose your auth](/knowledge-ai/authentication/authentication.md#choose-your-auth) for the decision rule. This page covers the Instance API key model.
{% endhint %}

The **KAI Instance API** (`https://api.kai-studio.ai`) uses static API-key authentication. Every request must carry two headers.

## Obtaining credentials

* Go to your KAI admin portal → **Instances** → select your instance → **API credentials**.
* Copy the `instance_id` and `api_key`.
* If you do not have access to the admin portal, contact KAI support.

## Request headers

```http
instance-id: <your-instance-id>
api-key: <your-api-key>
Content-Type: application/json
```

*(Exact header names are `instance-id` and `api-key`, lowercase with hyphens.)*

## Scope & isolation

One `(instance_id, api_key)` pair grants access to **exactly one instance**. Permissions are not user-level — there is no notion of "user" on this API. Any caller presenting the correct headers has full instance access.

## Rotation

To rotate a compromised key:

1. Admin portal → **Instances** → **Regenerate API key**.
2. The previous key is revoked immediately.
3. Update any deployed integrations with the new value.

{% hint style="warning" %}
**Never expose an instance API key in client-side code** (browsers, mobile apps, public widgets). This is a machine-to-machine credential only. For user-facing scenarios, use [**K-AI MCP**](/knowledge-ai/k-ai-mcp/mcp.md) with OAuth 2.1 instead.
{% endhint %}


---

# 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://k-ai.gitbook.io/knowledge-ai/authentication/api-keys.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.
