API Docs: Quickstart and SDKs
Use TrustedRouter with any OpenAI-compatible SDK after one base_url change. Get quickstarts, Python and TypeScript SDKs, privacy controls, and API reference.
Quickstart: one base_url change.
- ✓ OpenAI-compatible — point any OpenAI/Anthropic SDK at TrustedRouter
- ✓ Read your key from
TRUSTEDROUTER_API_KEY - ✓ Use
trustedrouter/autofor provider failover - ✓ Use
trustedrouter/euwith the EU regional API for Europe-focused routing - ✓ Use
trustedrouter/socratesfor the rolling advisor preset, ortrustedrouter/socrates-1.1for the pinned current version - ✓ Use
trustedrouter/iris-2.0,trustedrouter/prometheus-2.0, ortrustedrouter/zeus-1.0for versioned Synth presets - ✓ Use
trustedrouter/openpatcher-s2for Kimi K3 plus GLM 5.2 synthesis - ✓ Use
trustedrouter/openpatcher-g2for a Kimi K3 worker with parallel Gemma 4 and Prometheus 2.0 advisors - ✓ Use
trustedrouter/plato-pro-2.0for GLM 5.2 advised by Prometheus 2.0 - ✓ Use
trustedrouter/iris-code-1.0,trustedrouter/prometheus-code-1.0, ortrustedrouter/zeus-code-1.0for code-tuned Synth presets - ✓ Add
provider.min_privacy = "zdr"for a hard zero-retention floor - ✓ Add
provider.min_privacy = "confidential"to require confidential compute + provider E2EE
const client = new OpenAI({
apiKey: process.env.TRUSTEDROUTER_API_KEY,
baseURL: "https://api.trustedrouter.com/v1"
})
const r = await client.chat.completions.create({
model: "trustedrouter/auto",
messages: [{ role: "user", content: "Hello" }]
})
Fail-closed privacy filters
Require zero retention
{
"model": "your/model",
"provider": {"min_privacy": "zdr"}
}
This is a hard minimum. If no endpoint for the selected model and provider filters has a tracked ZDR guarantee, the request fails before inference.
Require confidential + E2EE
{
"model": "your/model",
"provider": {"min_privacy": "confidential"}
}
This stronger hard minimum requires both provider-side confidential compute and end-to-end encryption. e2e and e2ee are accepted value aliases. Unsupported model/provider combinations fail closed.
trustedrouter/e2e and trustedrouter/confidential select the same confidential + E2EE pool. provider.data_collection = "deny" remains an OpenRouter-compatible routing preference; use min_privacy when the privacy floor must never be relaxed.
Guides
60-second quickstart
Make one request, inspect the catalog, and verify the live prompt path.
Open →Agent setup
Point Codex, Claude Code, Hermes, Cursor, or any OpenAI-compatible client at TrustedRouter.
Open →MCP server
Let agents inspect live models, pricing, provider posture, credits, docs, and quick test messages.
Open →Agent skill
Help Codex, Claude Code, Hermes, and other agents choose models using speed, cost, AI IQ, privacy, context length, and prompt-cache fit.
Open →Migrate from OpenRouter
Swap one base_url and keep your existing calls working.
Open →Request tagging
Allocate cost and usage with AWS style tags while keeping metadata out of model prompts.
Open →Provider routing & pinning
Pin, prefer, or exclude providers per request — filters that fail closed, never silently relax.
Open →Signed inference receipts
Opt into an offline-verifiable proof of every response — exact bytes, routed model, and a hardware-attested signing key.
Open →Client reliability telemetry
See the content-free fields TrustedRouter SDKs report, the retention policy, and every opt-out.
Open →Prompt caching
Reuse stable prompt prefixes, inspect cache hits, and keep the router itself free of prompt storage.
Open →Batch API
Submit OpenRouter-compatible inline batches and poll encrypted results through the attested gateway.
Open →Responses web search
Search the live web inside the attested gateway and return source citations through the OpenAI Responses API.
Open →Video generation
Generate video with Seedance, Veo, Sora, Runway, Kling, Wan, Vidu, PixVerse, LTX, Gemini Omni, and Hailuo 3 through asynchronous jobs with exact quoted billing.
Open →Evals
Run eval suites across providers through one API.
Open →Provider conformance
Check an OpenAI-compatible provider endpoint against the production gateway contract before applying.
Open →Synth
Run Iris, Prometheus, Zeus, and code-tuned Synth presets inside the attested gateway.
Open →Socrates
Run the advisor preset, or configure the generic advisor primitive directly.
Open →User-provided models
List your own endpoint — a machine, an agent, or yourself typing — at a price you set, and keep 70% in credits.
Open →Custom models
Publish a base model with a hidden prompt and earn 70% of the markup you set.
Open →x402 stablecoin funding
Let agents add prepaid credits automatically without changing the prompt path.
Open →EU routing
Use the Europe West attested gateway and the EU-focused model alias.
Open →Sign in with TrustedRouter
Let your users bring their own account and credits.
Open →vs OpenRouter
How TrustedRouter compares to closed routers.
Open →Security & attestation
How the attested gateway and trust record work.
Open →SDKs
API reference
OpenAI-compatible endpoints
Base URL https://api.trustedrouter.com/v1. Authenticate inference calls with a Bearer sk-tr-… key.
POST /v1/chat/completionsPOST /v1/responsesPOST /v1/embeddingsPOST /v1/videosGET /v1/modelspublic, no API key
Agent-readable docs
Point your coding agent at the machine-readable docs for the full surface:
- /docs/llms.txt — concise index
- /docs/llms-full.txt — full context
- /docs/mcp — MCP tools for live catalog, credits, docs, and test-chat lookups
- Agent skill — model advisor for Codex, Claude Code, Hermes, and other agents
- trustedrouter-model-advisor — source repo and raw playbook for agent installation
- Socrates — advisor orchestration guide
- /docs/synth — Synth model panel guide
- /docs/user-models — post your own endpoint as a priced model; verification, dispatch, payouts
- /docs/custom-models — publish a hidden-prompt model, set markup, and collect creator earnings
- /docs/prompt-caching — provider cache behavior, usage fields, billing, and routing tradeoffs
- /docs/batch — inline Batch API quickstart, response contract, limits, and encrypted retention
- /docs/web-search — Responses API web search, citations, controls, and privacy boundaries
- /docs/provider-conformance — public provider contract checks, result meanings, and production parity
- /docs/video — asynchronous video generation, models, billing, and retention boundaries
- GitHub — source + issues
- OpenAI-compatible API — SDK migration surface
- Latency benchmarks — measured provider data
Spend-window rate limits
A key with a hard daily, weekly, or monthly spend limit gets the governing window on every response. Values are integer microdollars, the same unit used by the key-limit API. Keys without a hard spend window do not get fabricated rate-limit headers.
Response headers
RateLimit-Limit— configured spend limit for the governing windowRateLimit-Remaining— settled spend headroom observed by this requestRateLimit-Reset— whole seconds until the fixed UTC window resetsRetry-After— also present on429; the reset delay rounded up, with a minimum of one second
Window checks are approximate by design: in-flight holds are not included. Use RateLimit-Remaining to slow down before rejection, and treat Retry-After as authoritative after a 429.
import math
import time
import httpx
jobs = [{"model": "trustedrouter/auto", "messages": [...]}]
next_budget_microdollars = 50_000
with httpx.Client() as client:
while jobs:
response = client.post(API_URL, headers=AUTH, json=jobs[0])
reset = max(1, math.ceil(float(
response.headers.get("RateLimit-Reset", "1")
)))
if response.status_code == 429:
time.sleep(max(1, int(response.headers["Retry-After"])))
continue
response.raise_for_status()
jobs.pop(0)
remaining = int(response.headers.get(
"RateLimit-Remaining", next_budget_microdollars
))
if jobs and remaining < next_budget_microdollars:
time.sleep(reset)