SDKs, API and integrations
OpenSmartRoute is a Python library with zero dependencies, a TypeScript client typed to every endpoint, a CLI, and a hosted API that speaks the OpenAI and Anthropic dialects your clients already use. Whatever you pick, every answer carries the decision - target, confidence, alternatives, cost and a trace id.
pip install "opensmartroute[yaml,server]"npm install @opensmartroute/sdkcurl -LsSf https://opensmartroute.ai/install.sh | shWindows: powershell -ExecutionPolicy ByPass -c "irm https://opensmartroute.ai/install.ps1 | iex"
Four ways in
The router as a library: targets.yaml, rules.yaml, route(), the trace. Zero runtime dependencies; optional extras for YAML, the server and OpenTelemetry.
pip install "opensmartroute[yaml,server]"Python SDK guideTyped route, estimate and feedback calls, the /v1 surface with streaming and every platform endpoint through osr.rest. Node, Deno, Bun, edge and browsers.
npm install @opensmartroute/sdkTypeScript SDK guideosr route, audit, eval, trace, events, serve and mcp from one binary. Sign in once with osr login and the commands read from the platform you chose.
curl -LsSf https://opensmartroute.ai/install.sh | shCommand referencePoint your OpenAI or Anthropic SDK at the platform's base URL. model="auto" routes; a list of models scores only those with fallbacks; stream=true works.
OPENAI_BASE_URL=<platform>/v1REST API referenceLibrary, sidecar or hosted API
Embed the SDK in a Python service, call it from TypeScript, run the container beside your app, or use this platform. The OpenAI-compatible and Anthropic-compatible endpoints (chat, Responses, Messages, embeddings, moderations, audio, images) mean existing clients switch by changing one base URL.
pip install "opensmartroute[yaml]"
from opensmartroute import (
Objective, RequestConstraints, RouteRequest,
Router, load_rules, load_targets,
)
from opensmartroute.strategies import (
default_strategies,
)
router = Router(
load_targets("targets.yaml"),
strategies=[
load_rules("rules.yaml"),
*default_strategies(),
],
)
req = RouteRequest(
"Prove that sqrt(2) is irrational.",
constraints=RequestConstraints(
max_cost_per_1k=0.02,
),
objective=Objective(quality=1.0, cost=0.4),
)
d = router.route(req, plan=True)
print(d.target.id, f"{d.confidence:.2f}")
# per-strategy scores and rationales
print(d.trace.explain())
# who was filtered out, and why
print(d.trace.policy_rejections)Zero runtime dependencies. plan=True returns the ranked runners-up and every policy rejection with the winner.
Integrations
The router imports what you have - MCP servers, A2A agents, skills, tools - as targets, and slots into the frameworks you build with as a node, a condition or an executor. Nothing has to be rewritten to be routed.
from opensmartroute.adapters import connect_mcp_http
http, remote = connect_mcp_http(
"https://tools.example.com/mcp",
api_key="...", resources=True, prompts=True,
)
# every tool, resource and prompt is now a targetThe hosted API needs no SDK: one curl and the decision is back. The packages are there when you want to embed the router or type the calls.
Free plan, no card. Fifteen thousand decisions a month with the full trace.