API

Claude Code

Run Claude Code against your own nodes through MajesticMesh's Anthropic-compatible /v1/messages endpoint.

MajesticMesh also speaks Anthropic's Messages API, so Claude Code and Anthropic's SDKs can use the models on your nodes. You need an API key and a running node that shares its chat From anywhere and is not set to Private.

Set it up

Set these environment variables, then start Claude Code:

export ANTHROPIC_BASE_URL=https://api.majesticmesh.com
export ANTHROPIC_AUTH_TOKEN=mmk_api_...
export ANTHROPIC_MODEL=YOUR_MODEL
export ANTHROPIC_DEFAULT_HAIKU_MODEL=YOUR_MODEL
claude
  • The base URL has no /v1 at the end.
  • ANTHROPIC_MODEL is the model Claude Code uses. ANTHROPIC_DEFAULT_HAIKU_MODEL covers the smaller background requests Claude Code makes; set it to the same model unless you have a second one.

Choose a model

Use the id of one of your plain models, exactly as GET /v1/models lists it (see OpenAI-compatible API):

curl https://api.majesticmesh.com/v1/models \
  -H "Authorization: Bearer $MM_API_KEY"

Claude Code relies on tools, so pick a model that can use tools. majesticmesh-chat does not take your own tools, and small local models often use them poorly.

The node that answers needs a version from 2026-11-06 or later for /v1/messages; an older node hands the request to the next one.

Anthropic SDK

The same works from your own code:

import anthropic

client = anthropic.Anthropic(base_url="https://api.majesticmesh.com", api_key=MM_API_KEY)
m = client.messages.create(model="YOUR_MODEL", max_tokens=1024,
                           messages=[{"role": "user", "content": "Hello"}])

The key works as x-api-key or as Authorization: Bearer.

Known limits

  • Thinking is always shown. When streaming, a model's thinking comes as thinking blocks whether you asked for it or not, so you see progress while a slow model thinks. The thinking setting itself is ignored, and thinking blocks in the history are dropped.
  • No images in tool results. A picture in a tool_result is replaced by a note saying it was left out. Images in your own messages work as inline base64.
  • Long requests without streaming. A request without streaming that sends nothing for about 100 seconds is cut off with 524. Streams send keepalives, so stream for slow models. One request runs 30 minutes at most.
  • Not supported. Server tools (such as web_search), document blocks and image URLs are rejected with 400. stop_sequences, top_p, top_k, metadata, cache_control and anthropic-beta are ignored.
  • Estimated token counts. If the provider reports no token counts, they are estimated (about four characters per token), so Claude Code can still compact its context.
  • Relay budget. Claude Code resends the whole conversation on every turn, so a long coding session uses up the node's daily relay budget much faster than a chat (429 relay_limit).