API
API Quickstart
The kral API is OpenAI-compatible: existing SDKs keep working, you only swap the base URL and the key. Through the same interface you reach every model — Claude, GPT, Gemini, Grok, Mistral, Llama.
1. Create an API key
In the dashboard under API keys, click Create API key. One key per project, with its own spend limits, expiry date, model allowlist and rate limit. Keys start with sk-kral-. The plain-text key is shown once at creation; afterwards only the prefix.
2. Set the base URL
https://api.kral.ai/v1
Authentication is a Bearer token in the Authorization header.
3. First request
cURL
curl https://api.kral.ai/v1/chat/completions \
-H "Authorization: Bearer $KRAL_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"messages": [
{"role": "user", "content": "Hello"}
]
}'
Python
from openai import OpenAI
client = OpenAI(
base_url="https://api.kral.ai/v1",
api_key="sk-kral-...",
)
resp = client.chat.completions.create(
model="claude-sonnet-4-6",
messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.kral.ai/v1",
apiKey: process.env.KRAL_API_KEY,
});
const resp = await client.chat.completions.create({
model: "gpt-5",
messages: [{ role: "user", content: "Hello" }],
});
console.log(resp.choices[0].message.content);
Models
Pass the model name in the model field. Get the full list with GET /v1/models. More under Endpoints.
Next
- Endpoints — every path at a glance.
- Streaming — tokens as they arrive.
- Tools and structured outputs — function calling, JSON schema.
- Errors and migration — status codes plus drop-in from OpenAI.