Messages
PreviewAnthropic-compatible Messages API. Beta. Reference for API version next.
On this page
Create a message (Anthropic-compatible)
/api/v1/llm/v1/messages BetaBeta. Anthropic Messages wire format over the same gateway as chat completions, so scopes (llm:access or llm:chat), rate limits, the credit check and Idempotency-Key behave identically. Point an Anthropic SDK at the base URL https://api.breachline.io/api/v1/llm with a BreachLine API key in x-api-key. Server tools, mcp_servers, container and URL or file document sources are refused with 400 rather than silently dropped. temperature and top_p accept 0 to 1. top_k, cache_control, service_tier and context_management are accepted and ignored. The anthropic-version header is accepted and not used.
Authentication
- API key in x-api-key
- API key or session token in Authorization: Bearer
Headers
Idempotency-KeystringRun this exact request at most once in 24 hours. A replay with the same key and the same body, from the same organization, user and API key, is refused with
409before any model call. See the Idempotency guide.- Minimum length
1
anthropic-versionstringAccepted for SDK compatibility. Not used.
- Examples
2023-06-01
Request body
modelstring Required- Examples
nebula-4.5- Maximum length
256
max_tokensinteger Required- Minimum
1
messagesarray of objects Requireduserandassistantturns with text, image (base64 or URL), document (base64 PDF, text or content), thinking,tool_useandtool_resultblocks.- Minimum items
1
systemstring or array of objectsstop_sequencesarray of strings- Maximum items
16
streamboolean- Default
false
temperaturenumber- Minimum
0- Maximum
1
top_pnumber- Minimum
0- Maximum
1
top_kintegerAccepted and ignored.
toolsarray of objectsCustom tools with
name,descriptionandinput_schema. Server tools are refused.- Maximum items
512
tool_choiceobjectauto,any,tool(withname) ornone;disable_parallel_tool_useis honoured.thinkingobject{ "type": "enabled" | "adaptive" | "disabled", "budget_tokens"?: int, "display"?: "summarized" | "omitted" }output_configobjecteffort(low, medium, high, xhigh, max) andformat({ "type": "json_schema", "schema": { … } }).metadataobject
Responses
200An Anthropicmessage, or withstream: trueatext/event-streamofmessage_start,content_block_start,content_block_delta,content_block_stop,message_delta,message_stopandpingevents. Usage follows the Anthropic convention:input_tokensexcludes cache reads and writes, which are reported separately.Body (application/json)
idstringtypestring- Always
message
rolestring- Always
assistant
modelstringcontentarray of objectstext,thinkingandtool_useblocks.stop_reasonstring- One of
end_turnmax_tokensstop_sequencetool_userefusal
stop_sequencestring or nullusageobject4 fields in
usageinput_tokensintegeroutput_tokensintegercache_creation_input_tokensintegercache_read_input_tokensinteger
400Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
401Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
402Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
403Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
409Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
429Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
503Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
Example
curl -X POST "https://api.breachline.io/api/v1/llm/v1/messages" \
-H "x-api-key: $BREACHLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nebula-4.5",
"max_tokens": 1024,
"system": "You are a concise security assistant.",
"messages": [
{
"role": "user",
"content": "Summarise the risk of a missing Content-Security-Policy header."
}
]
}'
{
"id": "string",
"type": "message",
"role": "assistant",
"model": "string",
"content": [
{}
],
"stop_reason": "end_turn",
"stop_sequence": "string",
"usage": {
"input_tokens": 0,
"output_tokens": 0,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0
}
}
Count tokens (estimate)
/api/v1/llm/v1/messages/count_tokens BetaBeta. Returns an estimate of about 4 characters per token over the translated request: requests are routed across engines with different tokenizers, so there is no single exact count. No model runs and nothing is charged, but the call is rate limited like chat and the body is capped at 4 MiB (413 above that).
Authentication
- API key in x-api-key
- API key or session token in Authorization: Bearer
Request body
modelstring Required- Examples
nebula-4.5- Maximum length
256
max_tokensinteger Required- Minimum
1
messagesarray of objects Requireduserandassistantturns with text, image (base64 or URL), document (base64 PDF, text or content), thinking,tool_useandtool_resultblocks.- Minimum items
1
systemstring or array of objectsstop_sequencesarray of strings- Maximum items
16
streamboolean- Default
false
temperaturenumber- Minimum
0- Maximum
1
top_pnumber- Minimum
0- Maximum
1
top_kintegerAccepted and ignored.
toolsarray of objectsCustom tools with
name,descriptionandinput_schema. Server tools are refused.- Maximum items
512
tool_choiceobjectauto,any,tool(withname) ornone;disable_parallel_tool_useis honoured.thinkingobject{ "type": "enabled" | "adaptive" | "disabled", "budget_tokens"?: int, "display"?: "summarized" | "omitted" }output_configobjecteffort(low, medium, high, xhigh, max) andformat({ "type": "json_schema", "schema": { … } }).metadataobject
Responses
200The estimate.Body (application/json)
input_tokensinteger- Minimum
1
400Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
403Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
413Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
429Anthropic error envelope with the same HTTP status.Retry-AfterandX-Request-IDare passed through, andx-should-retry: falseis set when a retry cannot succeed (402,409). An over-long prompt starts its message withprompt is too longso clients that compact on overflow can recover.Body (application/json)
typestring- Always
error
errorobject2 fields in
errortypestring- One of
invalid_request_errorauthentication_errorbilling_errorpermission_errornot_found_errorrequest_too_largerate_limit_erroroverloaded_errorapi_error
messagestring
Example
curl -X POST "https://api.breachline.io/api/v1/llm/v1/messages/count_tokens" \
-H "x-api-key: $BREACHLINE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nebula-4.5",
"max_tokens": 1,
"messages": [
{}
]
}'
{
"input_tokens": 1
}