Docs

From zero to first request in about five minutes.

Quickstart

Create a LokaRouter account and top up your prepaid balance. Then generate an API key from the dashboard.

Use that key with any OpenAI SDK. The only two things you change are the base URL and the API key.

from openai import OpenAI client = OpenAI(    base_url="https://api.lokarouter.id/v1",    api_key="sk-lkr-your-key",) response = client.chat.completions.create(    model="openai/gpt-5-mini",    messages=[{"role": "user", "content": "Hello, LokaRouter"}],)print(response.choices[0].message.content)

Demo gateway

API keys you create in the dashboard work against the demo gateway on this site. It speaks the OpenAI wire format, validates your key, applies a limit of 60 requests per minute per key, and tracks last-used time.

When no upstream provider is configured, assistant replies are generated by the demo gateway itself and marked with lokarouter.demo = true in the response. With an upstream key configured (UPSTREAM_API_KEY), requests are forwarded for real and usage is recorded from the provider's response.

Every request is logged in the dashboard with model, tokens, cost, latency, and which provider served it. The dashboard also includes a chat playground, per-key budget caps, guardrails (model/tool allow-lists), and monthly workspace budgets.

  • POST /api/v1/chat/completions — OpenAI-compatible chat completions
  • GET /api/v1/models — list routable models
  • Pass "stream": true to receive Server-Sent Events chunks
curl https://api.lokarouter.id/v1/chat/completions \  -H "Authorization: Bearer sk-lkr-your-key" \  -H "Content-Type: application/json" \  -d '{    "model": "openai/gpt-5-mini",    "messages": [{ "role": "user", "content": "Hello" }]  }'

In production the endpoint moves to https://api.lokarouter.id/v1.

OpenAI compatibility

LokaRouter implements the OpenAI REST surface. These endpoints are supported today:

Point any official SDK or community client at https://api.lokarouter.id/v1 and it works. Streaming, function calling, and JSON mode are passed through to the underlying providers. See the API reference for full request and response shapes, header metadata, and the error table.

  • POST /chat/completions
  • POST /completions
  • POST /embeddings
  • GET /models
  • GET /models/{id}

The Files API (beta) is also available — see the API reference.

Choosing models

Model identifiers use the author/model convention, for example openai/gpt-5.2, anthropic/claude-opus-5, or deepseek/deepseek-v4. The catalog tracks current-generation releases only, with new launches added as they ship.

Switching models is a one-string change — the request shape stays identical. On the models page you can filter by provider, modality, use-case category, and tool-calling support, or sort by price, latency, throughput, and newest releases.

Prefer not to pick? Set model to lokarouter/auto and the gateway routes each request to the best fit automatically.

Fallback routing

Every model on LokaRouter is hosted by multiple infrastructure providers. When the preferred provider is unavailable or rate-limited, the request is rerouted automatically.

You can tune the trade-off with the provider preferences object: prioritize price, throughput, or uptime. If you need to pin a specific provider, pass its slug and set allow_fallbacks to false.

response = client.chat.completions.create(  model="openai/gpt-5.2",  messages=[{"role": "user", "content": "Hello"}],  extra_body={    "provider": {      "sort": "throughput",   # price | throughput | uptime      "allow_fallbacks": True    }  },)

Provider preferences are optional — defaults optimize for uptime.

Tool integrations

Any tool that lets you set an OpenAI-compatible base URL works with LokaRouter. Set the fields as below and pick a model id.

  • Cursor: Settings > Models > OpenAI API Key, override the base URL.
  • Continue.dev: config.yaml > provider
  • Replit: set OPENAI_BASE_URL in Secrets.
  • Kilo Code: provider settings > Base URL.
  • MCP Server: pass the base URL and key in the server's model config.