Messages
Anthropic-native Messages API for prompt-cache-preserving passthrough.
Anthropic-native Messages API. Accepts requests in Anthropic's wire format and forwards them to the upstream Anthropic provider byte-for-byte, preserving native features such as cache_control for prompt caching. Use this endpoint when the client already speaks Anthropic — it avoids the OpenAI translation layer that silently strips cache_control.
Optional client-provided identifier for grouping requests into a session. Leading and
trailing whitespace is trimmed; blank values, values longer than 256 bytes, and values
with non-printable or non-ASCII characters are ignored. Takes precedence over
X-Claude-Code-Session-Id, session-id, and thread-id. When none of these headers has
a usable value, a session fingerprint is derived from the first message and the
authenticated company, user, and team identity, if usable message text is available. This
header does not load conversation history.
Alternative client-provided session identifier, supported for Claude Code clients. Used
only when X-Session-Id has no usable value. Takes precedence over session-id and
thread-id. Leading and trailing whitespace is trimmed; blank values, values longer than
256 bytes, and values with non-printable or non-ASCII characters are ignored. This header
does not load conversation history.
Alternative client-provided session identifier, supported for Codex clients. Used only
when none of X-Session-Id, X-Claude-Code-Session-Id, and session-id has a usable
value. Leading and trailing whitespace is trimmed; blank values, values longer than 256
bytes, and values with non-printable or non-ASCII characters are ignored. This header does
not load conversation history.
Alternative client-provided session identifier, supported for Codex clients, which send
one value for a root thread and all of its subagents. Used only when neither
X-Session-Id nor X-Claude-Code-Session-Id has a usable value. Takes precedence over
thread-id. Leading and trailing whitespace is trimmed; blank values, values longer than
256 bytes, and values with non-printable or non-ASCII characters are ignored. This header
does not load conversation history.
Anthropic-native Messages API request body. Forwarded byte-for-byte to the upstream
provider — cache_control markers are preserved exactly where the client placed them
(system blocks, message content blocks, tool definitions, top-level).
Model identifier or alias resolved against the company's configured models. Must resolve to an Anthropic-provider model.
System prompt as a single string or as an array of text blocks (each may carry cache_control).
Maximum output tokens. Set to 0 to warm the prompt cache without generating output.
Sampling temperature. Note: the newest Claude models (Sonnet 4.6+/5) reject temperature, top_p, and top_k as deprecated.
Nucleus sampling. Rejected as deprecated by the newest Claude models.
Top-k sampling. Rejected as deprecated by the newest Claude models.
falseControls how the model selects tools.
Extended thinking configuration.
Anthropic API service tier. Note: models hosted on Vertex AI (currently all Claude models on the platform) reject this parameter.
Container reference for code-execution tools. Note: models hosted on Vertex AI (currently all Claude models on the platform) reject this parameter.
OK
POST /v1/messages HTTP/1.1
Host: api.nexos.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 137
{
"model": "Claude Sonnet 5",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "how many letters 'r' are in the word 'strawberry'?"
}
]
}OK
{
"id": "text",
"type": "message",
"role": "assistant",
"model": "text",
"nexos_model_uuid": "text",
"nexos_model_name": "text",
"cost_savings": {
"baseline_cost": 1,
"charged_cost": 1,
"cache_optimization": 1,
"nexos_cache": 1
},
"content": [
{
"type": "text",
"text": "text",
"cache_control": {
"type": "ephemeral",
"ttl": "5m"
},
"citations": [
{
"type": "text",
"cited_text": "text",
"document_index": 1,
"document_title": "text",
"start_char_index": 1,
"end_char_index": 1,
"start_page_number": 1,
"end_page_number": 1,
"start_block_index": 1,
"end_block_index": 1
}
]
}
],
"stop_reason": "end_turn",
"stop_sequence": "text",
"stop_details": {
"type": "refusal",
"category": "text",
"explanation": "text"
},
"usage": {
"input_tokens": 1,
"output_tokens": 1,
"cache_creation_input_tokens": 1,
"cache_read_input_tokens": 1,
"cache_creation": {
"ephemeral_5m_input_tokens": 1,
"ephemeral_1h_input_tokens": 1
},
"output_tokens_details": {
"thinking_tokens": 1
},
"service_tier": "text",
"server_tool_use": {
"web_search_requests": 1
},
"nexos_credits_cost": 1
},
"container": {
"id": "text",
"expires_at": "2026-01-01T00:00:00.000Z"
}
}Anthropic-native token counting. Accepts the same structured inputs as /v1/messages and returns the number of input tokens without generating a response. Claude Code calls this as /v1/messages/count_tokens?beta=true to size its context window; when the endpoint is missing it falls back to a character-based estimate.
Marks the request as using the Anthropic beta API surface. Claude Code sends beta=true;
forwarded upstream unchanged.
Anthropic-native token counting request body. Accepts the same structured inputs as
/v1/messages — system, messages, tools, thinking — but no max_tokens, because no
output is generated. Forwarded byte-for-byte to the upstream provider.
Model identifier or alias resolved against the company's configured models. Must resolve to an Anthropic-provider model.
System prompt as a single string or as an array of text blocks (each may carry cache_control).
Controls how the model selects tools.
Extended thinking configuration.
OK
Number of input tokens the supplied request would consume.
Estimated total input tokens. The count is an estimate and is not billed.
POST /v1/messages/count_tokens HTTP/1.1
Host: api.nexos.ai
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 119
{
"model": "Claude Sonnet 5",
"messages": [
{
"role": "user",
"content": "how many letters 'r' are in the word 'strawberry'?"
}
]
}OK
{
"input_tokens": 14
}Last updated

