{"uid":"cap_OnuUiFlwF1X8TBFOB4W2h","slug":"llm-context-window-fit-checker-764c3f6a","name":"LLM Context Window Fit Checker","description":"Check whether a prompt fits a context window with output reserve, and how many more chat turns fit.","url":"https://llm-cost-calc.x402tookit.com/context-fit?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"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"]},"tokensToTrim":{"type":["null","number"]},"contextWindow":{"type":["null","number"]},"outputReserve":{"type":["null","number"]},"safetyHeadroom":{"type":["null","number"]},"turnsRemaining":{"type":["null","number"]}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_DNvsvsQ-ARAemYHK-bPoH","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Pre-flight context check for long conversation","prompt":"I've got a conversation history that's grown to 60,000 tokens and my model has a 128k context window. Check if it still fits with 1,024 tokens reserved for the output and the default 5% safety margin, and tell me how many more back-and-forth turns I can squeeze in at about 500 tokens each."},{"title":"Detecting prompt overflow before API call","prompt":"Before I send this request, I want to know if my 95,000-token prompt will fit inside a 100k context window with 2,048 tokens saved for the reply and 10% safety headroom — and if not, how many tokens I need to cut."},{"title":"Capacity planning for multi-turn agent loop","prompt":"I'm running an agent loop where each turn adds roughly 1,200 tokens. My current prompt is 30,000 tokens in a 32k context window with 512 tokens reserved for output — how many more turns can I run before I run out of space?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-30T00:35:02.647Z","isFirstParty":false,"canonicalSlug":"llm-context-window-fit-checker-764c3f6a"}