Skip to main content

Python SDK

Official Python client library for the API Router Console API.

Why use the SDK​

  • Typed models — every response is a pydantic v2 model, so IDEs autocomplete fields and parsers reject malformed data.
  • Transparent auth — the SDK exchanges your API key for a Bearer token at construction time and auto-refreshes on expiry. You never call loginByApiKey manually.
  • Sync + async — WltClient (sync) and AsyncWltClient (async) share an identical method surface.
  • Retries built in — failed network calls and expired-token responses are retried automatically.

Installation​

pip install wlt-platform

Quick start​

from wlt import WltClient

client = WltClient(
api_key="your-api-key",
base_url="https://console.example.com",
)

# List your API keys (Secrets)
result = client.secrets.list(page_num=1, page_size=20)
print(result.page_info.list)

# Stream a chat completion
for chunk in client.model_lab.stream(
provider="dashscope",
model_name="Qwen2.5-72B-Instruct",
user_prompt="Hello!",
):
print(chunk, end="", flush=True)

client.close()

For async usage, use AsyncWltClient with await on each method.

Configuration​

For this environment, set base_url to https://console.example.com.

client = WltClient(
api_key="your-api-key", # Required. Auto-exchanged for Bearer token
base_url="https://console.example.com",
timeout=30.0, # Request timeout in seconds (default: 30)
max_retries=2, # Max retry attempts (default: 2)
)

Base URL resolution​

Priority, highest → lowest:

PrioritySource
1Constructor base_url argument (or CLI --base-url)
2WLT_BASE_URL environment variable
3base_url field in ~/.wlt/config.json (CLI users only)
4Built-in default

Trailing slashes are stripped automatically; https://host/ and https://host are equivalent.

Module reference​

ModuleAccessorMethods
Userclient.user1
Secretclient.secrets8
ApiKeyclient.api_keys7
Usageclient.usage4
Billingclient.billing4
Paymentclient.payment5
Model Galleryclient.model_gallery3
Model Labclient.model_lab3

Admin scope​

A separate AdminClient handles admin-scope operations (billing reports, end-customer CRUD, model pricing, credits, rate limits, and context records). It authenticates with an admin username and password — no captcha, no API key — and issues a session token scoped to admin-only endpoints. Instantiate it alongside WltClient when the caller must act as an administrator.

from wlt import AdminClient

admin = AdminClient(
username="admin",
password="your-admin-password",
base_url="https://console.example.com",
)

info = admin.auth.info() # admin identity
totals = admin.billing.customer_total( # billing rollup
start_time="2026-06-01 00:00:00",
end_time="2026-06-30 23:59:59",
)
customers = admin.customer.list(page_num=1, page_size=20) # customer CRUD
ModuleAccessorMethods
Authadmin.auth1
Billingadmin.billing6
Customeradmin.customer3
Pricingadmin.pricing9
Creditsadmin.credits2
Rate Limitadmin.rate_limit2
Contextadmin.context3