Python SDK Overview
Get started with the therouter package in Python applications and scripts.
Installation
pip
pip install therouterInitialization
client.py
import os
from therouter import TheRouter.ai
client = TheRouter.ai(
api_key=os.getenv("THEROUTER_API_KEY"),
base_url="https://api.therouter.ai/v1",
)| Name | Type | Required | Description |
|---|---|---|---|
api_key | str | Required | API key from THEROUTER_API_KEY. |
base_url | str | Defaults to https://api.therouter.ai/v1. | |
timeout | float | Request timeout in seconds. |
Basic Usage
Responses API
response = client.responses.create(
model="openai/gpt-4o-mini",
input="Summarize the deployment report in 3 bullets.",
)
print(response.output_text)Environment variables
Export
THEROUTER_API_KEY in your shell or inject it through your deployment platform secrets.