# API

> The API addresses of KONG API AI, how to authenticate, its own headers (Idempotency-Key, X-Router-Session, X-GW-Customer) and how to look up a request.

Source: https://kongapiai.com/en/docs/api

## Base URL and authentication

```text
https://kongapiai.com/v1
```

Send the key in the `Authorization: Bearer gw_live_…` header. Tools that use the Anthropic format may send it in the `x-api-key` header.

## Endpoints

| Method | Address | Use |
| --- | --- | --- |
| POST | `/v1/chat/completions` | Chat, OpenAI Chat Completions format |
| POST | `/v1/responses` | OpenAI Responses format |
| POST | `/v1/messages` | Anthropic Messages format |
| GET | `/v1/models` | The models this key may use |
| GET | `/v1/key` | This key's own details: limit, models, state |
| GET | `/v1/requests/{id}` | The state of one request |
| DELETE | `/v1/requests/{id}` | Ask to cancel a running request |

## Idempotency-Key

Send an `Idempotency-Key` header with a unique ID for each request, for example a UUID.

- The same ID again after the request was accepted: the API returns `409` with `duplicate_request` and the `request_id` of the first request. The provider is not called a second time.
- The same ID with a different body: the API returns `409` with `idempotency_conflict`.

If you do not send the header, KONG API AI generates an ID, and every retry counts as a new request.

## X-Request-ID

Every answer carries an `X-Request-ID` header. Record it in your logs. Use it to look the request up:

```bash
curl https://kongapiai.com/v1/requests/REQUEST_ID \
  -H "Authorization: Bearer gw_live_…"
```

## X-Router-Session

Send `X-Router-Session` with any stable ID, for example a conversation ID. Requests with the same ID use the same AI source, so a long conversation does not change source halfway.

## X-GW-Customer

For one key that serves many of your customers. See [Usage per customer](https://kongapiai.com/en/docs/customers).

## Size limit

A request body may be up to 2 MB. Above that the API returns `413` with `body_too_large`.
