We're shipping official SDKs for Python and Node.js — purpose-built for RoutePlex with zero dependencies, typed errors, and every API feature exposed.
Why SDKs?
Until now, using RoutePlex meant either writing raw HTTP calls or using the OpenAI SDK with a base URL swap. Both work, but neither gives you the full RoutePlex experience — auto-routing, prompt enhancement, cost estimation, and typed error handling all require extra boilerplate.
The new SDKs fix that. One install, one import, one line of code:
from routeplex import RoutePlex
client = RoutePlex(api_key="rp_live_YOUR_KEY")
response = client.chat("Explain quantum computing")
print(response.output)
import { RoutePlex } from "@routeplex/node";
const client = new RoutePlex({ apiKey: "rp_live_YOUR_KEY" });
const response = await client.chat("Explain quantum computing");
console.log(response.output);
Three Routing Modes
Both SDKs support all three ways to route your requests:
1. Auto-Routing (Default)
Omit both model and strategy — RoutePlex analyzes your prompt and picks the best model. A simple question gets a fast, cheap model. A complex reasoning task gets a capable one.
response = client.chat("What is Python?") # → fast, cheap model
response = client.chat("Prove the Riemann hypothesis") # → powerful model
2. Strategy Routing
Set a strategy to override auto-routing with a fixed priority.
response = client.chat("Write a haiku", strategy="speed") # fastest
response = client.chat("Analyze this data", strategy="quality") # most capable
response = client.chat("Summarize this", strategy="cost") # cheapest
3. Manual Mode
Pick a specific model. RoutePlex handles fallbacks if it's unavailable.
response = client.chat("Explain recursion", model="gpt-4o-mini")
Zero Dependencies
Both SDKs use only their language's standard library:
- Python:
urllib+json(stdlib). Works on Python 3.8+. - Node.js:
fetch(built-in since Node 18). Noaxios, nonode-fetch.
This means zero supply chain risk, instant installs, and no version conflicts.
Typed Errors
Both SDKs include a complete error hierarchy that maps to RoutePlex API error codes:
from routeplex import AuthenticationError, RateLimitError, ValidationError
try:
response = client.chat("Hello!")
except AuthenticationError:
print("Bad API key")
except RateLimitError:
print("Slow down")
import { AuthenticationError, RateLimitError } from "@routeplex/node";
try {
const res = await client.chat("Hello!");
} catch (err) {
if (err instanceof RateLimitError) console.log("Slow down");
}
Error classes: RoutePlexError, AuthenticationError, RateLimitError, ValidationError, ProviderError, ContentPolicyError.
Free Endpoints
Cost estimation, prompt enhancement, and model listing are free and don't require an API key:
# Estimate cost before sending
estimate = client.estimate("Write a blog post about AI")
print(f"Estimated cost: ${estimate.estimated_cost_usd:.6f}")
# Enhance a prompt
result = client.enhance("tell me about kubernetes")
print(result.enhanced_prompt)
# List all models
models = client.list_models()
for m in models:
print(f"{m.id} ({m.provider})")
Test Mode
Building a CI pipeline or just developing locally? Use test_mode to force default-tier models only — no premium model charges, predictable costs:
response = client.chat("Write a unit test", test_mode=True)
const response = await client.chat("Write a unit test", { testMode: true });
Full TypeScript Support
The Node.js SDK ships with complete .d.ts type definitions — ChatResponse, Usage, EstimateResponse, EnhanceResponse, Model, and all error classes are fully typed.
Install
pip install routeplex # Python — PyPI
npm install @routeplex/node # Node.js — npm
