Skip to content
Orqen Docs

Python SDK

SDK reference

A native Python management SDK is coming soon. Until then, call account APIs with httpx or requests and your Orqen API key. For chat completions, use the OpenAI SDK with base_url="https://api.orqen.app/v1".

Note on the orqen PyPI package

The published orqen package is the Orqen FastAPI server, not a client SDK. Do not install it for agent or management scripts.

REST endpoints

GET/v1/account/usage/summaryCurrent month requests, token savings, and billing estimate.
GET/v1/account/usage/dailyDaily token savings and request counts.
GET/v1/account/requestsPaginated request log.
GET/v1/account/keysList API keys.
POST/v1/account/keysCreate an API key; secret returned once.
DELETE/v1/account/keys/{id}Revoke an API key.
PUT/v1/account/providersStore or update encrypted provider credentials.
PUT/v1/account/routing/preferencesSet passthrough, auto, cheap, fast, or capable routing.

See the API reference for the full endpoint list.

Examples

import httpx

ORQEN_KEY = "sk-orq-YOUR_KEY"
BASE      = "https://api.orqen.app"

def orqen(method: str, path: str, **kwargs):
    with httpx.Client() as client:
        r = client.request(
            method, BASE + path,
            headers={"Authorization": f"Bearer {ORQEN_KEY}"},
            **kwargs,
        )
        r.raise_for_status()
        return r.json() if r.content else None

summary = orqen("GET", "/v1/account/usage/summary")
print(summary["tokens_saved_estimate"])

new_key = orqen("POST", "/v1/account/keys", json={"name": "ci-agent"})
print(new_key["key"])  # shown once

Error handling

REST calls return standard HTTP status codes. Check response.status_code and parse JSON error bodies. Store API keys securely and rotate them from the dashboard or API.