Grep Store Chunks
Match store chunks against a regular expression. Unlike `/stores/search`, this runs your regex against the literal text of each chunk. Use it to find chunks containing a specific token, identifier, error code, or literal phrase.
Unlike /stores/search, this runs your regex against the literal text of each
chunk. Use it to find chunks containing a specific token, identifier, error code,
or literal phrase.
grep matches across all requested stores and returns at most top_k chunks in total.
Matches are unranked and interleaved across stores in the order requested, preserving each
store's result order. Pagination is not supported; raise top_k to retrieve more matches.
ApiKeyAuthAuthorizationBearer <token>Api key to access Mixedbreads API
X-Mxbai-Tool-Ticket?|Ticket from a chat completion's tool_tickets, proving this call runs a tool call that completion asked for. Redeems once, and bills the operation at the discounted agent rate.
application/json- body
Grep parameters including the regular expression pattern, targets and filters
store_identifiers*array<string|>IDs or names of stores
1 <= items <= 64top_k?Top KNumber of results to return
1 <= value <= 1000010filters?||array<|>|Optional filter conditions
file_ids?array<any>|array<>|Optional list of file IDs to filter chunks by (inclusion filter)
pattern*PatternRegular expression (RE2 syntax) matched against chunk text
1 <= length <= 1024targets?array<>Chunk content groups to match against. text matches the original text of text chunks; generated matches ingestion-derived fields (transcription, OCR text, summaries).
1 <= itemscase_sensitive?Case SensitiveWhether the regular expression is case-sensitive
falsereturn_metadata?Return MetadataWhether to return file metadata
trueList of chunks whose text matches the pattern
application/json- response
object?ObjectThe object type of the response
"list"data*array<|||>The list of chunks matching the pattern
from mixedbread import Mixedbread
mxbai = Mixedbread(api_key="YOUR_API_KEY")
response = mxbai.stores.grep(
store_identifiers=["{{STORE_IDENTIFIER}}"],
pattern="ERR-\\d{4}",
top_k=10,
)
for chunk in response.data:
print(chunk){
"object": "list",
"data": [
{
"chunk_index": 3,
"mime_type": "text/plain",
"model": "mxbai-omni",
"score": 1,
"file_id": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"filename": "error_logs.txt",
"store_id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
"metadata": {
"source": "upload",
"page": 2
},
"type": "text",
"text": "Encountered ERR-4021 while processing the request payload."
},
{
"chunk_index": 7,
"mime_type": "text/plain",
"model": "mxbai-omni",
"score": 1,
"file_id": "b2c3d4e5-f6a7-8901-bcde-f23456789012",
"filename": "incident_report.md",
"store_id": "c3d4e5f6-a7b8-9012-cdef-345678901234",
"metadata": {
"category": "ops"
},
"type": "text",
"text": "Root cause analysis points to ERR-1337 raised by the upstream service."
}
]
}