Install the Python SDK
An SDK (software development kit) is a ready-made helper for your code. Instead of writing web requests by hand, you call simple functions like client.chat.complete(), and the SDK does the rest.
The NuRoute Python SDK needs Python 3.9 or newer. It uses httpx to talk over the internet.
Before you start
- Python 3.9 or newer. To check, type
python --versionin your terminal. - An API key that starts with
aicp-. Make one in the dashboard under Settings → API Keys (see the Quickstart). - Your gateway address, the web address your requests go to.
Step 1: Install
pip install nuroute
Step 2: Create a client
A client is the object you use to talk to NuRoute. You make it once and reuse it. There are two kinds. Pick one.
Sync client (the simple one)
"Sync" means your program waits for each answer before it moves on. Start here if you are not sure.
from nuroute import NuRouteClient
client = NuRouteClient(
api_key="aicp-...",
base_url="https://your-gateway",
timeout=30.0,
)
Async client (for doing many things at once)
"Async" means your program can send several requests at the same time and not sit idle. See the Async client page.
from nuroute import AsyncNuRouteClient
client = AsyncNuRouteClient(
api_key="aicp-...",
base_url="https://your-gateway",
)
Settings you can pass
| Setting | Type | Default | What it means |
|---|---|---|---|
api_key | str | None | None | Your secret key (a "Bearer token"). You can leave it out and set it later with set_api_key(). |
base_url | str | http://localhost:3000 | The NuRoute gateway address. |
timeout | float | 30.0 | How long to wait for an answer, in seconds, before giving up. |
Closing the client neatly (sync)
The sync client keeps a pool of open connections (an httpx connection pool). Use it as a context manager (a with block) and Python closes everything properly for you:
with NuRouteClient(api_key="aicp-...", base_url="https://your-gateway") as client:
response = client.chat.complete(
model="auto",
messages=[{"role": "user", "content": "Hello!"}],
)
Next step
Learn which kind of key to use in Authentication, or jump to Chat completions to ask your first question.