The Recursive Chunker splits text by trying multiple delimiters in order (paragraphs, sentences, words) to create natural, coherent chunks.
Examples
Text Input
from chonkie.cloud import RecursiveChunker
chunker = RecursiveChunker(
chunk_size=512,
recipe="markdown"
)
text = "Your text here..."
chunks = chunker.chunk(text)
from chonkie.cloud import RecursiveChunker
chunker = RecursiveChunker(
chunk_size=512,
recipe="markdown"
)
# Chunk from file
with open("document.txt", "rb") as f:
chunks = chunker.chunk(file=f)
Request
Parameters
The text to chunk. Can be a single string or an array of strings for batch processing. Either text or file is required.
File to chunk. Use multipart/form-data encoding. Either text or file is required.
Tokenizer to use for counting tokens.
Maximum number of tokens per chunk.
The minimum number of characters a chunk should have.
Language of the document to chunk
Response
Returns
Array of Chunk objects, each containing:
Starting character position in the original text.
Ending character position in the original text.
Number of tokens in the chunk.