Execute a retriever and return matching documents. The pipeline is automatically optimized before execution for best performance.
Automatic Optimization: Your pipeline stages are automatically transformed for optimal performance:
Streaming Support: Set stream=true in the request body to receive real-time stage updates via SSE:
Response Includes (when stream=false):
Optimization Summary Example:
{
"optimization_applied": true,
"optimization_summary": {
"original_stage_count": 5,
"optimized_stage_count": 3,
"optimization_time_ms": 8.2,
"rules_applied": ["push_down_filters", "group_by_push_down"],
"stage_reduction_pct": 40.0
}
}
Use the /explain endpoint to see the optimized execution plan before running.
REQUIRED: Bearer token authentication using your API key. Format: 'Bearer sk_xxxxxxxxxxxxx'. You can create API keys in the Mixpeek dashboard under Organization Settings.
"Bearer YOUR_API_KEY"
"Bearer YOUR_STRIPE_API_KEY"
REQUIRED: Namespace identifier for scoping this request. All resources (collections, buckets, taxonomies, etc.) are scoped to a namespace. You can provide either the namespace name or namespace ID. Format: ns_xxxxxxxxxxxxx (ID) or a custom name like 'my-namespace'
"ns_abc123def456"
"production"
"my-namespace"
Retriever ID or name. Pipeline will be automatically optimized before execution.
Execution request with inputs, filters, pagination, and optional stream parameter. Set stream=true to receive real-time stage updates via Server-Sent Events.
Runtime inputs for the retriever mapped to the input schema. Keys must match the retriever's input_schema field names. Values depend on field types (text, vector, filters, etc.). REQUIRED unless all retriever inputs have defaults.
Common input keys:
Template Syntax (Jinja2):
Namespaces (uppercase or lowercase):
INPUT / input: Query inputs (e.g., {{INPUT.query}})DOC / doc: Document fields (e.g., {{DOC.payload.title}})CONTEXT / context: Execution contextSTAGE / stage: Stage configurationSECRET / secret: Vault secrets (e.g., {{SECRET.api_key}})Accessing Data:
{{DOC.payload.metadata.title}}{{DOC.payload['special-key']}}{{DOC.items[0]}}, {{DOC.tags[2]}}{{DOC.items | first}}, {{DOC.items | last}}Array Operations:
{% for item in DOC.tags %}{{item}}{% endfor %}{{DOC.items | map(attribute='name') | list}}{{DOC.tags | join(', ')}}{{DOC.items | length}}{{DOC.items[:5]}}Conditionals:
{% if DOC.status == 'active' %}...{% endif %}{% if DOC.score > 0.8 %}high{% else %}low{% endif %}{{'yes' if DOC.enabled else 'no'}}Built-in Functions: max, min, abs, round, ceil, floor
Custom Filters: slugify (URL-safe), bool (truthy coercion), tojson (JSON encode)
S3 URLs: Internal S3 URLs (s3://bucket/key) are automatically presigned when accessed via DOC namespace.
{
"query": "artificial intelligence",
"top_k": 25
}{
"min_score": 0.7,
"query": "customer feedback",
"top_k": 50
}{
"category": "blog",
"embedding": [0.1, 0.2, 0.3],
"top_k": 10
}Offset-based pagination using page number sizing.
Enable streaming execution to receive real-time stage updates via Server-Sent Events (SSE). NOT REQUIRED - defaults to False for standard execution.
When stream=True:
When stream=False (default):
Use streaming when:
Example streaming client (JavaScript):
const eventSource = new EventSource('/v1/retrievers/ret_123/execute?stream=true');
eventSource.onmessage = (event) => {
const stageEvent = JSON.parse(event.data);
if (stageEvent.event_type === 'stage_complete') {
console.log(`Stage ${stageEvent.stage_name} completed`);
console.log(`Documents: ${stageEvent.documents.length}`);
}
};Example streaming client (Python):
import requests
response = requests.post('/v1/retrievers/ret_123/execute',
json={'inputs': {...}, 'stream': True},
stream=True)
for line in response.iter_lines():
if line.startswith(b'data: '):
event = json.loads(line[6:])
print(f"Stage {event['stage_name']}: {event['event_type']}")false
true
Execution results with documents, pagination, statistics, and optimization details. When stream=true, returns Server-Sent Events. When stream=false, returns JSON response.