Skip to main content
{
  "text": "<string>",
  "start_index": 123,
  "end_index": 123,
  "token_count": 123,
  "embedding": [
    {}
  ]
}
The Embeddings Refinery adds vector embeddings to your chunks, enabling semantic search and retrieval.

Request

Parameters

chunks
array
required
Array of chunk objects to add embeddings to. Each chunk must have text, start_index, end_index, and token_count fields.
embedding_model
string
default:"minishlab/potion-retrieval-32M"
The embedding model to use. Supports Hugging Face and OpenAI models.
Need another model? Reach out to us at [email protected]

Response

Returns

Array of chunks with added embedding field.
text
string
The original chunk text.
start_index
integer
Starting position in original text.
end_index
integer
Ending position in original text.
token_count
integer
Number of tokens in the chunk.
embedding
array
Vector embedding as array of floats.

Examples

from chonkie.cloud import TokenChunker, EmbeddingsRefinery

chunker = TokenChunker(chunk_size=512)
chunks = chunker.chunk("Your text here...")

refinery = EmbeddingsRefinery(
    embedding_model="minishlab/potion-retrieval-32M"
)
refined_chunks = refinery.refine(chunks)
I