Python SDK for the Optimus API — MSC construction, routing, and answers
Project description
agent-optimus
Python SDK for the Optimus backend API. Install with pip and call MSC construction, model routing, and full answer generation from Python.
Installation
pip install agent-optimus
Quick start
You can use Optimus with the exact same call pattern as OpenRouter/OpenAI. Only the import and API key differ.
Option 1 — built-in client (recommended, no extra install)
from agent_optimus import OpenAI
client = OpenAI(api_key="your-optimus-api-token")
response = client.chat.completions.create(
model="qwen/qwen3-32b",
messages=[
{"role": "user", "content": "Hello"}
],
)
print(response.choices[0].message.content)
base_url defaults to production. Override only for local development:
client = OpenAI(
api_key="your-optimus-api-token",
base_url="http://127.0.0.1:8000",
)
Option 2 — official openai package
If you need the real OpenAI SDK types/objects:
pip install agent-optimus[openai]
from openai import OpenAI
from agent_optimus import create_openai_client
client = create_openai_client(api_key="your-optimus-api-token")
response = client.chat.completions.create(
model="qwen/qwen3-32b",
messages=[
{"role": "user", "content": "Hello"}
],
)
print(response.choices[0].message.content)
Note:
from openai import OpenAIalone cannot talk to Optimus directly, because Optimus uses/finishinstead of OpenAI's/v1/chat/completions.create_openai_client()wires that up for you.
Optimus-specific fields (routing_score, cost_usd, metrics) are available on response.optimus (built-in client) or inside the raw response payload (official client).
Native SDK usage
from agent_optimus import AgentOptimus
client = AgentOptimus(api_token="your-api-key")
# 1. Build an MSC from long context
msc = client.construct_msc(
context="Italy dominates European silk production...",
user_query="Who leads silk production in Europe?",
)
print(msc["msc_string"], msc["compression_ratio"])
# 2. Route only (no full MSC + answer pipeline)
routed = client.route(
context="The Eiffel Tower is in Paris.",
query="Where is the Eiffel Tower?",
)
print(routed["content"], routed["model_provider_detail"])
# 3. Full pipeline answer (MSC + route + generate)
answer = client.answer(
context="The Eiffel Tower is in Paris.",
query="Where is the Eiffel Tower?",
)
print(answer["content"], answer["metrics"])
You can also pass api_token per call instead of on the client:
client = AgentOptimus(base_url="http://127.0.0.1:8000")
result = client.route(api_token="your-api-key", context="...", query="...")
Configuration
| Setting | Default | Override |
|---|---|---|
| Base URL | https://api-optimus-backend-service.up.railway.app |
AGENT_OPTIMUS_BASE_URL env var or base_url= |
| OpenAI client | OpenAI(api_key=...) |
api_key= |
| Native client | AgentOptimus(api_token=...) |
api_token= on client or each method |
| Auth header | x-api-token |
fixed |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_optimus-0.1.1.tar.gz.
File metadata
- Download URL: agent_optimus-0.1.1.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5f8412f9fcbefd81f27489a0223a7cebadf2689a0f3af3e110ee5bfdbb92d1c8
|
|
| MD5 |
24ae2ee295a1b5875a6b482232afca6a
|
|
| BLAKE2b-256 |
175672969cbcc331741f4fc325a824ef912604a31aed176d7a6ccb9a777a23d1
|
File details
Details for the file agent_optimus-0.1.1-py3-none-any.whl.
File metadata
- Download URL: agent_optimus-0.1.1-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18599ebb825a62ef7f1f817a1c73b8fbf1e3e452e8fa8af4e89197cd78a2dbd9
|
|
| MD5 |
f0879874d2936692b6f492d877e90067
|
|
| BLAKE2b-256 |
0ea6a4eed8b9a67af655fc305ea6126121c64cdc11d5608a159ec103932581e2
|