Browse documentation
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

LanguageRegistry & PackageInstallationExamples & Guides
PythonPyPI nrouter-sdkpip install nrouter-sdkGuide → · Demos
TypeScript / Nodenpm @nrouter_ai/sdknpm install @nrouter_ai/sdkGuide → · Demos

Source & Preview SDKs

Full source and idiomatic clients are maintained in our public SDK repository:

LanguageStatus / EcosystemInstallation / DependencySource & Demos
GoPreviewgo get github.com/nRouterAI/nrouter-sdk/sdks/go/v3@v3.0.0Guide → · Demos
RustPreviewcargo add nrouterSource & Demos
JavaPreviewimplementation 'ai.nrouter:nrouter-sdk:2.2.1'Guide → · Source
KotlinPreviewimplementation 'ai.nrouter:nrouter-sdk-kotlin:2.2.1'Source
AndroidPreviewimplementation 'ai.nrouter:nrouter-sdk-android:2.1.0'Source
SwiftPreview.package(url: "https://github.com/nRouterGateway/nrouter-sdk.git", from: "2.2.1")Guide → · Source
Dart / FlutterPreviewdart pub add nrouterSource
RPreviewinstall.packages("nrouter", repos = c(nrouterai = "https://nrouterai.r-universe.dev", CRAN = "https://cloud.r-project.org"))Source

Community & Universal OpenAI Clients

LanguageClient / PackageGuide
Python (OpenAI Drop-in)pip install openaiSetup →
PHPcomposer require openai-php/clientSetup →
Rubygem install ruby-openaiSetup →
cURLBuilt-inSetup →

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 with x-nr-cost-status. On an unpriced call the cost header is absent rather than 0.
  • 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?