hypnex-openai
Drop-in client for the Morpheus inference network. Same shape as openai, pointed at https://api.mor.org/api/v1.
bash
pip install hypnex-openai # Python
npm install hypnex-openai # TypeScriptWhy this exists
The Morpheus protocol exposes an OpenAI-compatible inference API at https://api.mor.org/api/v1 serving 60+ models — Mistral, GLM, Qwen, DeepSeek, Llama, MiniMax, plus embeddings, TTS, and Whisper. hypnex-openai is the smallest possible wrapper: it subclasses openai.OpenAI (Python) / OpenAI (TS) and points the base URL at Morpheus. Streaming, tools, structured output, async — all unchanged.
Python
python
from hypnex_openai import HypnexOpenAI
client = HypnexOpenAI(api_key="mor_...") # https://app.mor.org
# Chat completion
r = client.chat.completions.create(
model="mistral-31-24b",
messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)
# Streaming
for chunk in client.chat.completions.create(
model="glm-5", messages=[...], stream=True
):
print(chunk.choices[0].delta.content or "", end="", flush=True)
# Embeddings
emb = client.embeddings.create(
model="text-embedding-bge-m3",
input="a sentence to embed",
)TypeScript
ts
import { HypnexOpenAI } from "hypnex-openai";
const client = new HypnexOpenAI({ apiKey: process.env.HYPNEX_API_KEY });
const r = await client.chat.completions.create({
model: "mistral-31-24b",
messages: [{ role: "user", content: "Hello" }],
});
console.log(r.choices[0].message.content);List active models
python
print(client.models.list()) # OpenAI-shape model list
print(client.morpheus.active_models()) # Hypnex extension: full Morpheus registry
print(client.morpheus.find_model("glm")) # filter by name
print(client.morpheus.models_by_type("llm")) # filter by type (llm/embedding/tts/whisper)The client.morpheus.* extensions hit https://active.mor.org/active_models.json directly — no auth required for read.
Environment variables
| Var | Default | Purpose |
|---|---|---|
HYPNEX_API_KEY | (none) | API key from app.mor.org |
HYPNEX_BASE_URL | https://api.mor.org/api/v1 | Override base URL (e.g. for testing) |
Drop-in for popular frameworks
| Framework | Swap |
|---|---|
| LangChain (Python) | ChatOpenAI(base_url="https://api.mor.org/api/v1", api_key=...) |
| LangChain.js | new ChatOpenAI({ configuration: { baseURL: "..." } }) |
| CrewAI | LLM(model="openai/<morpheus-model>", base_url=..., api_key=...) |
| llama-index | OpenAILike(api_base=..., is_chat_model=True) |
| AutoGen | config_list = [{ "base_url": ..., "api_key": ... }] |
| Vercel AI SDK | createOpenAI({ baseURL: ..., apiKey: ... }) |
| dspy | dspy.OpenAI(api_base=..., api_key=...) |
| instructor | instructor.from_openai(HypnexOpenAI()) |
Source
github.com/hypnex-labs/hypnex/tree/main/python (Python) github.com/hypnex-labs/hypnex/tree/main/typescript (TypeScript)