Skip to main content
Add source citations to your RAG responses so users can verify information and explore the original documents. Citations link each statement in the generated response back to the specific chunk it came from.
In the hosted chat and the playground, citations are automatic. Agentset always applies its citation rules on top of your system prompt, so customize the prompt freely — don’t add citation-format instructions to it. This page is for building citations into your own app with the search API.

Return chunk IDs with your context

Include each chunk’s id in the context you pass to the model. IDs stay stable no matter how many searches produced the context, which makes them more reliable than position-based numbering.

Instruct the model to cite sources

Use a system prompt that tells the model to cite by chunk ID.
The model will respond with inline citations:

Render citations in your UI

Parse the bracket notation, look each ID up in your search results, and render citations as clickable elements. Leave unknown IDs as plain text.
If you prefer numbered pills like [1] in your UI, keep IDs in the model contract and map each cited ID to a display number at render time. Asking the model to cite by list position instead breaks down once context comes from multiple searches or gets deduplicated.

Next steps

  • API Reference — Search endpoint parameters and options
  • Agentic Search — Let the model search on its own for complex questions
  • Ranking — Improve citation relevance with reranking