Skip to main content

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

MicroSkills Reference

Word Counter (Policy-Driven)

text.count_words

ProductionBounded custom (Class B)Deterministicstrictinstantv1.0.0
File inputNo network

Overview

You pass text (or a file_ref) and choose how a word is defined — Unicode word boundaries or visible written words; we return the count, the words themselves on request, any judgement calls we had to make, and the rule set we used so the number is defensible. Leave the policy out and we count with Unicode boundaries. A word count is only accurate when the counting rule is stated, so we always state it.

Word counts vary by algorithm. We force you to pick an explicit policy so your counts are reproducible and defensible.

Reliability

STRICT and deterministic for a given policy, locale, and options on this runtime. unicode_default counts may shift after a JDK Unicode upgrade. Input validation (not retryable): unsupported policy; missing text and file_ref.

Context footprint

Accepts inline text up to 100,000 chars or file_ref (up to 2 MB). Upload files via POST /v1/files/upload before passing file_ref. A successful call costs 1 execution credit.

When to use it

When word-count methodology must be documented — for billing, contracts, or content validation.

Do not use for LLM token limits (use text.count_tokens) or when a rough estimate is enough and methodology does not matter.

Scope

Note
Counts words in your text with a mandatory, explicit counting policy (unicode_default or orthographic) so results are always auditable.

Non-goals

  • Does not guess which policy fits your use case
  • Does not perform NLP or grammatical word analysis

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 input97.7 KBMax file size1.9 MB

File limits

Constraints this skill applies to your input and generated files. The “Limited by” column shows the static source of each cap; none of these can be raised by upgrading your plan.

LimitValueLimited by
Maximum size per input file1.9 MiBSkill maximum

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
textstringNoInline text up to 100,000 characters; required unless file_ref is supplied.
file_refstringNoTenant-scoped managed text file up to 2 MB; required unless text is supplied.
policystringNoApplied word-counting policy.
localestringNoBCP 47 locale used by orthographic policy; omit it for locale-neutral counting.
return_segmentsbooleanNoWhether counted segments are returned.
return_positionsbooleanNoWhether returned segments include offsets.
optionsobjectNoOrthographic policy tuning; omit it to apply every documented default.

Output schema

FieldTypeRequiredDescription
countintegerYesWords counted under the applied policy.
unitstringYesCounted unit, always the string word.
policystringYesApplied counting policy.
localestringNoNormalized BCP 47 locale when supplied.
segmentsarrayNoFrom 1 through the bounded input size plain strings or closed positioned segment objects in reading order.
warningsarrayYesFrom 0 through the bounded input size closed policy-advisory objects.
metadataobjectYesClosed receipt containing the applied policy, policy version, skill identity, and reliability mode.

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.count_words","input":{"text":"Hello world","policy":"unicode_default"}}'
Integrations
TypeScript SDK
import { Squillify } from "@squillify/sdk";

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

const { output } = await sq.execute("text.count_words", {"policy":"unicode_default","text":"Hello world"});

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 guess which policy fits your use case
  • Does not perform NLP or grammatical word analysis
  • LLM token budgeting (use text.count_tokens)
  • Quick approximate length when methodology does not matter
  • Character or byte counting (use text.count_characters or text.count_bytes)

How to call

POST /v1/execute (requires authentication)

Request bodyjson
{
  "skillKey": "text.count_words",
  "input": {
    "policy": "unicode_default",
    "text": "Hello world"
  }
}

Examples

Unicode default policy

Inputjson
{
  "policy": "unicode_default",
  "text": "Hello world"
}
Expected outputjson
{
  "warnings": [
    {
      "message": "This count follows Unicode word boundary rules, not grammatical word analysis.",
      "code": "UNICODE_NOT_GRAMMATICAL"
    }
  ],
  "unit": "word",
  "policy": "unicode_default",
  "count": 2,
  "metadata": {
    "skill_version": "1.0.0",
    "skill": "text.count_words",
    "deterministic": true,
    "policy_version": "unicode-uax29-jdk21",
    "policy": "unicode_default",
    "reliability_mode": "STRICT"
  }
}

Orthographic policy

Inputjson
{
  "policy": "orthographic",
  "text": "Hello world"
}
Expected outputjson
{
  "warnings": [],
  "unit": "word",
  "policy": "orthographic",
  "count": 2,
  "metadata": {
    "skill_version": "1.0.0",
    "skill": "text.count_words",
    "deterministic": true,
    "policy_version": "orthographic-v1",
    "policy": "orthographic",
    "reliability_mode": "STRICT"
  }
}
  • Document word counts for billing, contracts, or editorial guidelines
  • Validate content length before publishing or submission
  • Compare counts across documents with a documented methodology

Avoid for

  • LLM token budgeting (use text.count_tokens)
  • Quick approximate length when methodology does not matter
  • Character or byte counting (use text.count_characters or text.count_bytes)

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

textanalysisstatistics