← All docs

POST /v1/messages

Anthropic Messages compatible endpoint and free token counting.

Anthropic Messages compatible — anthropic-native clients such as Claude Code connect as-is. Internally it runs through the same chat pipeline and supports stream.

Parameters

ParameterTypeRequiredDescription
modelstringYesModel ID
messagesarrayYesrole is user / assistant. content is a string or an array of blocks (text, image, tool_use, tool_result, thinking, document)
max_tokensintegerYes1–200000 (required by the Anthropic spec)
systemstring | arrayNoA string or an array of text blocks
temperaturenumberNo0–1
top_pnumberNo0–1
top_kintegerNoPositive integer
stop_sequencesstring[]NoUp to 8
streambooleanNoDefaults to false
toolsarrayNo{name, description, input_schema}
tool_choiceobjectNo{"type":"auto"|"any"|"none"} or {"type":"tool","name":"..."}
metadataobjectNo{"user_id": "..."}
thinkingobjectNo{"type":"enabled","budget_tokens":N} (N < max_tokens) · {"type":"adaptive"} · {"type":"disabled"}
everyaisobjectNoGateway caching options

If you attach cache_control directly to a block, it is passed through as-is (see prompt caching).

Request

{
  "model": "everyais/claude-opus-5",
  "max_tokens": 1024,
  "messages": [{"role": "user", "content": "Hello!"}]
}

POST /v1/messages/count_tokens

Estimates the input token count before you send a request. Claude Code calls this endpoint automatically.

  • Free — no credit is deducted.
  • Returns a heuristic estimate without calling the upstream provider (it may differ from the exact tokenizer result).
  • The request body takes the same shape as /v1/messages.
{
  "input_tokens": 1234
}