RouterHubDocs Back to RouterHub Get an API key

RouterHub API documentation

One API key for 44 models, on OpenAI- and Anthropic-compatible endpoints. Pick your tool for step-by-step setup, or call the API directly.

Set up your tool

Use the API directly

You need an account, credits and an API key. Save the key as ROUTERHUB_API_KEY.

Base URLhttps://routerhub.si/v1

Responses (/v1/responses) · cURL

curl --connect-timeout 30 --max-time 600 https://routerhub.si/v1/responses \
  -H "Authorization: Bearer $ROUTERHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-6.1-sol","input":"Reply with OK.","max_output_tokens":256}'

Responses (/v1/responses) · Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ROUTERHUB_API_KEY"],
    base_url="https://routerhub.si/v1",
    timeout=600.0,
    max_retries=0,
)
response = client.responses.create(
    model="gpt-6.1-sol",
    input="Reply with OK.",
    max_output_tokens=256,
)
print(response.output_text)

Messages (/v1/messages) · cURL

curl --connect-timeout 30 --max-time 600 https://routerhub.si/v1/messages \
  -H "x-api-key: $ROUTERHUB_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{"model":"claude-sonnet-5-5","max_tokens":256,"messages":[{"role":"user","content":"Reply with OK."}]}'

Messages (/v1/messages) · Python

import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ["ROUTERHUB_API_KEY"],
    base_url="https://routerhub.si",
    timeout=600.0,
    max_retries=0,
)
response = client.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=256,
    messages=[{"role": "user", "content": "Reply with OK."}],
)
print(response.content)

Chat Completions (/v1/chat/completions) · cURL

curl --connect-timeout 30 --max-time 600 https://routerhub.si/v1/chat/completions \
  -H "Authorization: Bearer $ROUTERHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"deepseek-v4-pro","messages":[{"role":"user","content":"Reply with OK."}],"max_tokens":256}'

Chat Completions (/v1/chat/completions) · Python

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["ROUTERHUB_API_KEY"],
    base_url="https://routerhub.si/v1",
    timeout=600.0,
    max_retries=0,
)
response = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[{"role": "user", "content": "Reply with OK."}],
    max_tokens=256,
)
print(response.choices[0].message.content)

Each model uses one of these three APIs; its model page says which. The examples use GPT-6.1 Sol, Claude Sonnet 5.5 and DeepSeek V4 Pro. PowerShell versions are in the API request guide.

Keys and billing

API keys

Create keys in API keys and copy the full value when it is shown. Your password is not an API key. Keep filled-in config files out of source control.

Credits

Each request reserves an estimated cost before it starts. We bill reported usage at RouterHub's published rates and release the estimate. If a model returns more tokens than requested, we deliver the response and bill the reported usage. In-flight usage can leave a wallet negative or take a key over its spend limit. Those checks still apply to new requests. See your charges in Usage.

Balance monitoring for resellers

Use the same RouterHub API key your backend uses for inference. This free, read-only call reports the wallet that owns the key, not your customers’ balances.

Check balance
curl -fsS --max-time 10 https://routerhub.si/v1/balance -H "Authorization: Bearer $ROUTERHUB_API_KEY"
Example response
{"currency":"USD","available_cents":1367}

available_cents is the USD balance you can spend now, after pending charges and active holds. It is rounded down to whole cents, with a minimum of zero. It is not the remaining allowance on an individual API key.

Poll once a minute from your backend. For a low-balance alert, notify your team when available_cents < 1000 ($10). Alert separately on repeated lookup failures. The endpoint allows 30 checks per minute per account across all keys, separate from inference. On HTTP 429, wait for Retry-After.

Keep your API key and this endpoint behind your backend. Do not forward /v1/balance through your customer-facing proxy. This call takes no parameters and cannot add credits or change your account.

For agents and scripts: quickstart.md, openapi.json, llms.txt.