OpenAI-compatible API
Call your own nodes from any OpenAI client through https://api.majesticmesh.com/v1, with streaming and your own tools.
Any app or library that speaks the OpenAI API can use your nodes. Point it at the central API with an API key and it answers with the models your nodes run or have connected.
Before you start
At least one of your nodes must be:
- running,
- sharing its chat From anywhere (in the app: Settings → Share → From anywhere),
- not set to Private.
Requests go to the first of your nodes that can answer, in the order of the central chat. If a node is offline, busy or over its relay budget, the next one takes over.
Base URL and key
Base URL: https://api.majesticmesh.com/v1
API key: mmk_api_...
Send the key as Authorization: Bearer YOUR_API_KEY. The header x-api-key works too.
Which models are available
GET /v1/models lists what the answering node offers:
majesticmesh-chat: the chat with mesh tools. It can call the agents on your nodes while it answers. It is available on every node.- One entry per LLM the node has connected, for example a local model or a provider you added.
- The LLMs of your account's other nodes, as
<agentID>@<peerID>. A call to one of them is routed to that node.
curl https://api.majesticmesh.com/v1/models \
-H "Authorization: Bearer $MM_API_KEY"
Chat completions
curl:
curl https://api.majesticmesh.com/v1/chat/completions \
-H "Authorization: Bearer $MM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "majesticmesh-chat", "messages": [{"role": "user", "content": "Hello"}]}'
Python, with the official OpenAI SDK:
from openai import OpenAI
client = OpenAI(base_url="https://api.majesticmesh.com/v1", api_key=MM_API_KEY)
r = client.chat.completions.create(
model="majesticmesh-chat",
messages=[{"role": "user", "content": "Roll a die for me."}],
)
print(r.choices[0].message.content)
Streaming
Set "stream": true to get standard SSE chunks, ending with data: [DONE]. stream_options.include_usage adds a final usage chunk. A model's thinking arrives as delta.reasoning; OpenAI SDKs skip it.
Use streaming for slow models: a request without streaming that sends nothing for about 100 seconds is cut off with 524. Streams send keepalives while the model thinks.
Your own tools
The plain models (every model except majesticmesh-chat) accept tools, tool_choice and parallel_tool_calls like OpenAI. The model's calls come back as tool_calls with finish_reason: "tool_calls"; your code runs them and sends the results back. Your tools never run on the node.
majesticmesh-chat rejects your own tools with 400 tools_not_supported, as does a model that cannot use tools. Small local models often use tools poorly.
Limits
- Relay budget. Requests count against the answering node's daily relay budget (429
relay_limit). Agents that resend their whole conversation each turn use it up much faster than a chat. - No node. 503
no_node_availablemeans none of your nodes could answer. - No repeats. A request that may already have run on a node is never repeated on another; you get 502
node_lostinstead. - Duration. One request runs 30 minutes at most.
- Images. Inline
data:URLs only (PNG, JPEG, WebP, GIF), at most 20 per request and 5 MiB each. Remote image URLs, audio and file parts, andn > 1are rejected with 400. - Ignored.
response_formatandlogprobsare silently ignored. - Media links. Links to generated media do not work through this address.
- Data. Requests pass through the relay and are not stored.