> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stateset.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Anthropic-compatible Messages endpoint backed by the recursive NSR solver.

> **Required scope:** write

**Required scope:** `write`

### Request body

`object`

<ParamField body="model" type="string">
  Model identifier (e.g. `claude-3-5-sonnet`, or an `nsr-v2-*` alias). Used to select the NSR solver mode.
</ParamField>

<ParamField body="messages" type="object[]" required>
  Conversation turns.
</ParamField>

<ParamField body="system" type="string">
  Optional top-level system prompt (string or array of text blocks).
</ParamField>

<ParamField body="max_tokens" type="integer">
  Maximum tokens to generate; honored as a truncation budget on the generated text.
</ParamField>

<ParamField body="tools" type="object[]">
  Tool definitions (Anthropic shape: `&#123;name, description, input_schema&#125;`).
</ParamField>

<ParamField body="tool_choice" type="object">
  Tool selection: `&#123;'type': 'auto'|'any'|'tool', 'name'?&#125;`.
</ParamField>

<ParamField body="stop_sequences" type="string[]">
  If the generated text contains one, generation reports `stop_reason = 'stop_sequence'`.
</ParamField>

<ParamField body="temperature" type="number">
  Accepted for compatibility; the solver is deterministic so it does not affect output.
</ParamField>

<ParamField body="top_p" type="number">
  Accepted for compatibility.
</ParamField>

<ParamField body="top_k" type="integer">
  Accepted for compatibility.
</ParamField>

<ParamField body="stream" type="boolean">
  When true, emit the Anthropic SSE event stream.
</ParamField>

<ParamField body="metadata" type="object">
  Opaque request metadata (passed through, not interpreted).
</ParamField>

<ParamField body="hydrate_org_context" type="boolean">
  When false, skip org knowledge-base hydration.
</ParamField>

<ParamField body="kb_limits" type="object">
  Optional per-request hydration limits.
</ParamField>

<ParamField body="facts" type="object[]">
  Request-scoped facts injected into the working set.
</ParamField>

<ParamField body="rules" type="object[]">
  Request-scoped rules injected into the working set.
</ParamField>

<ParamField body="max_depth" type="integer">
  Recursion depth override.
</ParamField>

<ParamField body="max_iterations" type="integer">
  Iteration budget override.
</ParamField>

<ParamField body="confidence_threshold" type="number">
  Confidence threshold override.
</ParamField>

<ParamField body="include_nsr_metadata" type="boolean">
  When true, attach the full recursive payload under `x_nsr`.
</ParamField>

### Response

`object`

<ResponseField name="id" type="string" required />

<ResponseField name="type" type="string" required />

<ResponseField name="role" type="string" required />

<ResponseField name="content" type="object[]" required>
  <Expandable title="content">
    <ResponseField name="type" type="string" required />

    <ResponseField name="text" type="string">
      Present on `text` blocks.
    </ResponseField>

    <ResponseField name="id" type="string">
      Present on `tool_use` blocks.
    </ResponseField>

    <ResponseField name="name" type="string">
      Present on `tool_use` blocks.
    </ResponseField>

    <ResponseField name="input" type="object">
      Present on `tool_use` blocks.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="model" type="string" required />

<ResponseField name="stop_reason" type="string" required />

<ResponseField name="stop_sequence" type="string" required />

<ResponseField name="usage" type="object" required>
  <Expandable title="usage">
    <ResponseField name="input_tokens" type="integer" required />

    <ResponseField name="output_tokens" type="integer" required />
  </Expandable>
</ResponseField>

<ResponseField name="x_nsr" type="object">
  Full recursive NSR payload. Present only when `include_nsr_metadata` is true.
</ResponseField>

### Status codes

| Code  | Meaning                                                                                              |
| ----- | ---------------------------------------------------------------------------------------------------- |
| `200` | Anthropic-compatible message. With `stream: true` the body is an Anthropic SSE event stream instead. |
| `401` | Unauthorized — missing or invalid credentials                                                        |
| `403` | Forbidden — the key/token lacks the required scope                                                   |
| `429` | Rate limited — see Retry-After / X-RateLimit-Reset                                                   |

<RequestExample>
  ```bash cURL theme={null}
  curl --request POST \
    --url 'https://api.nsr.stateset.com/v1/messages' \
    --header "X-API-Key: $STATESET_NSR_API_KEY" \
    --header 'Content-Type: application/json' \
    --data '{
    "model": "string",
    "messages": [
      {
        "role": "string",
        "content": "Two-person tent, green — replacement for damaged pole set."
      }
    ],
    "system": "string",
    "max_tokens": 1,
    "tools": [
      {}
    ],
    "tool_choice": {
      "type": "standard",
      "name": "Two-Person Tent"
    },
    "stop_sequences": [
      "string"
    ],
    "temperature": 1.5,
    "top_p": 1.5,
    "top_k": 1,
    "stream": true,
    "metadata": {},
    "hydrate_org_context": true,
    "kb_limits": {},
    "facts": [
      {}
    ],
    "rules": [
      {}
    ],
    "max_depth": 1,
    "max_iterations": 8,
    "confidence_threshold": 7.5,
    "include_nsr_metadata": true
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
    "type": "standard",
    "role": "string",
    "content": [
      {
        "type": "standard",
        "text": "Two-person tent, green — replacement for damaged pole set.",
        "id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
        "name": "Two-Person Tent",
        "input": {}
      }
    ],
    "model": "string",
    "stop_reason": "string",
    "stop_sequence": "string",
    "usage": {
      "input_tokens": 1,
      "output_tokens": 1
    },
    "x_nsr": {}
  }
  ```
</ResponseExample>
