---
title: "Code Chunk"
method: POST
path: "/v1/chunk/code"
tags: ["Chunking"]
---

# Code Chunk

`POST /v1/chunk/code`

Code chunking endpoint.

Chunks code using AST-based parsing for various programming languages.

## Headers

- `authorization` string, nullable

## Request body

- CodeChunkerRequest — Request model for code chunking.
  - `text` union — Code text or list of code texts to chunk
    - string
    - string[]
  - `file` FileReference — File reference for chunking with OCR.
    - `type` string, required — File type: 'document' or 'base64;extension'
    - `content` string, required — Filename (for document) or base64 data
  - `ocr` string — OCR provider (mistral or gemini)
  - `tokenizer` string — Tokenizer to use
  - `chunk_size` integer — Size of each chunk
  - `language` string — Programming language (auto-detect if 'auto')
  - `include_nodes` boolean — Include AST nodes in output

## Response `200`

Successful Response

- unknown

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.dev/chonkie/apis/chonkie-api.md) · [All operations](https://skmtc.dev/chonkie/apis/chonkie-api/llms.txt) · [OpenAPI document](https://skmtc.dev/chonkie/apis/chonkie-api/revisions/f40f036f941c?raw)
