API reference
Messages
POSThttps://api.offmem.app/v1/messages
Generates a model response in the Anthropic Messages format. Works with the official Anthropic SDKs and with Claude Code.
pip install anthropiccurl https://api.offmem.app/v1/messages \
-H "x-api-key: $OFFMEM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "offmem-glm-5.3-abliterated",
"max_tokens": 1024,
"system": "Answer in English.",
"messages": [{"role": "user", "content": "Explain what an API is in one sentence."}]
}'Headers
x-api-keyom_...required- API key.
Authorization: Beareralso works. Content-Typeapplication/jsonrequired- JSON body.
anthropic-versionstring- Accepted and not required.
Body
modelstringrequired- Model ID, or a
claude-*name (see Accepted IDs). The response repeats the name you sent. max_tokensintegerrequired- Output token limit, 1 or more.
messagesarrayrequired- Turns with role
userorassistant. Messages with rolesystemare merged intosystem. systemstring | array- Instructions, as text or
textblocks. temperaturenumber- Forwarded to the model.
top_pnumber- Forwarded to the model.
stop_sequencesstring[]- Up to 4 sequences; extras are ignored.
toolsarray- Custom tools (
name,description,input_schema). Anthropic server tools, such as web search, are ignored. tool_choiceobjectauto,any,tool(withname) ornone.streamboolean- Returns Anthropic server-sent events.
Other fields, such as top_k, metadata and thinking, are ignored.
Content blocks
| Block | Support |
|---|---|
text | Supported. |
image | Base64 (source.type: base64) or URL (source.type: url), only on models with vision. |
tool_use | Supported, in assistant turns. |
tool_result | Supported, with text content. is_error: true is sent to the model as an error. |
thinking | Ignored. |
document | Not supported: 400. Send the text instead. |
Response
{
"id": "msg_...",
"type": "message",
"role": "assistant",
"model": "offmem-glm-5.3-abliterated",
"content": [{ "type": "text", "text": "..." }],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 24,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 40
}
}| stop_reason | When |
|---|---|
end_turn | The model finished the answer. |
max_tokens | Reached max_tokens. |
tool_use | The model called a tool. |
refusal | The answer was blocked by a content filter. |
usage.input_tokens excludes cached tokens, which come in cache_read_input_tokens. cache_creation_input_tokens is always 0. The request ID comes in the request-id header.
Streaming
With "stream": true, the events follow the Anthropic order: message_start, content_block_start, content_block_delta (text_delta or input_json_delta), content_block_stop, message_delta and message_stop. A failure in the middle of the stream arrives as an error event.
Count tokens
POSThttps://api.offmem.app/v1/messages/count_tokens
Returns {"input_tokens": n}, an estimate of 3 characters per token over system, messages and tools. Free; requires a valid key.
curl https://api.offmem.app/v1/messages/count_tokens \
-H "x-api-key: $OFFMEM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "offmem-glm-5.3-abliterated", "messages": [{"role": "user", "content": "ok"}]}'