POST
/
v1
/
chunk
/
code
curl --request POST \
  --url https://api.chonkie.ai/v1/chunk/code \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: multipart/form-data' \
  --form tokenizer_or_token_counter=gpt2 \
  --form chunk_size=1500 \
  --form 'language=<string>' \
  --form include_nodes=false \
  --form return_type=chunks
[
  {
    "text": "<string>",
    "start_index": 123,
    "end_index": 123,
    "token_count": 123,
    "nodes": [
      {
        "text": "<string>",
        "start_byte": 123,
        "end_byte": 123,
        "type": "<string>"
      }
    ]
  }
]

Authorizations

Authorization
string
header
required

Your API Key from the Chonkie Cloud dashboard

Body

multipart/form-data

Response

200 - application/json
Successful Response: A list of `CodeChunk` objects.

A list containing CodeChunk objects, each detailing a segment of the original code and optionally the corresponding AST nodes.