API Documentation
Const Router is a high-performance universal AI gateway providing drop-in access to 14 frontier models through standard OpenAI and Anthropic API specifications.
Quickstart
Calling models through Const Router requires only two changes to standard client code: point the base URL to https://router.const.web.id/v1 and supply your Const API key.
from openai import OpenAI
client = OpenAI(
base_url="https://router.const.web.id/v1",
api_key="const_live_YOUR_KEY",
)
response = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=[{"role": "user", "content": "Explain Virtual Combos in two sentences."}],
)
print(response.choices[0].message.content)Authentication
Every inference request requires an active API key passed in the Authorization header with the Bearer prefix, or via x-api-key.
# Header syntax
Authorization: Bearer const_live_xxxxxxxxxxxxxxxxxxxxxxxx
Keys are revealed once upon creation. Invalid, disabled, or daily-capped keys are rejected with HTTP 401/403 before executing upstream model calls.
Models & Free Allowance
Const Router operates two billing tiers: Free Tier and Paid Wholesale.
7,000,000
Tokens per 7-day cycle. Applies automatically to models marked :free.
Per-Token
Metered down to fractions of a cent with up to 91% discount against official provider rates. No subscriptions.
Eligible Free Tier IDs:
deepseek-v4.1-flash:freeqwen-3.8-omni-flash:freeglm-5.3-flash:freeSDKs & Agent Setup
Use Const Router with official developer CLIs and autonomous agent frameworks:
Claude Code CLI (Anthropic Spec)
export ANTHROPIC_BASE_URL="https://router.const.web.id" export ANTHROPIC_API_KEY="const_live_YOUR_KEY" claude
Cursor / Cline / Roo Code / OpenCode
Set Provider to OpenAI Compatible, Base URL to https://router.const.web.id/v1, and enter your Const API key.
Chat Completions
Standard endpoint: POST /v1/chat/completions. Supports streaming, function/tool calling, structured JSON output, vision inputs, and reasoning controls.
curl https://router.const.web.id/v1/chat/completions \
-H "Authorization: Bearer const_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash",
"messages": [
{"role": "system", "content": "You are a concise engineering assistant."},
{"role": "user", "content": "Compare quicksort vs mergesort cache locality."}
],
"temperature": 0.2,
"max_tokens": 1024
}'Reasoning Effort
For reasoning and thinking models (such as DeepSeek R1, GLM thinking, and OpenAI reasoning architectures), pass the reasoning_effort parameter to modulate internal thought token budgets before producing output.
| Level | Behavior | Recommended For |
|---|---|---|
| "low" | Minimal internal chain-of-thought tokens. Lowest latency. | Simple code edits, quick lookups, high-concurrency bots |
| "medium" | Balanced reasoning budget (default setting). | General debugging, unit test synthesis, refactoring |
| "high" | Extended internal exploration and self-correction cycles. | Complex algorithmic proofs, architecture planning, multi-file refactors |
| "max" | Maximal thinking depth up to context boundaries. | Mission-critical bug audits and difficult logic puzzles |
from openai import OpenAI
client = OpenAI(
base_url="https://router.const.web.id/v1",
api_key="const_live_YOUR_KEY",
)
# Pass reasoning_effort parameter directly
response = client.chat.completions.create(
model="deepseek-v4.1-flash",
messages=[{"role": "user", "content": "Design an idempotent distributed lock with redis."}],
reasoning_effort="high",
)
print(response.choices[0].message.content)Streaming (Server-Sent Events)
Enable SSE by setting stream: true. Stream frames are passed through directly from upstream without proxy buffering delays. The final terminal chunk delivers exact token telemetry:
data: {"choices": [{"delta": {"content": "..."}}]}
...
data: {"usage": {"prompt_tokens": 42, "completion_tokens": 128}}
data: [DONE]Tool Calling & JSON Mode
Const Router supports OpenAI standard function schemas via tools and tool_choice. For structured JSON outputs without tools, pass:
"response_format": { "type": "json_object" }Virtual Combos & Automatic Failover
Virtual Combos allow grouping multiple upstream models under a single slug (model: "combo/my-coding-stack"). When your primary model returns HTTP 429 (rate limited), 503 (out of capacity), or high latency, Const Router automatically fails over to the next candidate model in the chain before replying to the client.
Response Header Telemetry:
X-Const-Combo-Selected-Model identifies the actual model that generated the completion.
Available Endpoints
/v1/chat/completionsOpenAI-compatible chat, streaming, tool calls, and user combos.
/v1/modelsPublic models; authenticated requests also include your active combos.
/v1/audio/transcriptionsSpeech to text using Whisper. Charged per audio minute.
/v1/searchResearch or deep research. Charged per search request.
/v1/fetchAuthenticated extraction of public web pages.
/v1/transcriptAuthenticated caption extraction from a public YouTube video.
Errors & Retries
Standard HTTP error codes are preserved:
| Code | Meaning | Action |
|---|---|---|
| 400 | Malformed request or unsupported parameter | Check request JSON payload |
| 401 / 403 | Invalid, revoked, or model-restricted key | Generate active key in Dashboard → API Keys |
| 402 | Credit balance depleted or weekly free quota exceeded | Top up credit or switch to free model |
| 429 | Rate limit reached | Retry with exponential backoff or use Combos |
| 502 / 503 | Upstream provider outage | Router failover automatically engages |
Per-Token Metering & Ledger
Every settled request emits an X-Const-Cost header with the exact micro-cost in USD deducted from your balance. Failed upstream requests are never billed.