Context sources
A context source is a document your organization uploads once, such as a runbook, a policy or a product manual. When a request names it, the gateway picks the sections that answer the request and adds only those, so the model answers from your documents without your application searching them. Which keys may use which documents, and every use, is recorded.
- Governed. No key can use a document until a workspace admin gives it access, and the audit log records every change and every agent read.
- Only what is needed. A request gets the relevant sections within a token budget, not the whole document.
- No code change. One header, or a default on the virtual key, works with the OpenAI SDK, the Claude SDK and the Responses API, and agents can read the same documents over MCP.
- Kept private. Section text is encrypted per organization and never written to request logs; a log row names the sections, not their text.
On Context sources, upload a Markdown, HTML or PDF file of up to 15 MB, give it a name, and pick the virtual key that pays for indexing. The gateway:
- splits the document into sections along its headings (pages are kept for PDFs). A document that numbers its clauses without headings, as most contracts do, is split at each numbered clause instead (“4.2 Payment.”, “ARTICLE IV”, “Schedule B”);
- scans it for prompt injection and secrets. A finding holds the source as QUARANTINED until a workspace admin reviews the findings and releases it;
- writes a one-sentence summary of each section with a model on that virtual key (default gpt-6-luna), billed to the key like any request. The source is then READY.
The Outline tab shows the sections with their summaries. Selection reads these summaries, so a workspace admin can rewrite one that misses the point; reindexing keeps the edit. A failed indexing run can be retried with another key or model. Uploading through the API is in the API reference (Context sources).
On the source’s Key access tab, tick the virtual keys that may use it. A new source has no keys; a request on any other key naming the source is refused. The same tab sets which keys use the source by default and which MCP keys may read it.
Name the source in the x-context-source header (up to 5, comma-separated). It works on /v1/chat/completions, the Claude SDK’s /v1/messages and the /v1/responses API, streamed or not:
curl https://api.vectoraxis.ai/v1/chat/completions \
-H "Authorization: Bearer $VECTORAXIS_VIRTUAL_KEY" \
-H "x-context-source: ctx-1a2b3c4d5e6f7a8b" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-6-luna",
"messages": [{"role": "user", "content": "How do I roll back a release?"}]}'The gateway reads the outline of each source, asks a selection model on your key which sections answer the last user message, and adds their text to the request before guardrails run. The answer’s x-context-status says what happened and x-context-sections lists the sections added:
| Status | Meaning |
|---|---|
| APPLIED | Sections were added. |
| LOW_CONFIDENCE | Sections were added, but the selection was unsure they answer the request. |
| NO_MATCH | No section is relevant; the request was sent without context. |
| NO_QUESTION | The request has no user text to choose for. |
| SELECT_FAILED | Selection failed; the request was sent without context. |
| SELECT_TIMEOUT | Selection took longer than its time limit; the request was sent without context. |
| UNAVAILABLE | The key’s default sources can no longer be used (deleted, access removed, or not ready). |
When every section of the sources fits the token budget, the gateway adds them all and makes no selection call, so small documents add no selection time. Further headers set the token budget (default 6,000), the selection model, a time limit on selection (default 8 seconds), and whether a request should fail rather than go out without context; they are described with every header in Request headers.
With a routing config. To use context sources with x-config, send your virtual key as well. The key must have access to the sources, and it pays for choosing the sections; its default sources apply too. The sections are chosen once, so whichever target the config picks, including a fallback, answers from the same sections:
curl https://api.vectoraxis.ai/v1/chat/completions \
-H "Authorization: Bearer $VECTORAXIS_VIRTUAL_KEY" \
-H "x-config: cfg-support-fallback" \
-H "x-organization: acme" \
-H "x-context-source: ctx-1a2b3c4d5e6f7a8b" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-6-luna",
"messages": [{"role": "user", "content": "How do I roll back a release?"}]}'Long documents often point to themselves. A clause near the end of a contract says “up to the Cap in Section 1.1”, or a policy says “at the rates in Schedule B”. The answer then depends on two places in the document: the section that answers the question, and the section it points to. The gateway follows those pointers for you.
Good to know:
- It costs nothing extra. Finding and adding the referenced sections needs no model call; you pay only for the added text, like any other context.
- Your chosen sections come first. Referenced sections use at most 30% of the token budget, so they never push out a section that was chosen for the question.
- One step only. A referenced section’s own references are not followed.
- Numbered references only. Words such as “the foregoing” or “as defined above” do not name a section, so they are not followed.
- See it happen. Try a question marks each added section “Added because n14 refers to it”, and in Request logs those sections are shown in blue, marked “ref”.
Under Use by default on Key access, a key with access can use the source on every request, with no header and no code change. A key can have up to 5 default sources. A request’s own x-context-source replaces the defaults, and x-context-source: none turns them off. A default that can no longer be used is skipped instead of failing the request.
Agents connected to the gateway’s own MCP server, https://mcp.vectoraxis.ai/s/vectoraxis with an MCP key, can browse and read the sources that key was given (Key access, MCP keys):
| Tool | What it returns |
|---|---|
| context_sources | The sources the key may read, with a summary of each. |
| context_outline | A source’s sections: id, title, pages, size and summary. |
| context_read | The text of up to 8 sections, at most 30,000 tokens per call, and the sections each one refers to, so the agent can read those too. Recorded in the source’s audit log. |
The agent’s own model decides which sections to read, so these tools make no model call and cost nothing beyond the agent’s own tokens. Setting up an agent is in Connecting agents.
- Provider prompt caching. The added sections are marked for the provider’s prompt cache on Anthropic (and Claude on Vertex AI) and on OpenAI models from GPT-5.6, so the same sections are billed at the cache-read rate while the provider keeps them. See Provider prompt caching.
- Response cache. With x-cache-mode: simple, a request that gets the same sections and the same question is a hit. With semantic, similar questions on the same sources share an answer; answers never cross to other documents.
- Try a question shows which sections a question would get on a chosen key, drawn step by step, and can ask the model with them.
- Test set holds questions with the sections that should answer them. A run reports how many were found (recall) and how long selection took (median and 95th percentile), so you can see the effect of an edited summary or another selection model. Skip the cache times every question as a new one.
- In Request logs, a request with context shows what was considered, chosen and added, and links to its selection call.
A source can be deleted after a number of days (Retention) or by hand. Deleting removes its sections, its key access and its place in every key’s defaults; the audit log is kept. The uploaded file itself is never stored, only the parsed section text.