# Quickstart

Send your first request to kenari with a free model. You need a kenari account and either a terminal or a Python or JavaScript project.

## 1. Create a key

Sign in to the [dashboard](/login), open **API Keys**, and select **Create API Key**. Add a label if you want, then select **Create Key**. Copy the key right away, because kenari shows it only once.

## 2. Set your key

Keep the key in an environment variable. The rest of the docs read it from `KENARI_API_KEY`.

```bash
export KENARI_API_KEY=kn-...
```

## 3. Send a request

This request calls a `:free` model, so it costs nothing and works with a zero balance.

```bash
curl https://kenari.id/v1/chat/completions \
  -H "Authorization: Bearer $KENARI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "step-3-7-flash:free",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'
```

A successful call returns HTTP 200 and a JSON body. The answer is in `choices[0].message.content`.

```json
{
  "id": "...",
  "object": "chat.completion",
  "model": "step-3-7-flash:free",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hello! How can I help you today?" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 9, "completion_tokens": 10, "total_tokens": 19 }
}
```

The free models change over time. List the current ones with the public models endpoint (the command needs `jq`):

```bash
curl https://kenari.id/v1/models | jq -r '.data[] | select(.pricing.free) | .id'
```

## 4. Call from code

The OpenAI SDKs work with kenari. Point them at `https://kenari.id/v1` and keep the rest of your code.

```bash
pip install openai
```

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://kenari.id/v1",
    api_key=os.environ["KENARI_API_KEY"],
)

response = client.chat.completions.create(
    model="step-3-7-flash:free",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```

```bash
npm install openai
```

```js
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://kenari.id/v1",
  apiKey: process.env.KENARI_API_KEY,
});

const response = await client.chat.completions.create({
  model: "step-3-7-flash:free",
  messages: [{ role: "user", content: "Hello!" }],
});
console.log(response.choices[0].message.content);
```

The Anthropic SDKs work too, with the base URL `https://kenari.id` and no `/v1`. See [Messages](/en/docs/messages).

## 5. Add balance for paid models

Free models have per-minute and daily limits. To call paid models, open **Balance** and top up with QRIS from Rp 1,000. See [How billing works](/en/docs/billing).

## Troubleshooting

| Symptom | Cause | Fix |
| --- | --- | --- |
| `401` with a plain-text body | The key is missing, mistyped, cut off when copied, or revoked | Check `echo $KENARI_API_KEY`. If the key is lost, create a new one under **API Keys**. |
| `400` with `model_not_found` | The model id is wrong | Copy an id from [Models and pricing](/en/docs/models). |
| `402` with `insufficient_balance` | A paid model was called with too little balance | Switch to a `:free` model, or top up. |
| `405` | The base URL has the wrong path, such as `/v1/v1` or a missing `/v1` | Use `https://kenari.id/v1` for OpenAI clients and `https://kenari.id` for Anthropic clients. |
| `429` | A rate limit was reached. It can be a free-model limit, your account limit or a provider limit | Read the `code` in the error, and wait for the `Retry-After` seconds if the response has that header. See [Rate limits](/en/docs/rate-limits). |

## See also

- [Authentication and API keys](/en/docs/authentication): send, restrict, share and revoke keys.
- [Chat completions](/en/docs/chat): every request field and the response shape.
- [Models and pricing](/en/docs/models): the model list and prices.
- [Claude Code](/en/docs/claude-code), [Codex](/en/docs/codex) and the [kenari CLI](/en/docs/cli): use kenari from a coding agent.
- [Errors](/en/docs/errors): every error code and what to do about it.
