API reference

Messages

Call the Anthropic Messages compatibility route with text, images and client-side tools.

POST /api/v1/messages translates supported Messages requests to the gateway's model routes. AI Hub model IDs and inference credentials still apply.

Request

bash
curl --fail-with-body https://tokenhub-api.belive.sg/api/v1/messages \
  -H "Authorization: Bearer $TOKENHUB_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{"model":"qwen/qwen3.8-max","max_tokens":128,"messages":[{"role":"user","content":"Write a one-sentence greeting."}]}'

Supported boundary

Text and image blocks, client function tools and tool results are translated. Document blocks are refused. Extended thinking and server tools are ignored, with the affected fields reported in X-TokenHub-Ignored-Fields.

Response and streaming

Read Messages content blocks, stop reason and usage. A streamed response uses Anthropic message/content-block events, not Chat choices or a DONE marker. Messages errors use the Anthropic {"type":"error","error":{"type":"…","message":"…"}} envelope.

Use the Claude Code setup for CLI configuration. For Claude Desktop, see the Claude Desktop guide.

Support and limits

Responses and Messages translate the fields they support to the selected model's route. A field the route does not take is refused with 400 or listed in X-TokenHub-Ignored-Fields.

Gateway validation, defaults and response forms are in the operation index and the OpenAPI schemas.

Error codes and recovery are in Errors and recovery. Keep the request or job ID from each response: it identifies the call in Activity and for support.