Context Window Fitter
context.fit_window
Overview
Before you call a model, we assemble your prefix, items, separator, and suffix into one canonical string and count it once with the tokenizer you choose (cl100k_base or o200k_base). We tell you whether it fits in windowTokens minus reservedOutputTokens. requiredInputTokens is the authoritative assembled count — per-item counts are informational only and must not be summed. We measure the text you send; we do not add provider chat or tool framing unless you include it in prefix, suffix, or items.
Summing per-item token counts is wrong for byte-pair encoders. We count the exact assembled string so you know before you spend on a model call.
Reliability
VERIFIABLE — requiredInputTokens is the exact count of the assembled rendering on the pinned tokenizer (tokenizer_version is returned). Counts can shift when the tokenizer library upgrades; retry after upgrading your budget assumptions. Per-item independentTokenCount values are informational and must not be summed. Input validation errors (not retryable): unsupported tokenizer, item or affix too large, or assembled rendering would exceed 2000000 chars — reduce input or split the assembly.
Context footprint
Up to 10000 items, 1M chars per item, 2M chars total assembled rendering. A successful call costs 1 execution credit.
When to use it
Before a model call, when you have the text you plan to send and a window size.
When you need to pick or trim items — use context.pack_chunks or truncate first.
Powered by JTokkit, an open-source tokenizer reproducing OpenAI tiktoken encodings, with Squillify canonical-rendering counting on top.
Scope
Non-goals
- Does not drop, reorder, or truncate items
- Does not model provider message framing
- Does not tokenize non-OpenAI encodings
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
How we handle your data
What this means
This skill may receive sensitive content, but it does not target sensitive data and returns only a structured non-sensitive result.
Squillify guarantees
- Runs inside Squillify
- This skill runs inside Squillify.
- Payloads are not sent to an external service by this skill.
- Squillify does not permanently store submitted payloads.
- Telemetry records metadata only, not submitted content.
- Submitted payloads are not used for training.
- Submitted payloads are not reviewed by humans.
- This skill does not target sensitive data.
- The response does not contain submitted content.
Your responsibility
Squillify does not determine whether submitted content is sensitive. Your application is responsible for deciding what data it is allowed to submit. Your application is responsible for securing the response.
Input schema
| Field | Type | Required | Description |
|---|---|---|---|
| items | array | Yes | From 0 through 10,000 context items assembled in caller order. |
| windowTokens | integer | Yes | Total token-window capacity. |
| reservedOutputTokens | integer | No | Output reservation; omit it for 0. |
| tokenizer | string | No | Tokenizer encoding; omit it for cl100k_base. |
| prefix | string | No | Canonical prefix; omit it for empty text. |
| suffix | string | No | Canonical suffix; omit it for empty text. |
| separator | string | No | Canonical separator; omit it for empty text. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| skill | string | Yes | Stable published skill key for this answer. |
| fits | boolean | Yes | Whether the canonical rendering fits. |
| tokenizer | string | Yes | Applied tokenizer encoding. |
| tokenizer_version | string | Yes | Pinned tokenizer library version. |
| windowTokens | integer | Yes | Bounded token count for windowTokens. |
| reservedOutputTokens | integer | Yes | Bounded token count for reservedOutputTokens. |
| availableInputTokens | integer | Yes | Bounded token count for availableInputTokens. |
| requiredInputTokens | integer | Yes | Bounded token count for requiredInputTokens. |
| overflowTokens | integer | Yes | Bounded token count for overflowTokens. |
| items | array | Yes | One informational count per input item, each a closed id with independentTokenCount. |
| warnings | array | Yes | From 0 through 10 safe advisory strings; currently always empty because fit has none. |
API contract
POST /v1/executecurl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"context.fit_window","input":{"items":[{"id":"system","text":"You are helpful."},{"id":"user","text":"Hi"}],"windowTokens":128000,"reservedOutputTokens":8000,"separator":"\n\n","tokenizer":"o200k_base"}}'import { Squillify } from "@squillify/sdk";
const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });
const { output } = await sq.execute("context.fit_window", {"separator":"\n\n","items":[{"id":"system","text":"You are a helpful assistant."},{"id":"user","text":"Summarize the attached document."}],"reservedOutputTokens":8000,"windowTokens":128000,"tokenizer":"o200k_base"});Errors
| Code | HTTP | Retryable | Description |
|---|---|---|---|
| VALIDATION_ERROR | 400 | No | The request payload failed schema validation. |
| UNAUTHORIZED | 401 | No | Missing or invalid API key. |
| SKILL_NOT_ACCESSIBLE | 403 | No | The API key is not granted access to this skill. |
| SKILL_NOT_AVAILABLE_FOR_PLAN | 403 | No | This skill is not included in your current plan. |
| PLAN_ELIGIBILITY_UNAVAILABLE | 503 | Yes | Plan eligibility could not be decided. Retry after backoff. |
| SKILL_NOT_FOUND | 404 | No | The requested skill or version does not exist. |
| TENANT_RATE_LIMITED | 429 | Yes | Request rate limit exceeded. Retry after backoff. |
| QUOTA_EXCEEDED | 429 | Yes | Plan quota exhausted. Retryable once the quota period resets. |
| EXECUTION_TIMEOUT | 504 | Yes | Execution exceeded the allowed time budget. |
Other limits
| Limit | Value |
|---|---|
| Recommended inline bytes | 32 KiB |
Limitations
- Does not drop, reorder, or truncate items
- Does not model provider message framing
- Does not tokenize non-OpenAI encodings
- Choosing which items to keep
- Summing per-item token counts
How to call
POST /v1/execute (requires authentication)
{
"skillKey": "context.fit_window",
"input": {
"separator": "\n\n",
"items": [
{
"id": "system",
"text": "You are a helpful assistant."
},
{
"id": "user",
"text": "Summarize the attached document."
}
],
"reservedOutputTokens": 8000,
"windowTokens": 128000,
"tokenizer": "o200k_base"
}
}Examples
Assembly fits with output reserved
{
"separator": "\n\n",
"items": [
{
"id": "system",
"text": "You are a helpful assistant."
},
{
"id": "user",
"text": "Summarize the attached document."
}
],
"reservedOutputTokens": 8000,
"windowTokens": 128000,
"tokenizer": "o200k_base"
}{
"windowTokens": 128000,
"requiredInputTokens": 13,
"reservedOutputTokens": 8000,
"overflowTokens": 0,
"availableInputTokens": 120000,
"fits": true,
"tokenizer": "o200k_base",
"tokenizer_version": "jtokkit-1.1.0",
"warnings": [],
"items": [
{
"id": "system",
"independentTokenCount": 6
},
{
"id": "user",
"independentTokenCount": 7
}
],
"skill": "context.fit_window"
}Assembly exceeds a tight window
{
"separator": "\n\n",
"items": [
{
"id": "system",
"text": "You are a helpful assistant."
},
{
"id": "user",
"text": "Summarize the attached document."
}
],
"reservedOutputTokens": 2,
"windowTokens": 10,
"tokenizer": "o200k_base"
}{
"windowTokens": 10,
"requiredInputTokens": 13,
"reservedOutputTokens": 2,
"overflowTokens": 5,
"availableInputTokens": 8,
"fits": false,
"tokenizer": "o200k_base",
"tokenizer_version": "jtokkit-1.1.0",
"warnings": [],
"items": [
{
"id": "system",
"independentTokenCount": 6
},
{
"id": "user",
"independentTokenCount": 7
}
],
"skill": "context.fit_window"
}Recommended use cases
- Pre-flight check before an expensive model call
- Reserve output tokens and verify inputs still fit
- Measure overflow before packing or truncating
Avoid for
- Choosing which items to keep
- Summing per-item token counts
Related skills
Composable with
Safety & privacy
- Runs without calling any external service.
- Your payloads are never stored permanently.
- Telemetry captures metadata only — never your payload contents.
- We never train models on your payloads.
- No human reviews your payloads.