curl --silent --show-error --fail-with-body --request POST \
--url 'https://api.nsr.stateset.com/v1/messages/count_tokens' \
--header "X-API-Key: $STATESET_NSR_API_KEY" \
--header "Idempotency-Key: ${IDEMPOTENCY_KEY:?Set a unique key for this operation; preserve it on retries}" \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": "Check the status of my order."
}
]
}'
{
"input_tokens": 1
}
Anthropic-compatible token counting (POST /v1/messages/count_tokens).
Estimate input tokens using the same request parser as the message endpoint. This count is an estimate, not a model generation or proof decision…
POST
/
v1
/
messages
/
count_tokens
curl --silent --show-error --fail-with-body --request POST \
--url 'https://api.nsr.stateset.com/v1/messages/count_tokens' \
--header "X-API-Key: $STATESET_NSR_API_KEY" \
--header "Idempotency-Key: ${IDEMPOTENCY_KEY:?Set a unique key for this operation; preserve it on retries}" \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": "Check the status of my order."
}
]
}'
{
"input_tokens": 1
}
Estimate input tokens using the same request parser as the message endpoint. This count is an estimate, not a model generation or proof decision. The example uses a plain-text conversation; use the deployed message contract for complex content blocks.
Headers
string
Retry-safe key. Replaying the same key with the same body returns the original response and sets
idempotent-replayed; a different body with the same key is rejected 422. Use it so a retried write cannot double-execute or double-bill.Request body
object
object[]
required
string,null
Model identifier accepted by your deployment.
string | object[],null
Show system
Show system
Show Option 1: string
Show Option 1: string
Value of type
string.Show Option 2: object[]
Show Option 2: object[]
Value of type
object[].integer,null
Minimum:
0.any[]
Default:
[].string[]
Default:
[].object
Opaque JSON metadata; defaults to null.
number,null
number,null
number,null
integer,null
Minimum:
0.integer,null
Minimum:
0.integer,null
Minimum:
0.boolean,null
boolean,null
boolean,null
RecursiveChatKbLimits,null
RecursiveChatFactInput[],null
Show RecursiveChatFactInput
Show RecursiveChatFactInput
number (double)
RecursiveChatPredicateInput
required
Show RecursiveChatPredicateInput
Show RecursiveChatPredicateInput
Arg[]
required
string
required
boolean
Negation-as-failure for a rule CONDITION:
not fraud_flagged(?o, ?r). Meaningful only on rule conditions (ignored on facts and conclusions). Defaulted and skipped-when-false so existing payloads are unchanged. Without this the negation was silently dropped and the condition read as POSITIVE — a fraud-flagged subject slipped a not fraud_flagged guard.string
RecursiveChatRuleInput[],null
Show RecursiveChatRuleInput
Show RecursiveChatRuleInput
string
any[]
string
object
boolean
string
RecursiveChatPredicateInput[]
required
Show RecursiveChatPredicateInput
Show RecursiveChatPredicateInput
Arg[]
required
string
required
boolean
Negation-as-failure for a rule CONDITION:
not fraud_flagged(?o, ?r). Meaningful only on rule conditions (ignored on facts and conclusions). Defaulted and skipped-when-false so existing payloads are unchanged. Without this the negation was silently dropped and the condition read as POSITIVE — a fraud-flagged subject slipped a not fraud_flagged guard.string
required
integer (int32)
RecursiveChatPredicateInput[]
required
Show RecursiveChatPredicateInput
Show RecursiveChatPredicateInput
Arg[]
required
string
required
boolean
Negation-as-failure for a rule CONDITION:
not fraud_flagged(?o, ?r). Meaningful only on rule conditions (ignored on facts and conclusions). Defaulted and skipped-when-false so existing payloads are unchanged. Without this the negation was silently dropped and the condition read as POSITIVE — a fraud-flagged subject slipped a not fraud_flagged guard.Response
CountTokensResponse
integer (int32)
required
Minimum:
0.Status codes
| Code | Meaning |
|---|---|
200 | Estimated input token count |
401 | Unauthorized — missing or invalid credentials |
403 | Forbidden — the key/token lacks the required scope |
429 | Rate limited — see Retry-After / X-RateLimit-Reset |
Using this contract
Read the source OpenAPI document for declared schemas and alternatives. This page also includes documented corrections from the spec overlays. Example IDs and values are illustrative; replace them with records from your workspace.curl --silent --show-error --fail-with-body --request POST \
--url 'https://api.nsr.stateset.com/v1/messages/count_tokens' \
--header "X-API-Key: $STATESET_NSR_API_KEY" \
--header "Idempotency-Key: ${IDEMPOTENCY_KEY:?Set a unique key for this operation; preserve it on retries}" \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": "Check the status of my order."
}
]
}'
{
"input_tokens": 1
}
Last modified on September 21, 2026