Skip to main content
Give your model numbered sources and get back an answer whose every claim points to a URL. The SDKs render search results as a numbered block with to_context(), and cited() returns the same results in the same order, so [2] in the answer always maps to the second source the model saw.

Parameters

The search request sets how much text each result carries: to_context() and cited() take the same options, which shape the rendered block: In Rust, pass the options to to_context_with and cited_with. In TypeScript, maxSnippetChars needs keenable 0.2.0 or later.

Build a cited prompt

This sample searches, renders the results as a block of at most 3,000 characters, wraps it in a prompt that asks for numbered citations, and prints the matching source list. Send the prompt to any model. It runs with no API key:
You see the prompt with one [n] Title (url) header per source, then the source list in the same order:
Example output · results vary
The curl tab numbers the raw results with jq, because HTTP returns the results as JSON with no block.

How the block is built

to_context() cleans each result’s text first: it drops images, resolves relative links and flattens tables. It cuts each result’s text at a word boundary near the per-result limit and ends it with ”…”. Then it adds whole results in rank order and stops before the first result that would take the block past the character limit, so the block never ends in the middle of a source. The first result is always kept, even if it is longer than the limit on its own. A header shows - published <timestamp> when the page has a known publish date. The limits apply to the rendered block only: each result’s snippet keeps its full text.

Cite a fetched page

A fetched page has its own to_context(), which renders it in the same [1] Title (url) shape and cuts the content at the character limit. Use it when you fetch a page after a search and want the model to cite it the same way.

Common mistakes

API reference