# LLM Context Window Fit Checker

> LLM Context Window Fit Checker is a paid API for AI agents from llm-cost-calc.x402tookit.com, paid per call via x402, $0.02/call, status unknown (last checked 2026-10-30).

Checks whether a prompt fits within a model's context window (with output reserve and safety headroom) and estimates how many additional chat turns remain.

## Facts

- Endpoint: GET https://llm-cost-calc.x402tookit.com/context-fit?utm_source=zero.xyz
- Price: $0.02/call
- Payment: x402
- Status: unknown
- Last checked: 2026-10-30
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/llm-context-window-fit-checker-764c3f6a
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_OnuUiFlwF1X8TBFOB4W2h

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability llm-context-window-fit-checker-764c3f6a
```

Example prompt: My prompt is currently 45,000 tokens and I'm using a model with a 128,000-token context window — can you check if it fits with 2,048 tokens reserved for the reply, 5% safety headroom, and tell me how many more turns I can fit assuming 800 tokens per turn?

## When to prefer this

Use this endpoint when you need a fast, deterministic computation of whether a prompt fits a model's context window without calling the model itself. Ideal for pre-flight checks before expensive API calls, agent loop capacity planning, or building guardrails that trim or paginate prompts before overflow. Prefer this over ad-hoc token math when you need structured output including turns remaining, trim advice, and safety headroom.

## Known failure modes

- Missing required parameters (contextWindow or promptTokens) returns a validation error
- safetyPercent outside 0–50 range may be rejected or clamped
- Very large token values that are implausible may produce unexpected results
- No model-specific validation — caller must supply correct context window size manually

## How this service works

Check whether a prompt fits a context window with output reserve, and how many more chat turns fit.

## Output

Returns a verdict (fits/does not fit), percentage of context used, tokens free, tokens reserved for output, safety headroom in tokens, how many tokens would need to be trimmed if over limit, estimated turns remaining at the given tokens-per-turn rate, and a human-readable summary of the context situation.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "object",
   "required": [
    "type",
    "method"
   ],
   "properties": {
    "type": {
     "type": "string",
     "const": "http"
    },
    "method": {
     "enum": [
      "GET"
     ],
     "type": "string"
    },
    "queryParams": {
     "type": "object",
     "required": [
      "contextWindow",
      "promptTokens"
     ],
     "properties": {
      "promptTokens": {
       "type": "number",
       "description": "Tokens already in the prompt (system + history + new input)"
      },
      "contextWindow": {
       "type": "number",
       "description": "Model context window in tokens"
      },
      "safetyPercent": {
       "type": "number",
       "description": "Extra headroom percent kept free, 0 to 50 (default 5)"
      },
      "tokensPerTurn": {
       "type": "number",
       "description": "Average tokens a new user + assistant turn adds, to count remaining turns"
      },
      "maxOutputTokens": {
       "type": "number",
       "description": "Tokens reserved for the reply (default 1024)"
      }
     }
    }
   },
   "additionalProperties": false
  },
  "output": {
   "type": "object",
   "required": [
    "type"
   ],
   "properties": {
    "type": {
     "type": "string"
    },
    "example": {
     "type": "object",
     "properties": {
      "asOf": {
       "type": [
        "null",
        "string"
       ]
      },
      "source": {
       "type": [
        "null",
        "string"
       ]
      },
      "reasons": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "summary": {
       "type": [
        "null",
        "string"
       ]
      },
      "verdict": {
       "type": [
        "null",
        "string"
       ]
      },
      "degraded": {
       "type": [
        "boolean",
        "null"
       ]
      },
      "disclaimer": {
       "type": [
        "null",
        "string"
       ]
      },
      "notChecked": {
       "type": [
        "array",
        "null"
       ],
       "items": {
        "type": "string"
       }
      },
      "tokensFree": {
       "type": [
        "null",
        "number"
       ]
      },
      "percentUsed": {
       "type": [
        "null",
        "number"
       ]
      },
      "promptTokens": {
       "type": [
        "null",
        "number"
    
… (truncated)
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/llm-context-window-fit-checker-764c3f6a/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from llm-cost-calc.x402tookit.com](https://www.zero.xyz/host/llm-cost-calc.x402tookit.com/llms.txt)
