Skip to main content

Squillify development is paused indefinitely. Read why, and discover what this experiment achieved. Read the story

MicroSkills Reference

Context Window Fitter

context.fit_window

ProductionBounded custom (Class B)Deterministicverifiablefastv1.0.0
No network

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

Note
Checks whether assembled context text fits a token window minus an output reservation.

Non-goals

  • Does not drop, reorder, or truncate items
  • Does not model provider message framing
  • Does not tokenize non-OpenAI encodings

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

analysistext-processing

Cost & billing

Flat rate per invocation

MetercallsBillable onsuccessCost per call1 credit

File handling

Accepts file_refProduces file_refMax input1.9 MB

How we handle your data

Sensitive input, safe output
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.

Read the Microskill Data Handling Policy

Input schema

FieldTypeRequiredDescription
itemsarrayYesFrom 0 through 10,000 context items assembled in caller order.
windowTokensintegerYesTotal token-window capacity.
reservedOutputTokensintegerNoOutput reservation; omit it for 0.
tokenizerstringNoTokenizer encoding; omit it for cl100k_base.
prefixstringNoCanonical prefix; omit it for empty text.
suffixstringNoCanonical suffix; omit it for empty text.
separatorstringNoCanonical separator; omit it for empty text.

Output schema

FieldTypeRequiredDescription
skillstringYesStable published skill key for this answer.
fitsbooleanYesWhether the canonical rendering fits.
tokenizerstringYesApplied tokenizer encoding.
tokenizer_versionstringYesPinned tokenizer library version.
windowTokensintegerYesBounded token count for windowTokens.
reservedOutputTokensintegerYesBounded token count for reservedOutputTokens.
availableInputTokensintegerYesBounded token count for availableInputTokens.
requiredInputTokensintegerYesBounded token count for requiredInputTokens.
overflowTokensintegerYesBounded token count for overflowTokens.
itemsarrayYesOne informational count per input item, each a closed id with independentTokenCount.
warningsarrayYesFrom 0 through 10 safe advisory strings; currently always empty because fit has none.

API contract

POST /v1/execute
curl
curl -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"}}'
Integrations
TypeScript SDK
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

CodeHTTPRetryableDescription
VALIDATION_ERROR400NoThe request payload failed schema validation.
UNAUTHORIZED401NoMissing or invalid API key.
SKILL_NOT_ACCESSIBLE403NoThe API key is not granted access to this skill.
SKILL_NOT_AVAILABLE_FOR_PLAN403NoThis skill is not included in your current plan.
PLAN_ELIGIBILITY_UNAVAILABLE503YesPlan eligibility could not be decided. Retry after backoff.
SKILL_NOT_FOUND404NoThe requested skill or version does not exist.
TENANT_RATE_LIMITED429YesRequest rate limit exceeded. Retry after backoff.
QUOTA_EXCEEDED429YesPlan quota exhausted. Retryable once the quota period resets.
EXECUTION_TIMEOUT504YesExecution exceeded the allowed time budget.

Other limits

LimitValue
Recommended inline bytes32 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)

Request bodyjson
{
  "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

Inputjson
{
  "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"
}
Expected outputjson
{
  "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

Inputjson
{
  "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"
}
Expected outputjson
{
  "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"
}
  • 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

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.

Tags

textanalysiscontext-window