Python SDK
Python SDK
Orqen works with any OpenAI-compatible Python client. For LLM calls you use the standard openai package pointed at Orqen's endpoint. A dedicated management SDK for programmatic key and usage management is coming soon.
LLM calls: use the OpenAI SDK
Install the standard OpenAI package. No additional package required.
pip install openaifrom openai import OpenAI
client = OpenAI(
api_key="sk-orq-YOUR_KEY", # Your Orqen key
base_url="https://api.orqen.app/v1", # Orqen endpoint
)
response = client.chat.completions.create(
model="gpt-4o", # or "orqen/auto" to let Orqen choose
messages=[{"role": "user", "content": "What is the weather in London?"}],
tools=[...], # Orqen prunes this automatically
)
print(response.choices[0].message.content)Other frameworks
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4o",
api_key="sk-orq-YOUR_KEY",
base_url="https://api.orqen.app/v1",
)Account management via REST
Until the native SDK ships, use httpx or requests to call the management API. All endpoints accept your Orqen key as a Bearer token.
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
# Current month usage
summary = orqen("GET", "/v1/account/usage/summary")
print(f"Tokens pruned: {summary['tokens_saved_estimate']:,}")
print(f"Provider savings: {summary['provider_savings_usd']:.3f{'}'}")
# Create an API key with an explicit saved-token budget
new_key = orqen("POST", "/v1/account/keys", json={
"name": "ci-agent",
"daily_token_budget": 75000,
"weekly_token_budget": 500000,
})
print(f"New key: {new_key['key']}") # shown once
# Add a provider key
orqen("PUT", "/v1/account/providers", json={"provider": "openai", "api_key": "sk-proj-..."})
# Set routing mode
orqen("PUT", "/v1/account/routing/preferences", json={"routing_mode": "auto"})Coming soon
Native Python management SDK
A first-class pip install orqen package is in development with typed responses and full IDE autocomplete.
# Coming soon — pip install orqen
from orqen import OrqenClient
client = OrqenClient(api_key="sk-orq-...")
summary = client.usage.summary()
new_key = client.keys.create(name="production-agent")
client.providers.save(provider="openai", api_key="sk-proj-...")
client.routing.update(routing_mode="auto")