Nadir Python SDK
Official Python client for the Nadir LLM router — intelligent model routing that cuts API costs 30-60%.
Installation
pip install nadir-sdk
Quick Start
from nadir import NadirClient
client = NadirClient(api_key="ndr_...")
# Chat completion — Nadir picks the optimal model
response = client.chat.completions.create(
messages=[{"role": "user", "content": "What is 2+2?"}],
)
print(response.choices[0].message.content)
# See which model was selected and why
print(response.nadir_metadata.tier) # "simple"
print(response.nadir_metadata.selected_model) # "gpt-4o-mini"
print(response.nadir_metadata.complexity_score) # 0.12
Streaming
stream = client.chat.completions.create(
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="", flush=True)
Model Recommendation (no LLM call)
rec = client.recommend("Explain quantum entanglement in detail")
print(rec) # {"recommended_model": "claude-sonnet-4-20250514", "complexity": ...}
Async
import asyncio
from nadir import AsyncNadirClient
async def main():
async with AsyncNadirClient(api_key="ndr_...") as client:
response = await client.chat.completions.create(
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
asyncio.run(main())
Advanced: Fallback & Routing Control
response = client.chat.completions.create(
messages=[{"role": "user", "content": "Complex analysis..."}],
route="fallback", # enable auto-fallback
fallback_models=["claude-sonnet-4-20250514", "gpt-4o"], # explicit fallback chain
layers={"routing": True, "optimize": True}, # per-request feature toggles
reasoning={"effort": "high"}, # reasoning token support
)
Environment Variables
| Variable | Description | Default |
|---|---|---|
NADIR_API_KEY |
API key (fallback if not passed to constructor) | — |
NADIR_BASE_URL |
API base URL | https://api.getnadir.dev |
OpenAI Drop-in Compatibility
Nadir's API is OpenAI-compatible. You can also use the OpenAI SDK directly:
from openai import OpenAI
client = OpenAI(
base_url="https://api.getnadir.dev/v1",
api_key="ndr_...",
)
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Hello"}],
)
The Nadir SDK adds typed access to routing metadata, recommendations, smart export, and clustering that the OpenAI SDK can't reach.
Metadata
Release files for nadir-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| nadir_sdk-0.1.0.tar.gz | 11.4 kB | Without provenance | Details for nadir_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| nadir_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for nadir_sdk-0.1.0-py3-none-any.whl |
Total release size: 23.1 kB
Release files / nadir_sdk-0.1.0.tar.gz
| Download URL | nadir_sdk-0.1.0.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
16a65acae8f7c19594e4ceda8650ebd7870fe7b9e08c12ee7015280fb3212a93
|
|
BLAKE2b-256 checksum How to use checksums |
d1dd46476aa2468c9010fede62ef162c8a745e09a5704e9978d5cce96b23b28e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / nadir_sdk-0.1.0-py3-none-any.whl
| Download URL | nadir_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aa6e310716766ef0d3f0235924fcbcef9e24cd88bccd444512ec7e627ddb1cf8
|
|
BLAKE2b-256 checksum How to use checksums |
5034e6bd9f75b65b5e5eee98daeb1c7f8369e9344d35af8ad605bfc147ba5783
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for nadir-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.