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

Affiliation & monetization

This SDK is published by Hypnex Labs. It is a thin OpenAI-compatible client; calls go directly to api.mor.org and are billed by Morpheus AI to the API-key holder. This SDK does not currently route fees to Hypnex Labs. Hypnex's revenue comes from the sister SDK hypnex-staking (MRC 73 capital referral) and the stake.hypnex.xyz onramp. Hypnex is not affiliated with the Morpheus AI Foundation.

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.1.tar.gz (45.0 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.1-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hypnex_openai-0.1.1.tar.gz
  • Upload date:
  • Size: 45.0 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.1.tar.gz
Algorithm Hash digest
SHA256 372ed391c8b9d6f45038c7dae3831589eef1bf0d6a4aaf67129d4879cf4eb639
MD5 670597f939e32d23d707b13e0ece8ef1
BLAKE2b-256 dfd9cf07dda1c47d748db6e93cc0608c8f6f014461acd9bf9bd0644ba7068164

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hypnex_openai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49f882a2a5be788d4f11a11dd3d5e0d11b1ba1839bd5f7fe217e2024cd1c0ef4
MD5 fbcb5563dea733bcfe5e2ac147e89b55
BLAKE2b-256 81da53a1dc27371ae254778bf2e86b3b7ac75826f64bbceeba64859f36b61e1e

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