Installation & Configuration
Installation
Install from PyPI:
pip install qarion-sdk
For local development of the SDK itself:
pip install -e ".[dev]"
Configuration
Configuration is handled through the QarionConfig dataclass. You can pass values directly to the client constructor or set environment variables.
| Parameter | Environment Variable | Default | Description |
|---|---|---|---|
api_key | QARION_API_KEY | required | Your API key (starts with qk_) |
base_url | QARION_BASE_URL | http://localhost:8000 | Platform API base URL |
timeout | — | 30.0 seconds | Request timeout |
max_retries | — | 3 | Automatic retry count for transient failures |
Using Environment Variables
The simplest approach — set your credentials once and every client picks them up automatically:
export QARION_API_KEY="qk_your_api_key_here"
export QARION_BASE_URL="https://api.qarion.com"
from qarion import QarionClient
# No arguments needed — reads from environment
async with QarionClient() as client:
spaces = await client.spaces.list()
Explicit Configuration
Pass parameters directly when you need per-client control:
from qarion import QarionClient
async with QarionClient(
api_key="qk_...",
base_url="https://api.qarion.com",
timeout=60.0,
max_retries=5,
) as client:
spaces = await client.spaces.list()
Client Lifecycle
Both clients implement the context-manager protocol. Always use with / async with to ensure the underlying HTTP connection is closed properly:
# Async
async with QarionClient(api_key="qk_...") as client:
... # connection is open here
# connection closed automatically
# Sync
with QarionSyncClient(api_key="qk_...") as client:
... # connection is open here
# connection closed automatically
If you prefer manual control, call close() explicitly:
client = QarionSyncClient(api_key="qk_...")
try:
spaces = client.spaces.list()
finally:
client.close()
Requirements
- Python ≥ 3.10
- httpx — async and sync HTTP transport
- pydantic — typed response models