Skip to content
API referenceRun a context source's test set

Run a context source's test set

POST/v1/context-sources/{slug}/test-runs

Run a context source's test set.

Starts a run in the background and returns it in status RUNNING: for every test case the sections are chosen as a chat completion with this source would (one selection call per question on virtual_key, billed to it; repeated questions come from the selection cache), and the run records which expected sections were chosen within the budget. Get the run for recall (mean share of expected sections chosen), hit_rate (share of questions with at least one), the selection times (select_p50_ms, select_p95_ms) and per-question results. With fresh, the selection cache is skipped so the times are real selection calls.

Requires an organization admin key, or a workspace admin key for the source's workspace, and a plan that includes context sources (402 otherwise). Returns 400 for an unusable virtual key or budget, 403 when the key has no access to the source, 404 when the source does not exist, 409 when it is not READY or has no test cases.

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.

Path parameters

  • slugstringrequired

    The source's identifier (ctx-...).

Query parameters

  • organizationstringrequired

    The organization's identifier (slug).

Request body application/json

The key and model to run with.

  • virtual_keystringrequired

    The virtual key (vk-...) the selections run on and are billed to: one selection call per case. It must have access to the source.

    At least 1 characters

  • modelstring

    The model that chooses the sections. Default gpt-6-luna.

    At least 0 characters · At most 200 characters

  • budgetinteger<int32>

    Most tokens of section text per question, 200 to 100000; an expected section that does not fit is a miss. Default 6000.

  • freshboolean

    Skip the selection cache, so every question is a real selection call and the run's selection times are what a new question takes. Default false: a question asked in the last day reuses its selection at no cost.

Responses

202application/json

Accepted

  • idstring

    The run's id.

  • statusenum<string>

    RUNNING, COMPLETED or FAILED.

    One of "RUNNING", "COMPLETED", "FAILED"

  • virtual_keystring

    The virtual key the selections ran on.

  • modelstring

    The model that chose the sections.

  • budgetinteger<int32>

    Tokens of section text allowed per question.

  • case_countinteger<int32>

    Test cases in the run.

  • recallnumber<double>

    Mean section recall over the cases, 0 to 1. Absent until the run completes.

  • hit_ratenumber<double>

    Share of cases where at least one expected section was chosen, 0 to 1. Absent until the run completes.

  • freshboolean

    True when the run skipped the selection cache, so every selection time is a real selection call.

  • select_p50_msinteger<int64>

    Median selection time over the questions not answered from the selection cache, in milliseconds. Absent until the run completes, or when every question came from the cache.

  • select_p95_msinteger<int64>

    95th-percentile selection time over the same questions, in milliseconds.

  • errorstring

    Why the run failed.

  • resultsobject[]

    Per-case results, in the test set's order. Present when you get one run, absent in lists.

    Child attributes
    • case_idstring

      The test case's id.

    • expected_sectionsstring[]

      The sections the case expects.

    • selected_sectionsstring[]

      The sections the selection chose within the budget, most relevant first.

    • statusstring

      The selection's status, as in x-context-status.

    • recallnumber<double>

      Share of the expected sections that were chosen, 0 to 1.

    • cachedboolean

      True when the choice came from the selection cache.

    • select_msinteger<int64>

      Milliseconds the selection took (0 when every section fit the budget and none had to be chosen).

  • created_bystring

    Who started the run.

  • started_atstring<date-time>

    When the run started.

  • finished_atstring<date-time>

    When it finished.

NVIDIA Inception Program member

VectorAxis is built by GK Labs, a member of NVIDIA Inception.