Split text into semantically meaningful chunks
The context-aware splitting endpoint provides intelligent text splitting capabilities for documents up to 4000 words. Unlike simple character-based splitting, context-aware splitting preserves the semantic meaning and context between chunks, making it ideal for processing long-form content while maintaining coherence.
Use cases
- Breaking down long articles or research papers for improved readability
- Preparing content for chunked processing in RAG (Retrieval-Augmented Generation) systems
- Splitting lengthy legal documents while maintaining context around clauses and references
- Creating digestible sections of educational content while preserving logical flow
- Processing large documentation files for knowledge base creation
You need an API key to access the Writer API. Get an API key by following the steps in the API quickstart.
We recommend setting the API key as an environment variable in a .env
file with the name WRITER_API_KEY
.
Endpoint overview
URL: POST https://api.writer.com/v1/tools/context-aware-splitting
Request body
The request body includes the following parameters:
Parameter | Type | Description |
---|---|---|
text | string | The text content to be split. The text should be fewer than 4000 words. |
strategy | string | The splitting strategy to use. Options include: llm_split , fast_split , and hybrid_split . See below for more details. |
Splitting strategies
llm_split
: Uses an LLM for precise semantic splittingfast_split
: Uses heuristic-based approach for quick splittinghybrid_split
: Combines both approaches
Response format
Returns an array of text chunks, with at least one chunk guaranteed. Each chunk maintains semantic coherence while preserving the context of the original text.
Parameter | Type | Description |
---|---|---|
chunks | array[string] | An array of text chunks as strings. |
Was this page helpful?