Messages
POST /v1/messages
POST
https://api.topbilling.in/v1/messagesscope chat:writeCreates 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
modelstringrequiredA Top Billing model id that supports the Anthropic-compatible API.
max_tokensintegerrequiredUpper bound on generated tokens; sizes the reservation.
messagesarrayrequiredtext, image, tool_use and tool_result blocks.
systemstring | arrayA string or block array (with
cache_control).tools / tool_choicearray / objectOn models with
tool_calling.streambooleanServer-sent events in the Anthropic event format.
stop_sequencesarrayStop sequences.
temperature · top_p · top_knumberSampling controls.
metadata.user_idstringYour end-user identifier.
thinkingobjectOn 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
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
{
"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.