{ "openapi": "3.1.0", "info": { "title": "Chonkie API", "description": "🦛 Chonkie running on the Internet! 🌎 Get chunks via POST HTTP calls~", "version": "0.1.0" }, "servers": [ { "url": "https://api.chonkie.ai", "description": "Chonkie Cloud API" } ], "security": [ { "BearerAuth": [] } ], "paths": { "/v1/auth/validate": { "post": { "summary": "Validate API Key", "description": "Validates the provided API key. Use this endpoint to check if your API key is valid and active.", "operationId": "validate_auth_v1_auth_validate_post", "responses": { "200": { "description": "API key is valid and active", "content": { "application/json": { "schema": { "type": "object", "properties": { "message": { "type": "string", "example": "Token is valid!" }, "status": { "type": "integer", "example": 200 } } }, "example": { "message": "Token is valid!", "status": 200 } } } } } } }, "/v1/chunk/token": { "post": { "summary": "Token Chunker", "description": "Chunk the given text using the Token Chunker.", "operationId": "get_token_chunks_v1_chunk_token_post", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/TokenChunkerREQ" } } } }, "responses": { "200": { "description": "Successful Response: A list of standard chunk objects.", "content": { "application/json": { "schema": { "title": "TokenChunkResponse", "type": "array", "items": { "$ref": "#/components/schemas/Chunk" }, "description": "A list containing standard chunk objects, each detailing a segment of the original text based on token count." } } } } } } }, "/v1/chunk/sentence": { "post": { "summary": "Sentence Chunker", "description": "Chunk the given text using the Sentence Chunker.", "operationId": "get_sentence_chunks_v1_chunk_sentence_post", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SentenceChunkerREQ" } } } }, "responses": { "200": { "description": "Successful Response: A list of sentence chunk objects.", "content": { "application/json": { "schema": { "title": "SentenceChunkResponse", "type": "array", "items": { "$ref": "#/components/schemas/SentenceChunkSchema" }, "description": "A list containing sentence chunk objects, each detailing a segment of the original text and the sentences within it." } } } } } } }, "/v1/chunk/recursive": { "post": { "summary": "Recursive Chunker", "description": "Chunk the given text using the Recursive Chunker.", "operationId": "get_recursive_chunks_v1_chunk_recursive_post", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/RecursiveChunkerREQ" } } } }, "responses": { "200": { "description": "Successful Response: A list of recursive chunk objects.", "content": { "application/json": { "schema": { "title": "RecursiveChunkResponse", "type": "array", "items": { "$ref": "#/components/schemas/RecursiveChunkSchema" }, "description": "A list containing recursive chunk objects, each detailing a segment of the original text and its recursion level." } } } } } } }, "/v1/chunk/semantic": { "post": { "summary": "Semantic Chunker", "description": "Chunk the given text using the Semantic Chunker.", "operationId": "get_semantic_chunks_v1_chunk_semantic_post", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SemanticChunkerREQ" } } } }, "responses": { "200": { "description": "Successful Response: A list of semantic chunk objects.", "content": { "application/json": { "schema": { "title": "SemanticChunkResponse", "type": "array", "items": { "$ref": "#/components/schemas/SemanticChunkSchema" }, "description": "A list containing semantic chunk objects, detailing segments and sentences with optional embeddings." } } } } } } }, "/v1/chunk/sdpm": { "post": { "summary": "SDPM Chunker", "description": "Chunk the given text using the SDPM Chunker.", "operationId": "get_sdpm_chunks_v1_chunk_sdpm_post", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/SDPMChunkerREQ" } } } }, "responses": { "200": { "description": "Successful Response: A list of semantic chunk objects.", "content": { "application/json": { "schema": { "title": "SDPMChunkResponse", "type": "array", "items": { "$ref": "#/components/schemas/SemanticChunkSchema" }, "description": "A list containing semantic chunk objects (as SDPM is a type of semantic chunking), detailing segments and sentences with optional embeddings." } } } } } } }, "/v1/chunk/late": { "post": { "summary": "Late Chunker", "description": "Chunk the given text using the Late Chunker.", "operationId": "get_late_chunks_v1_chunk_late_post", "requestBody": { "required": true, "content": { "application/json": { "schema": { "$ref": "#/components/schemas/LateChunkerREQ" } } } }, "responses": { "200": { "description": "Successful Response: A list of late chunk objects.", "content": { "application/json": { "schema": { "title": "LateChunkResponse", "type": "array", "items": { "$ref": "#/components/schemas/LateChunkSchema" }, "description": "A list containing late chunk objects, detailing segments, sentences, and an optional chunk-level embedding." } } } } } } } }, "components": { "securitySchemes": { "BearerAuth": { "type": "http", "scheme": "bearer", "description": "Your API Key from the [Chonkie Cloud dashboard](https://cloud.chonkie.ai/keys)" } }, "schemas": { "Chunk": { "title": "Chunk", "description": "Represents a single chunk of text with metadata.", "type": "object", "properties": { "text": { "type": "string", "title": "Text", "description": "The actual text content of the chunk." }, "start_index": { "type": "integer", "title": "Start Index", "description": "The starting character index of the chunk within the original input text." }, "end_index": { "type": "integer", "title": "End Index", "description": "The ending character index (exclusive) of the chunk within the original input text." }, "token_count": { "type": "integer", "title": "Token Count", "description": "The number of tokens in this specific chunk, according to the tokenizer used." } } }, "SentenceSchema": { "title": "Sentence", "description": "Represents a single sentence within a chunk.", "type": "object", "properties": { "text": { "type": "string", "title": "Text", "description": "The actual text content of the sentence." }, "start_index": { "type": "integer", "title": "Start Index", "description": "The starting character index of the sentence within the original input text." }, "end_index": { "type": "integer", "title": "End Index", "description": "The ending character index (exclusive) of the sentence within the original input text." }, "token_count": { "type": "integer", "title": "Token Count", "description": "The number of tokens in this specific sentence, according to the tokenizer used." } } }, "SemanticSentenceSchema": { "title": "SemanticSentence", "description": "Represents a single sentence within a semantic chunk, potentially including an embedding.", "type": "object", "properties": { "text": { "type": "string", "title": "Text", "description": "The actual text content of the sentence." }, "start_index": { "type": "integer", "title": "Start Index", "description": "The starting character index of the sentence within the original input text." }, "end_index": { "type": "integer", "title": "End Index", "description": "The ending character index (exclusive) of the sentence within the original input text." }, "token_count": { "type": "integer", "title": "Token Count", "description": "The number of tokens in this specific sentence, according to the tokenizer used." }, "embedding": { "type": [ "array", "null" ], "items": { "type": "number", "format": "float" }, "title": "Embedding", "description": "Optional embedding vector for the sentence (array of floats or null)." } } }, "SentenceChunkSchema": { "title": "SentenceChunk", "description": "Represents a chunk of text composed of sentences.", "type": "object", "properties": { "text": { "type": "string", "title": "Text", "description": "The actual text content of the chunk." }, "start_index": { "type": "integer", "title": "Start Index", "description": "The starting character index of the chunk within the original input text." }, "end_index": { "type": "integer", "title": "End Index", "description": "The ending character index (exclusive) of the chunk within the original input text." }, "token_count": { "type": "integer", "title": "Token Count", "description": "The number of tokens in this specific chunk, according to the tokenizer used." }, "sentences": { "type": "array", "items": { "$ref": "#/components/schemas/SentenceSchema" }, "title": "Sentences", "description": "List of sentences contained within this chunk." } } }, "RecursiveChunkSchema": { "title": "RecursiveChunk", "description": "Represents a chunk generated by the Recursive Chunker, including its level.", "type": "object", "properties": { "text": { "type": "string", "title": "Text", "description": "The actual text content of the chunk." }, "start_index": { "type": "integer", "title": "Start Index", "description": "The starting character index of the chunk within the original input text." }, "end_index": { "type": "integer", "title": "End Index", "description": "The ending character index (exclusive) of the chunk within the original input text." }, "token_count": { "type": "integer", "title": "Token Count", "description": "The number of tokens in this specific chunk, according to the tokenizer used." }, "level": { "type": "integer", "title": "Level", "description": "The level of this chunk in the recursive splitting process." } } }, "SemanticChunkSchema": { "title": "SemanticChunk", "description": "Represents a chunk generated by semantic chunking methods (Semantic, SDPM), containing sentences potentially with embeddings.", "type": "object", "properties": { "text": { "type": "string", "title": "Text", "description": "The actual text content of the chunk." }, "start_index": { "type": "integer", "title": "Start Index", "description": "The starting character index of the chunk within the original input text." }, "end_index": { "type": "integer", "title": "End Index", "description": "The ending character index (exclusive) of the chunk within the original input text." }, "token_count": { "type": "integer", "title": "Token Count", "description": "The number of tokens in this specific chunk, according to the tokenizer used." }, "sentences": { "type": "array", "items": { "$ref": "#/components/schemas/SemanticSentenceSchema" }, "title": "Sentences", "description": "List of semantic sentences contained within this chunk." } } }, "LateChunkSchema": { "title": "LateChunk", "description": "Represents a chunk generated by the Late Chunker, containing sentences and an optional chunk-level embedding.", "type": "object", "properties": { "text": { "type": "string", "title": "Text", "description": "The actual text content of the chunk." }, "start_index": { "type": "integer", "title": "Start Index", "description": "The starting character index of the chunk within the original input text." }, "end_index": { "type": "integer", "title": "End Index", "description": "The ending character index (exclusive) of the chunk within the original input text." }, "token_count": { "type": "integer", "title": "Token Count", "description": "The number of tokens in this specific chunk, according to the tokenizer used." }, "sentences": { "type": "array", "items": { "$ref": "#/components/schemas/SentenceSchema" }, "title": "Sentences", "description": "List of standard sentences contained within this chunk." }, "embedding": { "type": [ "array", "null" ], "items": { "type": "number", "format": "float" }, "title": "Embedding", "description": "Optional embedding vector for the entire chunk (array of floats or null)." } } }, "ErrorRES": { "properties": { "message": { "type": "string", "title": "Message" }, "status": { "type": "integer", "title": "Status", "default": 500 } }, "type": "object", "title": "ErrorRES", "description": "Error response for the Chonkie API." }, "HTTPValidationError": { "properties": { "detail": { "items": { "$ref": "#/components/schemas/ValidationError" }, "type": "array", "title": "Detail" } }, "type": "object", "title": "HTTPValidationError" }, "LateChunkerREQ": { "title": "LateChunkerREQ", "description": "Data to pass to the Late Chunker.", "type": "object", "required": [ "text" ], "properties": { "text": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Text", "description": "The input text or list of texts to be chunked." }, "embedding_model": { "type": "string", "title": "Embedding Model", "default": "sentence-transformers/all-minilm-l6-v2" }, "mode": { "type": "string", "title": "Mode", "default": "sentence" }, "chunk_size": { "type": "integer", "title": "Chunk Size", "default": 512 }, "min_sentences_per_chunk": { "type": "integer", "title": "Min Sentences Per Chunk", "default": 1 }, "min_characters_per_sentence": { "type": "integer", "title": "Min Characters Per Sentence", "default": 1 }, "approximate": { "type": "boolean", "title": "Approximate", "default": true }, "delim": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Delim", "default": [ "\n", ".", "!", "?" ] }, "include_delim": { "anyOf": [ { "type": "string", "enum": [ "prev", "next" ] }, { "type": "null" } ], "title": "Include Delim", "default": "prev" } }, "additionalProperties": false }, "RecursiveChunkerREQ": { "title": "RecursiveChunkerREQ", "description": "Data to pass to the Recursive Character Text Splitter.", "type": "object", "required": [ "text" ], "properties": { "text": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Text", "description": "The input text or list of texts to be chunked." }, "tokenizer_or_token_counter": { "type": "string", "title": "Tokenizer Or Token Counter", "default": "gpt2" }, "chunk_size": { "type": "integer", "title": "Chunk Size", "default": 512 }, "rules": { "additionalProperties": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" }, { "additionalProperties": true, "type": "object" }, { "items": { "additionalProperties": true, "type": "object" }, "type": "array" } ] }, "type": "object", "title": "Rules", "default": { "levels": [ { "delimiters": [ "\n\n", "\n", "\r\n" ], "include_delim": "prev", "whitespace": false }, { "delimiters": [ ".", "?", "!" ], "include_delim": "prev", "whitespace": false }, { "delimiters": [ ",", ";", ":", "...", "-", "(", ")", "[", "]", "{", "}", "<", ">", "|", "~", "`", "'", "\"" ], "include_delim": "prev", "whitespace": false }, { "include_delim": "prev", "whitespace": true }, { "include_delim": "prev", "whitespace": false } ] } }, "min_characters_per_chunk": { "type": "integer", "title": "Min Characters Per Chunk", "default": 1 }, "return_type": { "type": "string", "title": "Return Type", "default": "chunks" } }, "additionalProperties": false }, "SDPMChunkerREQ": { "title": "SDPMChunkerREQ", "description": "Data to pass to the SDPM Chunker.", "type": "object", "required": [ "text" ], "properties": { "text": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Text", "description": "The input text or list of texts to be chunked." }, "embedding_model": { "type": "string", "title": "Embedding Model", "default": "minishlab/potion-base-8M" }, "threshold": { "anyOf": [ { "type": "string", "const": "auto" }, { "type": "number" }, { "type": "integer" } ], "title": "Threshold", "default": "auto" }, "mode": { "type": "string", "title": "Mode", "default": "window" }, "chunk_size": { "type": "integer", "title": "Chunk Size", "default": 512 }, "similarity_window": { "type": "integer", "title": "Similarity Window", "default": 1 }, "min_sentences": { "type": "integer", "title": "Min Sentences", "default": 1 }, "min_characters_per_sentence": { "type": "integer", "title": "Min Characters Per Sentence", "default": 1 }, "threshold_step": { "type": "number", "title": "Threshold Step", "default": 0.01 }, "delim": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Delim", "default": [ "\n", ".", "!", "?" ] }, "skip_window": { "type": "integer", "title": "Skip Window", "default": 1 }, "return_type": { "type": "string", "title": "Return Type", "default": "chunks" } }, "additionalProperties": false }, "SemanticChunkerREQ": { "title": "SemanticChunkerREQ", "description": "Data to pass to the Semantic Chunker.", "type": "object", "required": [ "text" ], "properties": { "text": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Text", "description": "The input text or list of texts to be chunked." }, "embedding_model": { "type": "string", "title": "Embedding Model", "default": "minishlab/potion-base-8M" }, "threshold": { "anyOf": [ { "type": "string", "const": "auto" }, { "type": "number" }, { "type": "integer" } ], "title": "Threshold", "default": "auto" }, "chunk_size": { "type": "integer", "title": "Chunk Size", "default": 512 }, "similarity_window": { "type": "integer", "title": "Similarity Window", "default": 1 }, "min_sentences": { "type": "integer", "title": "Min Sentences", "default": 1 }, "min_chunk_size": { "type": "integer", "title": "Min Chunk Size", "default": 2 }, "min_characters_per_sentence": { "type": "integer", "title": "Min Characters Per Sentence", "default": 1 }, "threshold_step": { "type": "number", "title": "Threshold Step", "default": 0.01 }, "delim": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Delim", "default": [ "\n", ".", "!", "?" ] }, "include_delim": { "anyOf": [ { "type": "string", "enum": [ "prev", "next" ] }, { "type": "null" } ], "title": "Include Delim", "default": "prev" }, "return_type": { "type": "string", "title": "Return Type", "default": "chunks" } }, "additionalProperties": false }, "SentenceChunkerREQ": { "title": "SentenceChunkerREQ", "description": "Data to pass to the Sentence Chunker.", "type": "object", "required": [ "text" ], "properties": { "text": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Text", "description": "The input text or list of texts to be chunked." }, "tokenizer_or_token_counter": { "type": "string", "title": "Tokenizer Or Token Counter", "default": "gpt2" }, "chunk_size": { "type": "integer", "title": "Chunk Size", "default": 512 }, "chunk_overlap": { "type": "integer", "title": "Chunk Overlap", "default": 0 }, "min_sentences_per_chunk": { "type": "integer", "title": "Min Sentences Per Chunk", "default": 1 }, "min_characters_per_sentence": { "type": "integer", "title": "Min Characters Per Sentence", "default": 1 }, "approximate": { "type": "boolean", "title": "Approximate", "default": true }, "delim": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Delim", "default": [ "\n", ".", "!", "?" ] }, "include_delim": { "anyOf": [ { "type": "string", "enum": [ "prev", "next" ] }, { "type": "null" } ], "title": "Include Delim", "default": "prev" }, "return_type": { "type": "string", "title": "Return Type", "default": "chunks" } }, "additionalProperties": false }, "TokenChunkerREQ": { "title": "TokenChunkerREQ", "description": "Data to pass to the Token Chunker.", "type": "object", "required": [ "text" ], "properties": { "text": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Text", "description": "The input text or list of texts to be chunked." }, "tokenizer": { "type": "string", "title": "Tokenizer", "default": "gpt2" }, "chunk_size": { "type": "integer", "title": "Chunk Size", "default": 512 }, "chunk_overlap": { "type": "integer", "title": "Chunk Overlap", "default": 0 }, "return_type": { "type": "string", "title": "Return Type", "default": "chunks" } }, "additionalProperties": false }, "ValidationError": { "properties": { "loc": { "items": { "anyOf": [ { "type": "string" }, { "type": "integer" } ] }, "type": "array", "title": "Location" }, "msg": { "type": "string", "title": "Message" }, "type": { "type": "string", "title": "Error Type" } }, "type": "object", "title": "ValidationError" }, "WordChunkerREQ": { "title": "WordChunkerREQ", "description": "Data to pass to the Word Chunker.", "type": "object", "required": [ "text" ], "properties": { "text": { "anyOf": [ { "type": "string" }, { "items": { "type": "string" }, "type": "array" } ], "title": "Text", "description": "The input text or list of texts to be chunked." }, "tokenizer_or_token_counter": { "type": "string", "title": "Tokenizer Or Token Counter", "default": "gpt2" }, "chunk_size": { "type": "integer", "title": "Chunk Size", "default": 512 }, "chunk_overlap": { "type": "integer", "title": "Chunk Overlap", "default": 0 }, "return_type": { "type": "string", "title": "Return Type", "default": "chunks" } }, "additionalProperties": false } } } }