SDKsSDKs
SDKs
Call nRouter from Python, TypeScript, Rust, Go, Java, Kotlin, Android, Dart, Swift, R, PHP, Ruby, or plain cURL.
Last updated
nRouter provides official published SDKs, source/preview packages, and seamless drop-in integration with standard OpenAI and Anthropic client libraries.
Official & Supported SDKs
| Language | Registry & Package | Installation | Examples & Guides |
|---|---|---|---|
| Python | PyPI nrouter-sdk | pip install nrouter-sdk | Guide → · Demos |
| TypeScript / Node | npm @nrouter_ai/sdk | npm install @nrouter_ai/sdk | Guide → · Demos |
Source & Preview SDKs
Full source and idiomatic clients are maintained in our public SDK repository:
| Language | Status / Ecosystem | Installation / Dependency | Source & Demos |
|---|---|---|---|
| Go | Preview | go get github.com/nRouterAI/nrouter-sdk/sdks/go/v3@v3.0.0 | Guide → · Demos |
| Rust | Preview | cargo add nrouter | Source & Demos |
| Java | Preview | implementation 'ai.nrouter:nrouter-sdk:2.2.1' | Guide → · Source |
| Kotlin | Preview | implementation 'ai.nrouter:nrouter-sdk-kotlin:2.2.1' | Source |
| Android | Preview | implementation 'ai.nrouter:nrouter-sdk-android:2.1.0' | Source |
| Swift | Preview | .package(url: "https://github.com/nRouterGateway/nrouter-sdk.git", from: "2.2.1") | Guide → · Source |
| Dart / Flutter | Preview | dart pub add nrouter | Source |
| R | Preview | install.packages("nrouter", repos = c(nrouterai = "https://nrouterai.r-universe.dev", CRAN = "https://cloud.r-project.org")) | Source |
Community & Universal OpenAI Clients
| Language | Client / Package | Guide |
|---|---|---|
| Python (OpenAI Drop-in) | pip install openai | Setup → |
| PHP | composer require openai-php/client | Setup → |
| Ruby | gem install ruby-openai | Setup → |
| cURL | Built-in | Setup → |
Authentication Invariant
Every SDK and request requires your virtual API key set in your environment:
export NROUTER_API_KEY="sk-nrouter-your-key-here"What You Get Built-In
- Automated Cost Tracking — exact USD costs parsed and surfaced on the response object (
client.last_response.cost/x-nr-request-cost), paired withx-nr-cost-status. On an unpriced call the cost header is absent rather than0. - Server-Side Guardrails — PII redaction, prompt injection blocking, and content moderation configured in your dashboard.
- Smart Router & Fallbacks — alias routing across multiple upstream providers with automatic circuit-breaking.
- Semantic & Exact Caching — zero latency cache hits for duplicate prompts.
- Prompt Templating — centralized, versioned prompt templates.
Was this page helpful?