Word Counter (Policy-Driven)
text.count_words
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
Non-goals
- Does not guess which policy fits your use case
- Does not perform NLP or grammatical word analysis
Properties
Capabilities
Cost & billing
Flat rate per invocation
File handling
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.
| Limit | Value | Limited by |
|---|---|---|
| Maximum size per input file | 1.9 MiB | Skill maximum |
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 |
|---|---|---|---|
| text | string | No | Inline text up to 100,000 characters; required unless file_ref is supplied. |
| file_ref | string | No | Tenant-scoped managed text file up to 2 MB; required unless text is supplied. |
| policy | string | No | Applied word-counting policy. |
| locale | string | No | BCP 47 locale used by orthographic policy; omit it for locale-neutral counting. |
| return_segments | boolean | No | Whether counted segments are returned. |
| return_positions | boolean | No | Whether returned segments include offsets. |
| options | object | No | Orthographic policy tuning; omit it to apply every documented default. |
Output schema
| Field | Type | Required | Description |
|---|---|---|---|
| count | integer | Yes | Words counted under the applied policy. |
| unit | string | Yes | Counted unit, always the string word. |
| policy | string | Yes | Applied counting policy. |
| locale | string | No | Normalized BCP 47 locale when supplied. |
| segments | array | No | From 1 through the bounded input size plain strings or closed positioned segment objects in reading order. |
| warnings | array | Yes | From 0 through the bounded input size closed policy-advisory objects. |
| metadata | object | Yes | Closed receipt containing the applied policy, policy version, skill identity, and reliability mode. |
API contract
POST /v1/executecurl -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"}}'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
| 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 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)
{
"skillKey": "text.count_words",
"input": {
"policy": "unicode_default",
"text": "Hello world"
}
}Examples
Unicode default policy
{
"policy": "unicode_default",
"text": "Hello world"
}{
"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
{
"policy": "orthographic",
"text": "Hello world"
}{
"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"
}
}Recommended use cases
- 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)
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.