Developers
ENPT

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.

ToolWhat it doesUse it when
Smart SplitReads 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 textGets 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 CutSplits 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

NameTypeRequiredDescription
textstringYesText to split.
options.generalInstructionsstringNoHow to group, for example "one block per chapter".
options.returnBlocksbooleanNotrue (default) returns { text, label }. false returns { ranges, label }, with inclusive [start, end] line numbers starting at 0.
options.persistChunksbooleanNoSave each block to the knowledge base. Default false.
datasetIdstringNoDataset that receives the blocks when saving.
options.createDatasetIfMissingbooleanNoWhen saving without datasetId: true (default) creates a dataset named after the content; false uses the oldest dataset of the avatar.
avatarIdstringNoAvatar for the saved blocks. Default: the main avatar of your account.
options.maxLinesPerSessionintegerNoLines the AI reads at a time. Default 400.
options.overlapLinesintegerNoLines repeated between windows for continuity. Default 30.
options.minCoveragenumberNoMinimum 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
  }
}
FieldDescription
successtrue when coverage reached minCoverage.
coverageShare of lines placed in a block.
fallbackUsedtrue when part of the text was split mechanically.
persistedWith persistChunks: datasetId, avatarId, datasetCreated, datasetName (when created), chunkIds, count and embeddingFailures.

Convert to text

POST /api/externalAPIs/public/smartSplit/convertToText

NameTypeRequiredDescription
fileUrlstringYesPublic 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.

NameTypeRequiredDescription
textstringOne of the twoText to process.
urlstringOne of the twoPublic URL of a media file. It is transcribed first.
options.useAIbooleanNoKeep only the relevant lines. Default false: all lines are returned.
options.generalInstructionsstringNoWhich lines to keep, when useAI is true.
options.roiGate.skipbooleanNotrue always runs the cut, without the worth-it check.
options.roiGate.minimumSavingsRationumberNoMinimum 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." }
  }'
FieldDescription
linesThe lines kept.
allLinesEvery line before the selection.
intervalsRanges [start, end] chosen by the AI, when useAI is true.
skippedByRoiGatetrue when the cut was not worth it and the text came back unchanged. roiGateReason explains why.
errornull, or what went wrong.

Errors

CodeWhen
400Missing text or fileUrl, more than one Smart Cut input, or no text could be extracted from the file.
401Invalid token (Smart Split).
404The avatar or dataset is not in your account (Smart Split with saving).
500Unexpected error.

Previous

Media extraction

Next

Date resolver (Crono)