Skip to content
API reference

Messages & token counting

Use Anthropic-style messages, content blocks, and token estimates.

POST/v1/messagesapi.17.wtf
On this page Request bodyExample requestContent & response blocksCount input tokens

Request body

ParameterType / requirementDescription
modelstring · requiredText model ID.
messagesarray · requireduser or assistant messages with text or content blocks.
max_tokenspositive integer · requiredMaximum generated tokens.
systemstring or text-block array · optionalSystem prompt outside messages.
temperature, top_pnumber · optionalModel-dependent sampling controls.
stop_sequencesstring[] · optionalStop sequences.
streamboolean · optionalDefaults to false.
toolsarray · optionalname, description, and input_schema.
tool_choiceobject · optionaltype: auto, any, none, or tool with a name.
thinkingobject · optionalModel-dependent thinking configuration; budget_tokens must be positive.
reasoning_effortstring · optionaloutput_config.effort is a fallback alias.

Example request

Use a model key in x-api-key and the Anthropic version header.

curl https://api.17.wtf/v1/messages \
  -H "x-api-key: $LM0_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "MODEL_ID",
  "max_tokens": 512,
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}'

Content & response blocks

Read generated text from content blocks where type is text. Other supported blocks include images, tool_use, tool_result, and thinking. Base64 images use source.type: base64, media_type, and data; URL images use source.type: url and url. Inspect stop_reason and usage.input_tokens / usage.output_tokens. Provider-specific server tool blocks and redacted thinking are not round-tripped.

Count input tokens

POST /v1/messages/count_tokens accepts model, messages, and optional system using the Messages format. Include a valid text model ID so access and routing can be resolved. The gateway uses native Anthropic counting where possible and a coarse local estimate otherwise. Treat the result as an estimate, not a billing quote.

curl https://api.17.wtf/v1/messages/count_tokens \
  -H "Authorization: Bearer $LM0_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "MODEL_ID",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}'