Preview what context a question would get
/v1/context-sources/retrievePreview what context a question would get.
Chooses the sections of the given sources for question exactly as a chat completion with x-context-source would, and returns them with their text, the selector's confidence and reason, and the status a request would get in x-context-status. No answer is generated. The selection is one model call on virtual_key (billed to it and logged as context_select), or none when the same question was asked of the same outline before (cached).
Requires a key of the virtual key's workspace (or an organization admin key) and a plan that includes context sources (402 otherwise). Returns 400 for an unknown or unusable virtual key, 403 when the key has no access to a source, 404 for an unknown source and 409 when a source is not READY.
Authorization
AuthorizationBearer va_A platform API key (
va_...), created under Settings > API keys. Scoped to an organization or one workspace, with an admin or member role. Used by the management API.
Query parameters
organizationstringrequiredThe organization's identifier (slug).
Request body application/json
The question, the sources and the key to choose with.
virtual_keystringrequiredThe virtual key (
vk-...) the selection runs on and is billed to. It must have access to every source.At least 1 characters
sourcesstring[]requiredContext source ids (
ctx-...), 1 to 5.At most 5 items
questionstringrequiredThe question, as the last user message of a request would carry it. At most 20,000 characters.
At least 0 characters · At most 20000 characters
budgetinteger<int32>Most tokens of section text to return, 200 to 100000. Default 6000.
modelstringThe model that chooses the sections. Default
gpt-6-luna.At least 0 characters · At most 200 characters
Responses
statusstringAPPLIED(sections chosen),LOW_CONFIDENCE(chosen, but the selector was not sure they answer it),NO_MATCH(nothing relevant),NO_QUESTION(empty question),SELECT_FAILED(the selection call failed or its answer could not be read) orSELECT_TIMEOUT(it took longer than the time limit). When every section fits the budget, all are added without a selection call (APPLIED, no confidence). The same value a request gets inx-context-status.confidencestringThe selector's confidence:
high,mediumorlow. Absent when it did not answer.reasonstringThe selector's one-sentence reason for its choice. Absent when it did not give one.
cachedbooleanTrue when the choice came from the cache of earlier selections for the same outline and question (no model call was billed).
select_msinteger<int64>Milliseconds spent choosing.
tokensinteger<int32>Estimated tokens of all the sections' text.
consideredinteger<int32>How many sections of the sources the selector could choose from.
chosenstring[]What the selector chose,
<source>/<section>, in its order, before the budget: one here but not insectionswas dropped because it did not fit.modelstringThe model that chose.
budgetinteger<int32>Tokens of section text allowed.
sectionsobject[]The sections chosen within the budget, most relevant first.
Child attributes
sourcestringThe source's id (
ctx-...).section_idstringThe section's id in the source's outline (
n12).titlestringThe section's title.
page_frominteger<int32>First page of the section (PDF only).
page_tointeger<int32>Last page of the section (PDF only).
tokensinteger<int32>Estimated tokens of the text below.
cited_bystringWhen the section was added because a chosen section refers to it ("subject to Section 9"): that section's id in the outline (
n14). Absent for the sections the selection chose itself.textstringThe text that would be added, cut to the budget when it is the only section and too long.