Create a message
Send an Anthropic Messages request to any chat model and get its response in Anthropic's format, whole or streamed.
https://inference.trymorse.ai/v1/messagesTakes an Anthropic Messages request on any Morse chat model and answers in Anthropic's format, whole or as a stream. Anthropic's SDKs and Claude Code can use Morse by pointing their base URL at it. Morse reads the request as a chat completion. It is billed, held, routed, and refused exactly as POST /v1/chat/completions is, and Morse keeps no state between requests. The key goes in Authorization: Bearer or in x-api-key. The query string, such as ?beta=true, is ignored, and so are the anthropic-version and anthropic-beta headers.
A stream is Anthropic's named events. message_start comes first. Then each text, thinking, or tool_use block sends a content_block_start, its deltas, and a content_block_stop. Then come message_delta, with the stop_reason and the usage, and message_stop. It sends no [DONE]. A comment line (: keepalive) keeps an idle stream open, and so does a ping event every 15 seconds while the model reasons unseen. Each event's data carries an obfuscation string of random length that hides the event's size. A stream that fails after it began ends with an error event and no message_stop. Usage splits the prompt as Anthropic does, into input_tokens, cache_read_input_tokens, and cache_creation_input_tokens.
Morse refuses each of these with a 400 in Anthropic's envelope that names it:
- server tools
- document blocks
- images linked by URL
- an output_config.format of any type but json_schema
- context_management, container, and mcp_servers ("Extra inputs are not permitted")
top_k is sent as the chat completion's top_k, on the same terms. A context_management that asks to clear nothing, as Claude Code sends, is taken and dropped. A 400, 401, 403, 404, 413, or 422 refusal, on this route or any other, carries X-Should-Retry: false. The Anthropic and OpenAI SDKs and Claude Code read it and do not send the request again. output_config.format of type json_schema is sent as the chat's response_format, named output and strict. So it needs forward_settings and a model whose providers list json_schema. thinking of type disabled, with no output_config.effort, asks for the effort none. A model that lists no none runs it at its lowest effort. With disable_parallel_tool_use, as with a chat's parallel_tool_calls: false, the response carries the first tool call alone, whichever provider served it. The calls it drops are billed. API keys are not offered end-to-end encryption for now, so a request for an end-to-end encrypted chat is refused with 403.
curl -X POST https://inference.trymorse.ai/v1/messages \
-H "x-api-key: $MORSE_API_KEY" \
-H "anthropic-version: 2023-06-01" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.3",
"max_tokens": 1024,
"system": "Answer in one sentence.",
"messages": [
{
"role": "user",
"content": "What is a TEE?"
}
],
"stream": true
}'{
"id": "msg_YYOKD77FV2J75JOVRH6T77B4GZ",
"type": "message",
"role": "assistant",
"model": "glm-5.3",
"content": [
{
"type": "text",
"text": "A TEE is hardware that runs code where its host cannot read it."
}
],
"stop_reason": "end_turn",
"stop_sequence": null,
"usage": {
"input_tokens": 4,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 20,
"output_tokens": 19
}
}Request body
An Anthropic Messages request. Morse reads it as a chat completion and serves it on any chat model, with the same billing, privacy floors, and failover. Parameters Morse does not use, such as metadata and service_tier, are ignored.
modelstringRequiredA model id from GET /v1/models. Anthropic's own id for a Claude model, such as claude-opus-5-5 or a dated id like claude-opus-5-5-20261001, also names the Morse model anthropic/claude-opus-5.5.
max_tokensintegerRequiredThe output limit. Morse clamps it to the model's limit, as it clamps max_completion_tokens.
messagesarray of objectRequiredThe conversation. A user turn takes text, image (base64 source only), and tool_result blocks. A tool_result with is_error true reaches the model with its text prefixed "Error: ". An assistant turn takes text and tool_use blocks. A thinking block's text reaches an open model as the turn's earlier reasoning, as reasoning_content does on a chat completion. A redacted_thinking block is dropped. A message with role system is sent as a system message in its place. An image inside a tool_result is served, as Claude Code's Read returns for a picture. The tool message ends with a line saying the image is in the next message. The image leads the user message that follows the turn's tool messages, under a line that names its call. document blocks, images linked by URL, and every other block type are refused with a 400 that names the type.
Show its 2 properties
rolestringRequiredOne of
user,assistant, orsystem.contentstring | array of objectRequired
systemstring | array of objectThe system prompt, a string or text blocks. Blocks are joined with a blank line. cache_control is ignored: Morse places its own cache breakpoints.
streambooleanStream the response as Anthropic's named server-sent events.
toolsarray of objectCustom tools (name, description, input_schema). Anthropic's server tools, such as web_search or code_execution, are refused with a 400 that names the type.
tool_choiceobjectauto, any, tool (with name), or none. disable_parallel_tool_use asks for at most one tool call.
thinkingobjectWith enabled and budget_tokens, Morse sets a reasoning effort from the budget. With disabled, it asks for no reasoning, which a model that cannot turn it off runs at its lowest effort. With enabled or adaptive, it also streams the model's reasoning as thinking blocks where the model shows it. Thinking blocks carry no signature.
output_configobjecteffort sets the reasoning effort (low, medium, high, xhigh, or max). format takes type json_schema with a schema, on a model whose providers honour json_schema. It needs an API key that lets its settings reach the provider.
stop_sequencesarray of stringSent as stop. An API key needs forward_settings, as for a chat completion's stop.
temperaturenumber1, Anthropic's default, is ignored. Any other value needs forward_settings, as for a chat completion.
top_pnumber1 is ignored. Any other value needs forward_settings, as for a chat completion.
providerobjectMorse's per-request privacy floor, as on POST /v1/chat/completions.
privacy_veilanyMorse's Privacy Veil ask, as on POST /v1/chat/completions.
Response
The response: a Message, or a stream of Anthropic events when stream is true.
idstringRequiredtypestringRequiredOne of
message.rolestringRequiredOne of
assistant.modelstringRequiredThe model as the request named it.
contentarray of objectRequiredShow its 1 property
typestringRequiredOne of
text,thinking, ortool_use.
stop_reasonstringRequiredOne of
end_turn,tool_use,max_tokens, orrefusal.stop_sequencestring | nullusageMessageUsageRequiredTokens as Anthropic counts them: input_tokens is the prompt read neither from nor into the cache.
Show its 4 properties
input_tokensintegerRequiredoutput_tokensintegerRequiredcache_creation_input_tokensintegerRequiredcache_read_input_tokensintegerRequired
Response headers
| Header | What it says |
|---|---|
X-Morse-Version | The running build. Every response the server makes carries it. A refusal the inference door makes itself does not, such as its 404 not_found or its 401 for a request with no key. |
X-Funding | What pays for the request. With a key, the value is always credits. A request that Morse refuses before it bills anything has no X-Funding. |
X-Ratelimit-Limit-Requests | The account's requests per minute, the limit behind 429 rate_limit_exceeded. All of the account's keys and its owner's use of the Morse app share it. A response carries the three X-Ratelimit headers when the account's rate limit judged its request. That is a request a key sends that Morse bills and that this limit judged, and the 429 rate_limit_exceeded this limit returns. A request paced by the included allowance carries none, and neither does a replayed response. A 429 from a route's own allowance carries none either, such as search's 90 calls a minute. Morse has no token rate limit, so it sends no x-ratelimit-*-tokens headers. |
X-Ratelimit-Remaining-Requests | How many more requests the account could send at once, as of this response, before a 429 rate_limit_exceeded. Requests sent since, by any of its keys, lower it. The account regains one request every 60 seconds divided by its limit. It holds at most its limit divided by 10 (rounded down, at least 1) plus one at once. 0 on the 429. |
X-Ratelimit-Reset-Requests | The time until the account may send its whole burst at once again. It is rounded up to a whole second and written as 1s, 45s, or 6m0s. 0s when it already may. |
X-Request-Id | An id for this request. Quote it when you contact support about the request. An error that arrives after the request starts carries it too. A request that Morse refuses before it bills anything has no X-Request-Id. |
X-Tier | The privacy tier of the endpoint that served the response. TEE is opt-in. A request on a model id is served at private or anon, at or above its provider.min_privacy and the key's minimum tier. It is served at tee only when either of those is tee, or the model has no private or anon endpoint at or above them. This header says which tier served it. It is at least the request's floor. No header names the provider or the endpoint. |
X-Model-Successor | Set when the request named a retired model id: the id that replaced it, which served the request. A retired id keeps working and is billed at its replacement's price. The docs list every retired id and its replacement. |
Errors
Branch on the status: an error returns Anthropic's error shape, whose error.type follows the status. The one exception is 403 service_unavailable_in_region, which returns Morse's error shape with that error.code.
{
"type": "error",
"error": {
"type": "authentication_error",
"message": "Incorrect API key provided."
}
}| Status | error.type |
|---|---|
400 | invalid_request_error |
401 | authentication_error |
402 | billing_error |
403 | permission_error |
404 | not_found_error |
413 | request_too_large |
429 | rate_limit_error |
503 | overloaded_error |
504 | timeout_error |
Any other 5xx | api_error |
When to retry applies to these statuses too.
400The request is malformed, or asks for something Morse does not serve. The message names the parameter or block.
401The key is missing or wrong.
402The account's credits, or what the key's spend limit has left, do not cover the request.
403The key may not use this model or route. A request with E2EE headers or a sealed model name is refused here. Its error type is permission_error. Its message reads: "End-to-end encryption is not offered to API keys for now. Send the request without E2EE headers, to a model id from GET /v1/models."1 code
service_unavailable_in_regionMorse doesn't serve the place the request comes from, because of US sanctions rules and its providers' terms. Every request from there returns this, whatever the key. It is the one refusal here that comes in Morse's own error envelope, {"error":{"message","type":"region","param","code"}}, so its code stays readable; every other refusal comes in Anthropic's.