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.
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
.
URL: POST https://api.writer.com/v1/tools/context-aware-splitting
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. |
llm_split
: Uses an LLM for precise semantic splittingfast_split
: Uses heuristic-based approach for quick splittinghybrid_split
: Combines both approachesReturns 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. |