Code Chunker
Splits code into chunks based on its structure, leveraging Abstract Syntax Trees (ASTs) to create contextually relevant segments.
Authorizations
Your API Key from the Chonkie Cloud dashboard
Body
The programming language of the code. Accepts languages supported by tree-sitter-language-pack
.
The file containing code to be chunked.
Tokenizer or token counting function to use for measuring chunk size.
Maximum number of tokens per chunk.
Whether to include the list of corresponding AST Node
objects within each CodeChunk
.
Whether to return chunks as CodeChunk
objects or plain text strings.
texts
, chunks
Response
The actual code text content of the chunk.
The starting character index of the chunk within the original input code.
The ending character index (exclusive) of the chunk within the original input code.
The number of tokens in this specific chunk, according to the tokenizer used.
Optional list of AST Node
objects corresponding to this code chunk (present if include_nodes
is true).
Represents a node in the Abstract Syntax Tree (AST) of the code, used by CodeChunker.