moth docs
Reference Messages

Messages

Sends a conversation to any chat model in Anthropic's Messages format, whatever format its host speaks.

POSThttps://api.runmoth.si/v1/messages

Point an Anthropic SDK at https://api.runmoth.si without /v1, since the SDK adds it, and send your key as its API key.

Body

modelrequired

A chat model ID from the catalog.

max_tokensrequired

The longest reply, in tokens, held in full until the call settles. The models that reason first, grok-4.7, deepseek-v4.1-flash and kimi-k3, hold and may bill up to 2,048 output tokens even when this is smaller, though the reply you see stops here.

messagesrequired

The conversation, with roles user and assistant. Content can be text, images, tool calls and their results, and thinking blocks.

systemstring or array

The system prompt.

toolsarray

Custom tools, or the web search tool on models that have it. A model whose capabilities.tools is false refuses a request with tools.

tool_choiceobject

auto, any, none or a named tool. A model whose capabilities.forced_tool_choice is false refuses any and a named tool with 400, so send auto to it.

stop_sequencesarray

Text that ends the reply. The GPT, Grok, DeepSeek and Kimi models refuse it.

temperaturenumber

From 0 to 1, sent where capabilities.sampling_params is true and dropped without an error elsewhere.

top_pnumber

From 0 to 1, sent where temperature is.

top_kinteger

Sent only to Claude models whose capabilities.sampling_params is true, and dropped elsewhere.

streamboolean

Sends the reply as it is written. Chat and streaming shows how to read it.

thinkingobject

Sent to Claude models and dropped elsewhere.

A stream in this format reports no charge, so read that call's cost in activity. On models other than Claude, message_start reports 0 input tokens and the real count arrives in the last message_delta.

Errors

400invalid_request_errorThe body isn't valid, holds a document or another block type the API doesn't take, or is longer than the model's context
401authentication_errorThe key is missing, revoked or expired
402insufficient_creditThe balance or the key's cap can't cover the call's hold
403permission_errorThe key may not use this model
404not_found_errorThe model isn't a chat model in the catalog
429rate_limit_errorToo many calls from the key or the account, or to the model, so wait for retry-after when it is sent
529overloaded_errorThe model is paused, or busy or down at its host, so choose another or wait for retry-after when it is sent
curl https://api.runmoth.si/v1/messages \
  -H "Authorization: Bearer $MOTH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "model": "gemini-3.8-flash", "max_tokens": 300, "messages": [ { "role": "user", "content": "Say hello in five words" } ] }'
Response
moth-request-id  req_4Gk9tQ2wXb7Lm1Pz8RcV
moth-charged-micros  18
{
  "id": "msg_4Gk9tQ2wXb7Lm1Pz8RcV",
  "type": "message",
  "role": "assistant",
  "model": "gemini-3.8-flash",
  "content": [
    {
      "type": "text",
      "text": "Hello there, good to meet."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 13,
    "output_tokens": 7
  }
}