Start the server and visit
http://localhost:8000/docs for an interactive Swagger UI where you can try every endpoint directly in your browser.Response Format
All chunking endpoints return a list of chunk objects:Chunkers
Token Chunker
POST /v1/chunk/token
Splits text into fixed-size token windows. The fastest and most predictable chunker.
Sentence Chunker
POST /v1/chunk/sentence
Groups sentences into chunks while respecting a token-size limit. Preserves sentence boundaries — no mid-sentence splits.
Parameters
Parameters
Recursive Chunker
POST /v1/chunk/recursive
Splits text using a hierarchy of separators defined by a named recipe. Great for structured text like Markdown or code. Chunker instances are cached per (recipe, lang, tokenizer) for speed.
Parameters
Parameters
Named splitting recipe. Options:
"default" (paragraph → sentence → word), "markdown", "python", "js".Semantic Chunker
POST /v1/chunk/semantic
Splits where semantic similarity between adjacent sentences drops below a threshold. Produces topically coherent chunks. Requires the semantic extra.
Parameters
Parameters
Sentence-embedding model for computing similarity. Any model compatible with
sentence-transformers works.Cosine-similarity threshold for splitting (0.0–1.0). Lower values produce larger, fewer chunks.
Code Chunker
POST /v1/chunk/code
Splits source code at syntactic boundaries using AST parsing. Never breaks inside a function or class. Requires the code extra.
Parameters
Parameters
Programming language. Supported:
"python", "javascript", "typescript", "java", "go", "rust", "c", "cpp", and more.Refineries
Refineries enrich an existing list of chunks. Pass the output of any chunker endpoint directly into a refinery.Overlap Refinery
POST /v1/refine/overlap
Appends or prepends overlapping context from neighbouring chunks. Useful when downstream consumers need continuity across chunk boundaries.
Parameters
Parameters
List of chunk objects from any chunker endpoint. Each must contain
text, start_index, end_index, and token_count.Size of the overlap context. A float (0–1) is treated as a fraction of the chunk size; an integer is an absolute token count.
"suffix" appends context from the next chunk; "prefix" prepends context from the previous chunk; "justified" adds context from both sides.Embeddings Refinery
POST /v1/refine/embeddings
Computes and attaches embeddings to each chunk via Chonkie’s AutoEmbeddings. Each chunk in the response gains an embedding field containing a list of floats.
Local models (e.g. minishlab/potion-base-8M) run entirely on-device and require no API key. API-based models require the appropriate environment variable for your provider.
Embeddings Providers
Batch Processing
Send a list of strings to process multiple documents in one request:Chaining Chunkers and Refineries
Pipeline example — chunk semantically, then add overlap context:Error Handling
Error responses follow FastAPI’s standard format:
