Skip to main content
The TeraflopAIChunker uses the TeraflopAI Segmentation API to split text into semantically meaningful segments. It is especially useful for domain-specific segmentation such as legal documents.

Installation

TeraflopAI Chunker requires the teraflopai Python package:
For general installation instructions, see the Installation Guide.

Initialization

Parameters

Optional[TeraflopAI]
default:"None"
An existing TeraflopAI client instance. If provided, url and api_key are ignored.
str
The URL for the TeraflopAI segmentation API endpoint.
Optional[str]
default:"None"
The API key for authentication. If not provided, it will be read from the TERAFLOPAI_API_KEY environment variable.
Union[str, TokenizerProtocol]
default:"character"
The tokenizer used to compute token counts for returned chunks.

Usage

Single Text Chunking

Batch Chunking

Using with Environment Variable

How It Works

  1. The text is sent to the TeraflopAI Segmentation API endpoint.
  2. The API returns a list of text segments.
  3. Each segment is converted into a Chonkie Chunk object with proper start_index, end_index, and token_count fields.
The TeraflopAI Segmentation API performs the segmentation on the server side. This chunker requires an active internet connection and a valid API key.