| English | 中文版 |
Version: 0.1
Date: 2026-04-12
The NPS Token Budget mechanism lets an agent declare a maximum token-consumption cap for a given request. A node uses this cap to trim response fields, limit the number of records returned, or reject over-budget requests.
To address the differences in how each LLM counts tokens, NPS introduces NPS Token (NPT) as a standardized unit of measure.
NPT is the standard token-accounting unit inside the NPS protocol suite. Native tokens from each LLM are converted to NPT through exchange rates.
When the tokenizer cannot be determined, use the following formula as a default estimate:
NPT = ceil(UTF-8_bytes / 4)
This formula reflects the average behavior of mainstream LLM tokenizers (≈ 4 bytes/token for English, ≈ 3 bytes/token for Chinese) and acts as the most conservative baseline.
Node implementations SHOULD ship with built-in NPT exchange rates for common models:
| Model family | Tokenizer | 1 native token ≈ NPT | Notes |
|---|---|---|---|
| OpenAI GPT-4 / GPT-4o | cl100k_base |
1.0 | Reference baseline |
| Anthropic Claude | Claude tokenizer | 1.05 | Slightly higher than GPT-4 |
| Google Gemini | SentencePiece | 0.95 | Slightly lower than GPT-4 |
| Meta LLaMA 3 | llama3-tokenizer |
1.02 | Near baseline |
| Mistral | SentencePiece | 0.98 | Near baseline |
| Default (unknown model) | UTF-8 / 4 | 1.0 | Fallback |
The table is maintained with NPS version updates. Implementations MAY override the built-in rates via configuration.
When an agent issues a request, the node resolves the tokenizer in this order:
1. Explicit declaration by the agent (X-NWP-Tokenizer header)
↓ not declared
2. Auto-match from agent configuration / IdentFrame
↓ match failed
3. Default calculation (UTF-8 bytes / 4)
The agent declares its tokenizer in the request header:
X-NWP-Tokenizer: cl100k_base
Node MUST recognize the declared tokenizer and use the corresponding algorithm to count tokens. If the node does not support that tokenizer, it SHOULD fall back to auto-match.
The node infers the agent’s model family from IdentFrame metadata:
IdentFrame.metadata.model_family: e.g. "openai/gpt-4o", "anthropic/claude-4"IdentFrame.metadata.tokenizer: e.g. "cl100k_base"When either field is present in the IdentFrame, the node uses the matching tokenizer.
When the tokenizer cannot be determined, use ceil(UTF-8_bytes / 4) to compute NPT.
| Header | Required | Description |
|---|---|---|
X-NWP-Budget |
optional | Maximum NPT budget (uint32) |
X-NWP-Tokenizer |
optional | Tokenizer identifier used by the agent |
| Header | Description |
|---|---|
X-NWP-Tokens |
Actual NPT consumed by this response |
X-NWP-Tokens-Native |
Native token consumption for this response (when the tokenizer is known) |
X-NWP-Tokenizer-Used |
Tokenizer identifier actually used by the node |
When the response would exceed X-NWP-Budget:
NWP-BUDGET-EXCEEDED error.The token_est field in a CapsFrame is in NPT:
{
"frame": "0x04",
"anchor_ref": "sha256:...",
"count": 2,
"data": [...],
"token_est": 180,
"tokenizer_used": "cl100k_base"
}
cl100k_base (GPT-4 family) tokenizer built in.Copyright: LabAcacia / INNO LOTUS PTY LTD · Apache 2.0