Skip to main content

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

MicroSkills Reference

Token Chunker

text.chunk_by_tokens

ProductionBounded custom (Class B)Deterministicverifiablefastv1.0.0
No network

Overview

You pass text and a token budget; we split it into chunks whose token count does not exceed maxTokens, with optional token overlap. We return character offsets, token counts, and deterministic chunk IDs. Paragraph preservation is best-effort; long paragraphs are hard-split at token boundaries when enabled. Offsets are UTF-16 Java string indexes. Do not use this for semantic chunking or non-OpenAI tokenizers.

Character-based chunking breaks token budgets unpredictably — you need reproducible token-bounded chunks for retrieval, embeddings, and hand-off.

Reliability

VERIFIABLE and deterministic for identical input and options on this deployment. Tokenizer encodings are version-sensitive — re-run after platform upgrades if you depend on exact chunk boundaries. Input validation (not retryable): missing text; text too long; maxTokens or maxChunks out of range; overlapTokens >= maxTokens; unsupported tokenizer.

Context footprint

Bounded input (2 MB) and maxChunks; character offsets are UTF-16 indexes. A successful call costs 1 execution credit.

When to use it

When you must split text into chunks that fit a token budget with optional overlap.

When you need semantic chunking or tokenizers other than the supported set.

Powered by JTokkit, an open-source tokenizer reproducing OpenAI's tiktoken byte-pair encodings.

Scope

Note
Splits plain text into token-bounded chunks (cl100k_base/o200k_base via jtokkit, or a simple Unicode word tokenizer) with optional overlap and deterministic IDs.

Non-goals

  • Does not summarize or embed text
  • Does not call any language model
  • Does not parse document formats beyond plain text

Properties

IdempotentRetry safeStreaming supportedFile input supportedRequires external service

Capabilities

data-transformationtext-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
textstringYesText divided into tokenizer-bounded chunks.
maxTokensintegerYesMaximum tokens in one chunk.
overlapTokensintegerNoAdjacent-chunk overlap; omit it for zero.
tokenizerstringNoTokenizer encoding; omit it for cl100k_base.
preserveParagraphsbooleanNoWhether paragraph boundaries are preferred; omit it for true.
hardSplitLongSegmentsbooleanNoWhether overlong segments are split; omit it for true.
includeTextbooleanNoWhether chunk text is returned; omit it for true.
maxChunksintegerNoChunk cap; omit it for one thousand.

Output schema

FieldTypeRequiredDescription
chunksarrayYesBounded array of chunk receipts in order with index, token bounds, and optional text. The item shape is defined by the nested schema and the array contains from 0 through 10000 items.
chunkCountintegerYesReturned chunk count.
totalTokensintegerYesOriginal input token count.
tokenizerstringYesApplied tokenizer encoding.

API contract

POST /v1/execute
curl
curl -sS -X POST "$BASE/v1/execute" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"skillKey":"text.chunk_by_tokens","input":{"text":"The quick brown fox.","maxTokens":512,"overlapTokens":64}}'
Integrations
TypeScript SDK
import { Squillify } from "@squillify/sdk";

const sq = new Squillify({ apiKey: process.env.SQUILLIFY_API_KEY });

const { output } = await sq.execute("text.chunk_by_tokens", {"text":"The quick brown fox.","maxTokens":4,"tokenizer":"cl100k_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 summarize or embed text
  • Does not call any language model
  • Does not parse document formats beyond plain text
  • Semantic/section-aware chunking that needs understanding
  • Chunking by characters or words (use character/word skills)

How to call

POST /v1/execute (requires authentication)

Request bodyjson
{
  "skillKey": "text.chunk_by_tokens",
  "input": {
    "text": "The quick brown fox.",
    "maxTokens": 4,
    "tokenizer": "cl100k_base"
  }
}

Examples

Chunk a short sentence

Inputjson
{
  "text": "The quick brown fox.",
  "maxTokens": 4,
  "tokenizer": "cl100k_base"
}
Expected outputjson
{
  "totalTokens": 5,
  "tokenizer": "cl100k_base",
  "chunks": [
    {
      "tokenCount": 4,
      "id": "63a8ef50989ffb3e",
      "text": "The quick brown fox",
      "endChar": 19,
      "overlapWithPreviousTokens": 0,
      "index": 0,
      "startChar": 0
    },
    {
      "tokenCount": 1,
      "id": "68feee9f6c1e5ea9",
      "text": ".",
      "endChar": 20,
      "overlapWithPreviousTokens": 0,
      "index": 1,
      "startChar": 19
    }
  ],
  "chunkCount": 2
}

Single chunk within budget

Inputjson
{
  "maxTokens": 100,
  "text": "hello world"
}
Expected outputjson
{
  "totalTokens": 2,
  "tokenizer": "cl100k_base",
  "chunks": [
    {
      "tokenCount": 2,
      "id": "82cb46d47a507877",
      "text": "hello world",
      "endChar": 11,
      "overlapWithPreviousTokens": 0,
      "index": 0,
      "startChar": 0
    }
  ],
  "chunkCount": 1
}
  • Chunk documents for RAG ingestion within a token budget
  • Prepare overlapping windows for embeddings
  • Split text for safe agent hand-off

Avoid for

  • Semantic/section-aware chunking that needs understanding
  • Chunking by characters or words (use character/word 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.

Tags

transformationtext