---
title: "Overlap Refinery"
method: POST
path: "/v1/refine/overlap"
---

# Overlap Refinery

`POST /v1/refine/overlap`

Adds overlapping context (prefix or suffix) to a list of provided chunks based on specified arguments.

## Request body

- OverlapRefineryREQ — Request body for the Overlap Refinery endpoint.
  - `chunks` Chunk[], required — A list of `Chunk` objects (as dictionaries) to refine with overlap.
    - `text` string — The actual text content of the chunk.
    - `start_index` integer — The starting character index of the chunk within the original input text.
    - `end_index` integer — The ending character index (exclusive) of the chunk within the original input text.
    - `token_count` integer — The number of tokens in this specific chunk, according to the tokenizer used.
    - `context` string, nullable — Chunk context.
  - `tokenizer_or_token_counter` string — Tokenizer identifier (e.g., 'gpt2') or 'character' for character counting.
  - `context_size` union — Size of the overlap context (absolute tokens if int, fraction if float).
    - number
    - integer
  - `mode` 'token' | 'recursive' — Mode for calculating overlap ('token' or 'recursive').
  - `method` 'suffix' | 'prefix' — Method for adding context ('suffix' from next, 'prefix' from previous).
  - `rules` object — Recursive rules definition (object representation) if mode is 'recursive'.
  - `merge` boolean — If true, merge context into chunk text; otherwise, store in 'context' field.

## Response `200`

Successful Response: A list of `Chunk` objects with added overlap context.

- Chunk[] — A list containing `Chunk` objects, potentially modified to include overlapping text or context.
  - `text` string — The actual text content of the chunk.
  - `start_index` integer — The starting character index of the chunk within the original input text.
  - `end_index` integer — The ending character index (exclusive) of the chunk within the original input text.
  - `token_count` integer — The number of tokens in this specific chunk, according to the tokenizer used.
  - `context` string, nullable — Chunk context.

## Other responses

- `422` — Validation Error

## Changes

- **2025-05-04** `33dc37e4abcd` — 1 info
  - endpoint added

[Change history](https://skmtc.dev/feyninc/apis/chonkie-api/changes/v1/refine/overlap/post.md)

---

[API](https://skmtc.dev/feyninc/apis/chonkie-api.md) · [All operations](https://skmtc.dev/feyninc/apis/chonkie-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/feyninc/chonkie-api/revisions/8a6665f478db/schema)
