Messages

POST /v1/messages

POSThttps://api.topbilling.in/v1/messagesscope chat:write

Creates a model response in the Anthropic Messages format. Send anthropic-version: 2023-06-01.

Authentication

Send your key as Authorization: Bearer tb_… or x-api-key: tb_…. See Authentication.

Parameters

modelstringrequired
A Top Billing model id that supports the Anthropic-compatible API.
max_tokensintegerrequired
Upper bound on generated tokens; sizes the reservation.
messagesarrayrequired
text, image, tool_use and tool_result blocks.
systemstring | array
A string or block array (with cache_control).
tools / tool_choicearray / object
On models with tool_calling.
streamboolean
Server-sent events in the Anthropic event format.
stop_sequencesarray
Stop sequences.
temperature · top_p · top_knumber
Sampling controls.
metadata.user_idstring
Your end-user identifier.
thinkingobject
On reasoning models.

On the translated lane, unsupported semantic fields return 400 with a capability_rejected: token; advisory fields are dropped and listed in tb-dropped-hints. See Messages.

Request

shell
curl https://api.topbilling.in/v1/messages \
  -H "x-api-key: $TB_API_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
  -d '{"model":"<model-id>","max_tokens":256,"messages":[{"role":"user","content":"Hello"}]}'

Response

json
{
  "id": "msg_...",
  "type": "message",
  "role": "assistant",
  "content": [{"type": "text", "text": "..."}],
  "stop_reason": "end_turn",
  "usage": {"input_tokens": 18, "output_tokens": 24, "cache_read_input_tokens": 0, "cache_creation_input_tokens": 0}
}

Count tokens

POST /v1/messages/count_tokens takes the same body without max_tokens and returns input_tokens, on models with token_counting.

Errors

Anthropic error shapes (error.type) with the same meanings as in Errors.