Skip to content

anthropic-server

Anthropic-compatible HTTP surface for hum (POST /v1/messages, SSE streaming)

A bee that fronts hum’s local thrum socket with the Anthropic Messages API. Drop-in for @anthropic-ai/sdk — point baseURL at this server and existing Anthropic clients work against hum without knowing thrum exists. Symmetric counterpart to openai-server.

Propensity

statefulnessrichnesswire shapehides
convention-statefulmediumAnthropic /v1/messages SSEpulse, breath, drone, perf-mark, tendril, permission-ask, tool-meta

Each request mints a fresh sid; continuation flows through the messages array as tool_result content blocks.

What it does

client anthropic-server humd
│ │ │
│ POST /v1/messages │ │
├────────────────────────────────────►│ │
│ { model, messages, system, │ │
│ tools, stream:true } │ chi:"hello" on first call │
│ ├─────────────────────────────►│
│ │ chi:"prompt" (text/system/tools)
│ ├─────────────────────────────►│
│ │ chi:"chunk" (text/tool_use) │
│ │◄─────────────────────────────┤
│ event: content_block_delta │ │
│ data: { delta: { text: "Hi" } } │ │
│◄────────────────────────────────────┤ │
│ │ chi:"finish" │
│ │◄─────────────────────────────┤
│ event: message_stop │ │
│◄────────────────────────────────────┤ │

Tool use flows symmetrically: model tool_use blocks come out via chi:"tool-call", and the client’s tool_result content blocks in the next message come back as chi:"tool-result" carrying the matching callId.

Configure

envdefaultwhat
ANTHROPIC_SERVER_PORT14622HTTP listen port
ANTHROPIC_SERVER_HOST127.0.0.1HTTP listen host
ANTHROPIC_SERVER_API_KEY(empty = no auth)required x-api-key header value
HUM_THRUM_SOCK$XDG_RUNTIME_DIR/hum/thrum.sockhumd’s NDJSON socket

You can also drop a JSON config at ~/.config/hum/hives/anthropic-server.json with shape { host?, port?, apiKey? }. Precedence: env > config file > defaults.

Run

Terminal window
npm install
npm run build
npm start

Or in dev:

Terminal window
npx tsx src/index.ts

Use

Terminal window
curl http://localhost:14622/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: anything" \
-d '{
"model": "claude-sonnet-4",
"max_tokens": 1024,
"stream": true,
"messages": [{ "role": "user", "content": "ping" }]
}'

Drop-in for the Anthropic SDK:

import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "http://localhost:14622",
apiKey: "anything",
});
const stream = await client.messages.stream({
model: "claude-sonnet-4",
max_tokens: 1024,
messages: [{ role: "user", content: "ping" }],
});
for await (const chunk of stream) console.log(chunk);

What flows where

Anthropic Messages surfacehum chi
POST /v1/messageschi:"prompt"
system (string or [{type:"text"}])prompt.systemPrompt
tools[] (with input_schema)prompt.tools[]
tool_result blocks in last user msgchi:"tool-result"
content_block_delta textchi:"chunk" (text part)
content_block_delta input_jsonchi:"chunk" (tool_use partial)
message_stopchi:"finish"
error eventchi:"error"

Status

Reference implementation. Streaming + non-streaming both supported. Tool use is forwarded; image inputs, prompt caching, and vision are not yet wired.

See also