Chunking
Experimental0 creditsSplit text into semantically meaningful chunks with 4 strategies. Character and token are free.
Production Recommendation
This is a direct endpoint for development and testing. For production workloads, use the Data Intelligence Pipeline -- it provides structured Data Packages with quality metrics, is async by default, and is covered by Enterprise SLAs.
Overview
The Chunking service splits text into semantically meaningful segments for granular processing, vector indexing, and RAG pipelines.
**4 strategies:** character (free), token (free), semantic (charged), hybrid (charged)
All strategies automatically detect and preserve Markdown structure, code blocks, heading hierarchies, and section boundaries. Each chunk includes structural metadata: character offsets, token counts, semantic coherence scores, and heading paths.
When to Use
Use chunking when you need to split documents into segments for vector indexing, RAG, or any downstream processing. Place it right after Document Intelligence in your pipeline.
API Reference
https://api.latence.ai/api/v1/chunking/chunkRequest Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
text | string | — | Text to chunk (max 5,000,000 characters) | |
strategy | stringcharactertokensemantichybrid | hybrid | Chunking strategy. Character and token are free; semantic and hybrid are charged at $0.10/1M chars. | |
chunk_size | integer | 512 | Target chunk size (64-8192). Characters for character/semantic/hybrid, tokens for token strategy. Range: 64 - 8192 | |
chunk_overlap | integer | 50 | Overlap between adjacent chunks Range: 0 - 8191 | |
min_chunk_size | integer | 64 | Minimum chunk size — smaller chunks are discarded Range: 1 - 8192 | |
request_id | string | — | Optional request tracking ID |
Response Fields
| Field | Type | Description |
|---|---|---|
success | boolean | Whether the request succeeded |
data.chunks | array | Array of chunk objects with content, index, start, end, char_count, token_count, semantic_score, section_path |
data.num_chunks | integer | Total number of chunks produced |
data.strategy | string | Chunking strategy used |
data.chunk_size | integer | Target chunk size parameter |
data.processing_time_ms | number | Processing time in milliseconds |
usage | object | Credit usage information |
Response Example
{
"success": true,
"data": {
"chunks": [
{
"content": "Introduction to machine learning...",
"index": 0,
"start": 0,
"end": 512,
"char_count": 498,
"token_count": 127,
"semantic_score": 0.87,
"section_path": ["Chapter 1", "Section 1.1"]
}
],
"num_chunks": 42,
"strategy": "hybrid",
"chunk_size": 512,
"processing_time_ms": 45.2
},
"usage": { "credits": 0.0 }
}Error Handling
All errors return a JSON body with error and details fields.
| Status | Code | Description |
|---|---|---|
| 400 | MISSING_FIELDMissing required field: text | The text field is required |
| 400 | INVALID_STRATEGYInvalid strategy. Must be character, token, semantic, or hybrid | Unknown chunking strategy |
| 429 | RATE_LIMITEDRate limit exceeded | Too many requests — retry after the Retry-After interval |
Billing
Pricing Formula
cost = (characters / 1,000,000) × rate (strategy-dependent)Add-ons & Multipliers
| Option | Price | Description |
|---|---|---|
| Character strategy | Free | Fixed character-length splits |
| Token strategy | Free | Token-boundary splits |
| Semantic strategy | $0.10 / 1M chars | Embedding-based semantic grouping |
| Hybrid strategy | $0.10 / 1M chars | Character splits refined with semantic coherence |
Pricing Examples
Code Examples
from latence import Latence
client = Latence(api_key="YOUR_API_KEY")
# Chunk a document (hybrid strategy)
result = client.experimental.chunking.chunk(
text="Your document text here...",
strategy="hybrid",
chunk_size=512,
)
print(f"{result.data.num_chunks} chunks")
for chunk in result.data.chunks:
print(f" [{chunk.index}] {chunk.char_count} chars: {chunk.content[:60]}...")Explore Tutorials & Notebooks
Deep-dive examples and interactive notebooks in our GitHub repository
Looking for production-grade processing?
The Data Intelligence Pipeline chains services automatically and returns structured Data Packages.