Skip to main content

Drop-in OpenAI client for the Morpheus decentralized inference network (mor.org)

Project description

hypnex-openai (Python)

Drop-in OpenAI client for the Morpheus decentralized inference network (mor.org).

pip install hypnex-openai
from hypnex_openai import HypnexOpenAI

client = HypnexOpenAI(api_key="mor_...")  # get one at https://app.mor.org

response = client.chat.completions.create(
    model="mistral-31-24b",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

HypnexOpenAI subclasses openai.OpenAI and points it at https://api.mor.org/api/v1. Streaming, tools, async, structured output — all work unchanged.

Models on the Morpheus network

The network exposes 60+ models via OpenAI-compatible endpoints. List them:

hypnex models

Or programmatically:

client.morpheus.active_models()           # full registry
client.morpheus.models_by_type("LLM")     # filter
client.morpheus.find_model("glm-5")       # lookup

Featured LLMs: mistral-31-24b, glm-5, qwen3-235b, qwen3-coder-480b-a35b-instruct, deepseek-r1:70b, minimax-m25. Embeddings: text-embedding-bge-m3. TTS: tts-kokoro. STT: whisper-1.

Drop-in for popular frameworks

Any framework that accepts a base_url accepts Morpheus:

# LangChain
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
    model="qwen3-235b",
    api_key=os.environ["HYPNEX_API_KEY"],
    base_url="https://api.mor.org/api/v1",
)

# CrewAI
from crewai import LLM
llm = LLM(
    model="openai/qwen3-235b",
    api_key=os.environ["HYPNEX_API_KEY"],
    base_url="https://api.mor.org/api/v1",
)

# llama-index
from llama_index.llms.openai_like import OpenAILike
llm = OpenAILike(
    model="qwen3-235b",
    api_base="https://api.mor.org/api/v1",
    api_key=os.environ["HYPNEX_API_KEY"],
    is_chat_model=True,
)

# instructor
import instructor
client = instructor.from_openai(HypnexOpenAI())

Morpheus-specific endpoints

client.morpheus.* exposes endpoints that have no OpenAI equivalent:

Method What it does
balance() Current MOR balance
transactions(limit=50) Billing history
spending() Cumulative usage
me() User profile
list_keys() / create_key(name) / delete_key(id) / set_default_key(id) API keys
link_wallet(addr, sig, msg) / get_wallet() / unlink_wallet() Wallet binding
active_models() / find_model(name) / models_by_type(type) Public registry

CLI

hypnex models                          # list
hypnex health                          # show api.mor.org health
hypnex chat "Hello" --model glm-5      # one-shot

Async

from hypnex_openai import AsyncHypnexOpenAI
client = AsyncHypnexOpenAI(api_key="mor_...")
r = await client.chat.completions.create(...)

Environment

  • HYPNEX_API_KEY — your API key (required)
  • HYPNEX_BASE_URL — override base URL (default https://api.mor.org/api/v1)

Tests

pip install -e ".[dev]"
pytest                                   # public smoke tests
HYPNEX_API_KEY=mor_... pytest          # also run authenticated tests

License

MIT

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

hypnex_openai-0.1.0.tar.gz (47.6 kB view details)

Uploaded Source

Built Distribution

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

hypnex_openai-0.1.0-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file hypnex_openai-0.1.0.tar.gz.

File metadata

  • Download URL: hypnex_openai-0.1.0.tar.gz
  • Upload date:
  • Size: 47.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hypnex_openai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ef86ae675ca001a13a17932ca2a7fc84da8eae1ea6f194bd560a79d7917e90f2
MD5 ff532e90a6b7c38b33f9f9e78242cd1b
BLAKE2b-256 282e9a4b98af5e8a48c98e8fc1b213e7cf289136da7bbd83b2700cb8e65afa2e

See more details on using hashes here.

File details

Details for the file hypnex_openai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hypnex_openai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hypnex_openai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f766705347f064d1ac0c8d176240cf4e28154cc5b98ea010c3f7fb263bd13930
MD5 23d265cdbdfc75296b93998ca0dad109
BLAKE2b-256 14553802546f17cd0f1fccb103a0e682127e678b14f403ef6c4973768e6ebe60

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