Smart Split and Smart Cut
Break long texts into meaningful blocks for the knowledge base, or cut them down to the lines that matter.
Long texts are hard to use as they are. These endpoints prepare them.
| Tool | What it does | Use it when |
|---|---|---|
| Smart Split | Reads the text and groups lines that belong to the same idea, topic or chapter. Each block gets a short label. It can save every block straight into the knowledge base. | You want to add a manual, a catalog or a policy to the knowledge base in well-formed pieces. |
| Convert to text | Gets the text of a PDF or the content of an image from a URL. | Your source is a file and Smart Split needs text. |
| Smart Cut | Splits text into lines and, if you ask, keeps only the lines relevant to an instruction. | You want to send less text to the next step, for example only the lines about prices. |
Smart Split decides where to cut by meaning, not by size, so a block keeps a whole topic together. When the AI cannot handle part of the text, that part is split mechanically, and the response tells you.
Smart Cut checks first whether cutting is worth it. When the text is already short, or the expected saving is small, it returns the text unchanged and says why.
ReferenceTechnical details
All endpoints use a host token (Authorization: Bearer $TOLKY_TOKEN). Field names are accepted in camelCase or snake_case.
Smart Split
POST /api/externalAPIs/public/smartSplit/partition
| Name | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to split. |
options.generalInstructions | string | No | How to group, for example "one block per chapter". |
options.returnBlocks | boolean | No | true (default) returns { text, label }. false returns { ranges, label }, with inclusive [start, end] line numbers starting at 0. |
options.persistChunks | boolean | No | Save each block to the knowledge base. Default false. |
datasetId | string | No | Dataset that receives the blocks when saving. |
options.createDatasetIfMissing | boolean | No | When saving without datasetId: true (default) creates a dataset named after the content; false uses the oldest dataset of the avatar. |
avatarId | string | No | Avatar for the saved blocks. Default: the main avatar of your account. |
options.maxLinesPerSession | integer | No | Lines the AI reads at a time. Default 400. |
options.overlapLines | integer | No | Lines repeated between windows for continuity. Default 30. |
options.minCoverage | number | No | Minimum share of lines that must end up in a block, from 0 to 1. Default 0.90. |
curl -X POST "https://api.tolky.to/api/externalAPIs/public/smartSplit/partition" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "Chapter 1. Returns.\nYou can return any product within 30 days.\n\nChapter 2. Shipping.\nWe ship to the whole country.",
"options": { "generalInstructions": "One block per chapter." }
}'{
"code": 200,
"message": "OK",
"data": {
"success": true,
"blocks": [
{ "text": "Chapter 1. Returns.\nYou can return any product within 30 days.", "label": "Returns" },
{ "text": "Chapter 2. Shipping.\nWe ship to the whole country.", "label": "Shipping" }
],
"coverage": 1,
"totalLines": 5,
"sessionsUsed": 1,
"fallbackUsed": false,
"failedSessions": 0,
"reasoning": "Grouped by chapter.",
"auditLog": ["..."],
"persisted": null
}
}| Field | Description |
|---|---|
success | true when coverage reached minCoverage. |
coverage | Share of lines placed in a block. |
fallbackUsed | true when part of the text was split mechanically. |
persisted | With persistChunks: datasetId, avatarId, datasetCreated, datasetName (when created), chunkIds, count and embeddingFailures. |
Convert to text
POST /api/externalAPIs/public/smartSplit/convertToText
| Name | Type | Required | Description |
|---|---|---|---|
fileUrl | string | Yes | Public URL of a PDF or an image (JPG, PNG, WEBP and others). |
{ "code": 200, "message": "OK", "data": { "success": true, "text": "...", "fileName": "manual.pdf", "fileType": "pdf" } }For PDFs this reads the text layer. For scanned PDFs, use Media extraction. For images, text is a description of the image.
Smart Cut
POST /api/externalAPIs/public/smartCut/lineSplit. Send exactly one input: text or url.
| Name | Type | Required | Description |
|---|---|---|---|
text | string | One of the two | Text to process. |
url | string | One of the two | Public URL of a media file. It is transcribed first. |
options.useAI | boolean | No | Keep only the relevant lines. Default false: all lines are returned. |
options.generalInstructions | string | No | Which lines to keep, when useAI is true. |
options.roiGate.skip | boolean | No | true always runs the cut, without the worth-it check. |
options.roiGate.minimumSavingsRatio | number | No | Minimum expected reduction, from 0 to 1, for the cut to run. |
curl -X POST "https://api.tolky.to/api/externalAPIs/public/smartCut/lineSplit" \
-H "Authorization: Bearer $TOLKY_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello! Our store opens at 9am. The blue shirt costs 59.90. Have a nice day.",
"options": { "useAI": true, "generalInstructions": "Keep only lines that mention prices." }
}'| Field | Description |
|---|---|
lines | The lines kept. |
allLines | Every line before the selection. |
intervals | Ranges [start, end] chosen by the AI, when useAI is true. |
skippedByRoiGate | true when the cut was not worth it and the text came back unchanged. roiGateReason explains why. |
error | null, or what went wrong. |
Errors
| Code | When |
|---|---|
400 | Missing text or fileUrl, more than one Smart Cut input, or no text could be extracted from the file. |
401 | Invalid token (Smart Split). |
404 | The avatar or dataset is not in your account (Smart Split with saving). |
500 | Unexpected error. |