For the complete documentation index, see llms.txt. This page is also available as Markdown.

Messages

Anthropic-native Messages API for prompt-cache-preserving passthrough.

Create a message (Anthropic-native)

post

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.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Header parameters
X-Session-Idstring · max: 256Optional

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.

X-Claude-Code-Session-Idstring · max: 256Optional

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.

thread-idstring · max: 256Optional

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.

session-idstring · max: 256Optional

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.

Body

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).

modelstringRequired

Model identifier or alias resolved against the company's configured models. Must resolve to an Anthropic-provider model.

systemone ofOptional

System prompt as a single string or as an array of text blocks (each may carry cache_control).

stringOptional
or
max_tokensintegerRequired

Maximum output tokens. Set to 0 to warm the prompt cache without generating output.

temperaturenumber · max: 1 · nullableOptional

Sampling temperature. Note: the newest Claude models (Sonnet 4.6+/5) reject temperature, top_p, and top_k as deprecated.

top_pnumber · nullableOptional

Nucleus sampling. Rejected as deprecated by the newest Claude models.

top_kinteger · nullableOptional

Top-k sampling. Rejected as deprecated by the newest Claude models.

stop_sequencesstring[] · nullableOptional
streamboolean · nullableOptionalDefault: false
tool_choiceone of · nullableOptional

Controls how the model selects tools.

or
or
or
thinkingone of · nullableOptional

Extended thinking configuration.

or
or
service_tierstring · enum · nullableOptional

Anthropic API service tier. Note: models hosted on Vertex AI (currently all Claude models on the platform) reject this parameter.

Possible values:
containerstring · nullableOptional

Container reference for code-execution tools. Note: models hosted on Vertex AI (currently all Claude models on the platform) reject this parameter.

Responses
200

OK

post/v1/messages
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'?"
    }
  ]
}
200

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"
  }
}

Count message tokens (Anthropic-native)

post

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.

Authorizations
AuthorizationstringRequired
Bearer authentication header of the form Bearer <token>.
Query parameters
betastringOptional

Marks the request as using the Anthropic beta API surface. Claude Code sends beta=true; forwarded upstream unchanged.

Body

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.

modelstringRequired

Model identifier or alias resolved against the company's configured models. Must resolve to an Anthropic-provider model.

systemone ofOptional

System prompt as a single string or as an array of text blocks (each may carry cache_control).

stringOptional
or
tool_choiceone of · nullableOptional

Controls how the model selects tools.

or
or
or
thinkingone of · nullableOptional

Extended thinking configuration.

or
or
Responses
200

OK

application/json

Number of input tokens the supplied request would consume.

input_tokensintegerRequired

Estimated total input tokens. The count is an estimate and is not billed.

post/v1/messages/count_tokens
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'?"
    }
  ]
}
200

OK

{
  "input_tokens": 14
}

Last updated