Send your first request
1. Top up and create a key
Add a Rupiah balance, then create an API key on the API keys page. The key is shown only once.
2. Set the base URL and key
Store the base URL and key as environment variables. ROUTER_BASE_URL already includes /v1. Never put the key in browser code.
export ROUTER_BASE_URL="https://api.koneksialabs.ai.id/v1"
export ROUTER_API_KEY="sk-kl-..." # dari halaman Kunci API / from the API keys page3. Send a message
Use the official OpenAI SDK; only the base URL and key change. Replace MODEL_ID with an ID from the catalog.
curl "$ROUTER_BASE_URL/chat/completions" \
-H "Authorization: Bearer $ROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_ID","messages":[{"role":"user","content":"Halo!"}]}'Sample response
{
"id": "gen-0000-contoh",
"object": "chat.completion",
"model": "MODEL_ID",
"choices": [{ "index": 0, "message": { "role": "assistant", "content": "Halo! Ada yang bisa saya bantu?" }, "finish_reason": "stop" }],
"usage": {
"prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21,
"cost": 0.000235, "cost_micro_idr": "235"
}
}Streaming
The last chunk (empty choices) carries usage. The final cost comes from server metering; look it up via /v1/generation if the connection drops.
curl -N "$ROUTER_BASE_URL/chat/completions" \
-H "Authorization: Bearer $ROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_ID","stream":true,"messages":[{"role":"user","content":"Halo!"}]}'4. Check the cost
Every response carries usage.cost (IDR) and usage.cost_micro_idr (exact value). See per-request detail and cache discounts in Activity.
Errors to handle
| HTTP | Code | Meaning |
|---|---|---|
| 402 | insufficient_balance | Balance too low. Top up to continue. |
| 402 | key_monthly_budget_exceeded | The key's monthly budget is used up; it resets on the 1st (WIB). |
| 402 | key_credit_limit_exceeded | The key's lifetime credit limit is reached. Raise the limit or use another key. |
| 429 | rate_limited | Too many requests. Wait as the Retry-After header says. |
| 429 | free_daily_limit | The free model's daily quota is used up. |
| 404 | no_eligible_endpoint | No provider meets the policy (PDP, region or provider filters). |
| 502 | all_providers_failed | Every provider failed. The request is not charged. |
| 401 | invalid_api_key | The key is missing, wrong or revoked. |