Account and keys
Use these endpoints to read your balance, inspect usage and manage API keys. Monetary amounts are in rupiah, with "currency": "IDR". Results are returned in a data object.
Key types
Section titled “Key types”- An API key calls models and spends your balance. It is what every other page uses.
- An admin key cannot call a model or spend anything. It can create and revoke API keys and read your organization’s reports, so your own systems can hand out keys. Someone with the API Key permission creates one in the console under Admin Key (
/keys/admin). In error messages it is called a provisioning key.
| Endpoint | API key | Admin key |
|---|---|---|
GET /v1/key, GET /v1/credits, GET /v1/generation |
yes | yes |
/v1/keys |
no | yes |
/v1/organization/usage/{surface}, /v1/organization/costs |
no | yes |
Using the wrong key type returns 403: provisioning_key_cannot_spend or inference_key_cannot_provision.
The key you are using
Section titled “The key you are using”curl https://api.indorouter.ai/v1/key \ -H "Authorization: Bearer $INDOROUTER_API_KEY"The data object contains:
- Key details:
id,label,prefixandkind. - Spending:
usagesince creation,usage_dailyandusage_monthly. - Spend limits:
limit,limit_reset,limit_remainingand details incaps. - Rate and concurrency limits in
rate_limit:requests_per_minute,tokens_per_minuteandconcurrent_requests. - Active requests:
rate_limit.requests_in_flight. - Allowed models (
allowed_models) and expiry time (expires_at).
Daily and monthly calculations use WIB.
Your balance
Section titled “Your balance”curl https://api.indorouter.ai/v1/credits \ -H "Authorization: Bearer $INDOROUTER_API_KEY"| Field | Meaning |
|---|---|
billing_mode |
postpaid for an account on a credit line, otherwise prepaid. |
balance |
What you can spend now. Empty on a postpaid account. |
held |
Reserved for requests that are still running. |
total_usage, usage_daily, usage_monthly |
What the account has spent. |
total_credits |
balance plus total_usage. Empty on a postpaid account. |
The cost of one request
Section titled “The cost of one request”Every response carries the request’s ID in the x-request-id header. Pass it to /v1/generation:
curl "https://api.indorouter.ai/v1/generation?id=req_..." \ -H "Authorization: Bearer $INDOROUTER_API_KEY"data has the model, status, total_cost (empty until the request has been charged), held, the tokens (tokens_prompt, tokens_completion, and every kind in tokens), provider_name, latency_ms, the key’s label and prefix, and attempts: each provider we tried, how it went and whether it was billed. You can only look up your own account’s requests.
Admin keys
Section titled “Admin keys”An admin key for your agent
Section titled “An admin key for your agent”An agent such as Claude Code or Codex can request an admin key through a console approval flow. The agent asks for a code, you approve it in the console, and the agent receives an admin key that can do only what you approved. The flow is OAuth’s device flow (RFC 8628).
curl https://api.indorouter.ai/v1/agent/connect \ -H "Content-Type: application/json" \ -d '{"name": "Claude Code", "scopes": ["keys", "usage"]}'No key is needed. scopes is one or more of keys, usage, publishing and billing. The answer has user_code and verification_uri for you, device_code for the agent (keep it secret), interval, and expires_in (15 minutes). The agent shows you the code and the link; you open it, sign in, check the code, choose the permissions and approve. Only someone with the API Key permission can approve, and only with permissions they have themselves.
The agent then asks for its key, no more often than every interval seconds:
curl https://api.indorouter.ai/v1/agent/token \ -H "Content-Type: application/json" \ -d '{"device_code": "irdc_..."}'Until you decide, the answer is 400 with the code authorization_pending, or slow_down when it asks too soon. Refused: access_denied. Expired or already used: expired_token. Once approved, the answer has api_key (shown this once), key_id, the scopes you approved (possibly fewer than were asked for), and account_id. The key is on the Admin Key page as “Agen: …” and can be revoked there. An admin key cannot make another admin key, so every agent is approved by a person.
Create an API key
Section titled “Create an API key”curl https://api.indorouter.ai/v1/keys \ -H "Authorization: Bearer $INDOROUTER_ADMIN_KEY" \ -H "Content-Type: application/json" \ -d '{"label": "customer-42", "monthly_cap_idr": 500000}'Every field is optional:
| Field | Meaning |
|---|---|
label |
A name, 1 to 255 bytes. |
allowed_models |
A list of model IDs the key may use. Leave it out to allow every model. |
requests_per_minute, tokens_per_minute |
Rate limits for this key. |
concurrent_requests |
How many of the key’s requests may run at once. null means no limit of its own. See Rate limits. |
daily_cap_idr, monthly_cap_idr |
Spending limits in rupiah. The daily one cannot be above the monthly one. |
expires_at |
When the key stops working, in RFC 3339. |
strict_output_cap |
true refuses a request the balance cannot fully cover. The default, false, lowers its output cap instead. How billing works explains the difference. |
Any other field is refused with invalid_key_request. The response, status 201, is the key object with the secret in key. This is the only time the secret is shown.
User approval
Section titled “User approval”Accepting service documents (terms, privacy notices and data processing agreements) or the Publisher Agreement requires user approval. An agent can request approval with its admin key:
curl https://api.indorouter.ai/v1/approvals \ -H "Authorization: Bearer $INDOROUTER_ADMIN_KEY" \ -H "Content-Type: application/json" \ -d '{"kind": "service_terms", "service": "tatareka/bpjs-ai-klaim", "note": "For the hospital SIMRS"}'kind is service_terms (with service, needing the keys scope) or publisher_agreement (with version, needing publishing). The answer has url, the console page where someone with that permission reads and approves it, and state: pending, then approved, denied, or expired after seven days. The agent gives you the url and reads GET /v1/approvals/{id} until the state changes. Asking again while it is pending answers the same request; asking for what is already agreed is 409 already_agreed. Pending requests also appear on the Overview page.
POST /v1/publisher/agreement opens a request like this and answers 202 with it.
List, read and revoke
Section titled “List, read and revoke”| Request | What it does |
|---|---|
GET /v1/keys |
Every key on the account, newest first, without secrets. |
GET /v1/keys/{id} |
One key. |
DELETE /v1/keys/{id} |
Revokes the key. This cannot be undone. |
Keys created through this API cannot be edited after creation. To change their settings, create a new key and revoke the old one.
Usage and cost reports
Section titled “Usage and cost reports”GET /v1/organization/usage/{surface} counts requests and tokens. surface is completions, embeddings, images, audio_speeches or audio_transcriptions. GET /v1/organization/costs adds up what was charged, across everything.
curl "https://api.indorouter.ai/v1/organization/costs?start_time=1790787600&bucket_width=1d&group_by=api_key_id" \ -H "Authorization: Bearer $INDOROUTER_ADMIN_KEY"| Parameter | Meaning |
|---|---|
start_time |
Required. Unix seconds. |
end_time |
Unix seconds. Defaults to now. |
bucket_width |
1d (the default) or 1h. Buckets follow WIB days and hours. |
group_by |
One of model or api_key_id for usage; line_item (the model, or service:<account>/<slug> for a service) or api_key_id for costs. |
models, api_key_ids |
Only these models or keys. |
limit |
Buckets per page: up to 31 daily or 168 hourly. |
page |
The next_page value from the previous response. |
The response is a page of buckets, each with start_time, end_time and results, plus has_more and next_page. A cost result has amount.value in rupiah. Video and services are not in the usage reports, but their cost is in /v1/organization/costs.
See Error codes for errors and how to handle them.