Skip to main content

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-api-token")

response = client.chat.completions.create(
    model="qwen/qwen3-32b",
    messages=[
        {"role": "user", "content": "Hello"}
    ],
)

print(response.choices[0].message.content)

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-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 OpenAI alone cannot talk to Optimus directly, because Optimus uses internal end point instead 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"])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_optimus-0.1.2.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_optimus-0.1.2-py3-none-any.whl (10.5 kB view details)

Uploaded Python 3

File details

Details for the file agent_optimus-0.1.2.tar.gz.

File metadata

  • Download URL: agent_optimus-0.1.2.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.13

File hashes

Hashes for agent_optimus-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ce2c0ab2a7091e96d2cc91ee9cff9309ffb03883856b5e908119403cec62bade
MD5 fca18a268930668a3f6cae398f290658
BLAKE2b-256 a9da77c60977f6894efad429dbdd155aabca87aa873eba621e9f2013866cac17

See more details on using hashes here.

File details

Details for the file agent_optimus-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: agent_optimus-0.1.2-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

Hashes for agent_optimus-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 ce552708ca99e7199d32cb9a4a316e421beda469c112b82032313ff2252c4e59
MD5 25cec319b69c8d76a2bf8556fcdfc94f
BLAKE2b-256 cbab19a4d71332fdbb86a32ba694841e457d260ea12b95139745192d1dd30057

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page