Quickstart

Create an API key and run the example with model free. Compatible chat models accept OpenAI Chat Completions or Anthropic Messages with the same key. Other modalities use the endpoint listed on their model page.

1. Create an API key

Sign in and create a key with your email using a one-time code. KeepRouter does not use passwords. New accounts can call the free model without a top-up. The key starts with sk-kr-, is scoped to free by default in this flow, and is shown once.

2. Call a compatible chat model like OpenAI

Point your client's base_url at https://keeprouter.com/v1:

curl https://keeprouter.com/v1/chat/completions \
  -H "Authorization: Bearer sk-kr-..." \
  -H "Content-Type: application/json" \
  -d '{"model":"free","messages":[{"role":"user","content":"Hello!"}]}'

Python with the official OpenAI SDK:

from openai import OpenAI
client = OpenAI(base_url="https://keeprouter.com/v1", api_key="sk-kr-...")
r = client.chat.completions.create(
    model="free",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(r.choices[0].message.content)

3. Or call the compatible chat model like Anthropic

The same key works on the Anthropic Messages API used by Claude Code and the Anthropic SDK:

curl https://keeprouter.com/v1/messages \
  -H "x-api-key: sk-kr-..." \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"free","max_tokens":256,"messages":[{"role":"user","content":"Hello!"}]}'

These first-call examples deliberately use the production trial-eligible free model, so a new account can run them before topping up.

4. Move from free to a paid model

  1. Choose a model on Models & pricing and confirm its current price and endpoint.
  2. Use that model page's Use model button to create a new key scoped to the selected model. Save the new key when it is shown.
  3. Complete a valid top-up, then return to the selected model's request example and use the new key with that model ID.

Topping up unlocks paid models for your account; it does not change the original key's free scope. If a request returns model_not_allowed, use a key whose model allowlist includes the selected ID. Do not remove key limits merely to bypass the error.

5. Call Gemini with the same Chat Completions client

Use your KeepRouter key and select an exact Gemini model ID, such as gemini-3.8-flash. The base URL, Bearer authentication, messages and response shape stay the same:

r = client.chat.completions.create(
    model="gemini-3.8-flash",
    messages=[{"role": "user", "content": "Reply with a short greeting."}],
    reasoning_effort="low",
    max_tokens=1024,
)
print(r.choices[0].message.content)
print(r.usage)

The key must allow this paid model and the account must be topped up. Use the public ID without a google/ prefix. You do not supply a Google key, Cloud project or region to KeepRouter. The gateway handles upstream authentication and model mapping.

Gemini chat requests use POST /v1/chat/completions; set stream=True for streaming. The current Google Cloud chat route does not expose /v1/responses, /v1/messages, Google-native generateContent or the Live WebSocket API. Other routes may differ; use the exact model's endpoint guidance. Tool and structured-output parameters are model-specific. See the Gemini API guide for examples and verified scope.

Choose the exact model operation

GPT-6.1 Sol function calling uses POST /v1/responses; its Chat Completions interface does not support tools. Use the OpenAI SDK's client.responses.create, with model-specific reasoning settings and an output budget. GPT model and tool guide.

Claude Sonnet and Opus 5.5 can start with native POST /v1/messages. Preserve complete thinking and tool blocks and remove unsupported non-default sampling parameters. Claude 5.5 migration.

Reviewed models expose api_contract in GET /api/public/model/{id}: preferred operation, configured operations, reasoning guidance, price policy and source date. These are capability notes, not proof of every production workflow. Paid models need sufficient prepaid credit and a key that permits the selected ID.

Next

  • Models & pricing: current price, modality, and endpoint guidance for each model.
  • API errors: documented error codes, retry behavior, and corrective actions.
  • API reference: the full OpenAPI reference.

Billing in one line

Paid usage is deducted from prepaid USD credit at the published model rate. There is no recurring subscription. Card checkout shows the processing fee and applicable tax before payment. Per-key spend limits are optional.