API
A standard OpenAI-compatible API. Use it with most coding harnesses, agent frameworks, or LLM-compatible systems. Our LLM router sends your prompt to the best model for your task.
Get started
Open web chat and click the round account icon in the top right. Create a key under API keys. The key starts with kai_sk_. K.ai shows it only once. Copy it into your tool.
Then give any OpenAI-compatible tool these three settings:
- Base URL
https://api.usek.ai/v1 - API key
kai_sk_… - Model
kai
curl https://api.usek.ai/v1/chat/completions \
-H "Authorization: Bearer kai_sk_…" \
-H "Content-Type: application/json" \
-d '{
"model": "kai",
"stream": true,
"messages": [{"role": "user", "content": "Hello!"}]
}'
Models
Model kai is the full K.ai experience. The router reads each request, picks the best lane, and searches the web when that makes the answer better.
Pinned models lock one lane and add nothing. No injected prompt, no retrieval. Your harness stays in charge, which is what a coding tool usually wants.
GET /v1/models lists every model with its prices. You do not need a key.
| Model | What it does |
|---|---|
kai · kai-auto | Routed, grounded, and cited; K.ai picks the lane |
kai-fast | Everyday answers, lowest latency and price |
kai-standard | More depth for ordinary work |
kai-multilingual | Strong non-English writing and translation |
kai-vision | Images in, understanding out |
kai-flagship | The strongest general lane |
kai-coding | Hard programming work |
kai-reasoning | Deep multi-step thinking |
Tools
Function calling works the standard way, so agents work too. Send tools, get tool_calls back, return the results, repeat. Parallel calls work. So do temperature, top_p, max_tokens, stop, seed, the penalties, and JSON mode.
Model kai routes on its own and searches the web when that helps. A pinned model, or any request with tools or sampling settings, goes straight to that lane and obeys the harness.
Streams send a keep-alive every 15 seconds during silent thinking, so long runs do not drop. A streamed tool call arrives in delta.tool_calls chunks. Join the arguments fragments by index. The stream then ends with finish_reason: "tool_calls". Every chunk carries K.ai's completion id and your model name. The last chunk carries K.ai's usage and cost.
Add an Idempotency-Key header and a retried request bills once. This works on streams too. A keyed stream runs to its end even when your client drops. Send it again with the same key and the same body, and the stream plays again from the first chunk. You pay for it once. A stream that stopped after it cost you plays again as it was, error included. It still ends with a chunk that shows what it cost. A stream that cost nothing runs again. A different body under the same key gets a 400. When the server holds too many streams, a new keyed stream gets a 503. Send it again in a moment. An answer too large to keep, or one the server let go to make room, gets a 409 on retry. Use a new key to ask again. When the server keeps too many keys, a request with a new key gets a 503. Send it again in a moment.
Lost a reply? Send POST /v1/receipt with {"key": "…"} to learn what that key cost. It answers charged with the cost, held while the turn still runs or waits to settle, or unknown when your account never paid under the key. It only looks. It starts nothing, returns no answer text, and costs nothing.
{
"model": "kai-coding",
"temperature": 0.2,
"tools": [{
"type": "function",
"function": {
"name": "run_tests",
"parameters": {
"type": "object",
"properties": { "path": { "type": "string" } }
}
}
}],
"messages": [{ "role": "user", "content": "Fix the failing test." }]
}
Beyond chat
The same base URL and key cover audio, images, and embeddings. Every endpoint keeps the standard OpenAI shape and the same transparent pricing.
POST /v1/audio/transcriptionsturns audio into textPOST /v1/audio/speechturns text into spoken audioPOST /v1/images/generationsmakes an image and returns it inlinePOST /v1/embeddingsembeds text in over 100 languagesPOST /v1/searchsearches the web. A search costs at most 24,600 micro-dollars ($0.0246), or at most 34,850 ($0.03485) withdeepPOST /v1/readreads one public page as text. A read costs at most 10,250 micro-dollars ($0.01025)
curl https://api.usek.ai/v1/audio/speech \
-H "Authorization: Bearer kai_sk_…" \
-H "Content-Type: application/json" \
-d '{"input": "Hello!", "voice": "nova"}' \
--output aloha.mp3
Quickstarts
The OpenAI SDKs work unchanged. So does any tool that lets you set a base URL. Use kai for routed answers, or kai-coding to pin the coding lane.
Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.usek.ai/v1",
api_key="kai_sk_...",
)
reply = client.chat.completions.create(
model="kai",
messages=[{"role": "user", "content": "Hello!"}],
)
print(reply.choices[0].message.content)
JavaScript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.usek.ai/v1",
apiKey: "kai_sk_...",
});
const reply = await client.chat.completions.create({
model: "kai",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(reply.choices[0].message.content);
aider
export OPENAI_API_BASE=https://api.usek.ai/v1 export OPENAI_API_KEY=kai_sk_... aider --model openai/kai-coding # or in .aider.conf.yml openai-api-base: https://api.usek.ai/v1 openai-api-key: kai_sk_... model: openai/kai-coding
Continue
# ~/.continue/config.yaml
models:
- name: Kai
provider: openai
model: kai-coding
apiBase: https://api.usek.ai/v1
apiKey: kai_sk_...
Reply costs
Every reply says what it cost and what credit remains, in micro-dollars. One dollar is 1,000,000. Two headers and a kai object in the body carry the numbers. A streamed reply carries them in the final chunk.
When your credit runs out, the API returns HTTP 429 with insufficient_quota, the shape tools already understand. Top up with Lightning from $1 and get 15% bonus credit.
x-kai-cost-micro·x-kai-balance-microon every reply- Real token counts in
usage x-ratelimitheaders on every response
"kai": {
"tier": "fast",
"cost_micro": 1840,
"balance_micro": 4998160,
"searched": false
}
Try it
Paste a key, pick a model, write a prompt. The reply streams straight from the API to this page.
The API allows any origin, so a plain fetch works from any web page. Your key stays in this browser. This page sends it only to api.usek.ai.
Privacy
The API is the same transient pipeline the apps use. K.ai never logs prompts or answers, and never stores them past delivery. Accounting keeps lane, token counts, latency, and cost. It never keeps content.
Accounts are pseudonymous. No email, no phone number, no card. K.ai stores only a hash of each key. The secret exists once, on your screen. A revoked key stops working on the next request.
- No prompt or answer logging
- No personal data attached to keys or credits
- Revoke any key instantly from web chat