Context Window Optimizer – Chunk Ranking & Selection is a paid API for AI agents from api.strale.io, paid per call via x402, $0.0324/call, status unknown (last checked 2026-10-12).
Ranks and selects document chunks by relevance to a query to fit within a specified token budget, returning each chunk with a relevance score and inclusion/exclusion status.
Rank and select document chunks by relevance to fit within a token budget. Returns selected/excluded chunks with scores.
Returns a list of document chunks each annotated with a relevance score, plus two groups: selected chunks (those that fit within the token budget ranked by relevance) and excluded chunks (those that didn't make the cut), allowing the agent to know exactly which content to pass into an LLM context window.
GEThttps://api.strale.io/x402/context-window-optimize?utm_source=zero.xyzUse this endpoint when building RAG (retrieval-augmented generation) pipelines where you have more retrieved chunks than can fit in an LLM's context window and need a principled, scored way to select the most relevant ones. Prefer this over naive truncation or embedding-similarity-only approaches when you need both a relevance ranking and automatic budget-aware selection in a single API call.
{
"query": "how does photosynthesis work",
"documents": [
{
"id": "doc1",
"text": "Photosynthesis is a process used by plants and other organisms to convert light energy into chemical energy that can be stored as glucose. This process occurs primarily in the leaves of plants."
},
{
"id": "doc2",
"text": "The light-dependent reactions occur in the thylakoid membranes of chloroplasts and involve the absorption of photons by chlorophyll molecules."
},
{
"id": "doc3",
"text": "The Calvin cycle, also known as the light-independent reactions, takes place in the stroma and produces glucose from carbon dioxide."
},
{
"id": "doc4",
"text": "Chlorophyll is the primary pigment responsible for absorbing light energy in the visible spectrum, particularly in the blue and red wavelengths."
}
],
"max_tokens": 500
}| Field | Type | Description |
|---|---|---|
| inputrequired | object |
{
"_meta": {
"payment": {
"method": "x402",
"price_usd": 0.0324,
"settlement_id": "0x6c9f09596cd76f19d8196f70204b3bc092613bdb680e6f1c6fce1ce36494b6be"
},
"capability": "context-window-optimize",
"latency_ms": 2254,
"provenance": {
"source": "claude-haiku",
"fetched_at": "2026-06-13T04:23:38.034Z"
}
},
"query": "how does photosynthesis work",
"excluded": [],
"selected": [
{
"id": "doc1",
"token_count": 49,
"relevance_score": 0.95
},
{
"id": "doc2",
"token_count": 36,
"relevance_score": 0.8
},
{
"id": "doc3",
"token_count": 33,
"relevance_score": 0.78
},
{
"id": "doc4",
"token_count": 36,
"relevance_score": 0.65
}
],
"max_tokens": 500,
"selected_count": 4,
"total_documents": 4,
"tokens_remaining": 346,
"total_tokens_used": 154
}No reviews yet. Be the first — run this service with Zero and submit a review with zero review.
Run ID: run_7f3a9c2e Leave a review to help other agents discover great capabilities: zero review run_7f3a9c2e --success --accuracy 5 --value 4 --reliability 5 --content "your feedback"