/ask-sources without paying the payload cost of inlining base64 in the answer.
Endpoint overview
HTTP Method
GET
Authentication
This endpoint requires authentication using an API token. Include your API token as a Bearer token in theAuthorization header.
Learn how to create and manage API tokens in the API Tokens guide.
When to use this endpoint
This is the recommended way to display page previews for citations returned by/ask-sources.
- The default
/ask-sourcesresponse does not includeimage_base64— clients should call this endpoint per citation, only when the user actually needs to see the page (e.g. on hover, on click, or when rendering a side panel). - Each render is keyed by
(file_id, page_number)and returns aCache-Control: public, max-age=3600hint so browsers and CDNs can cache the image bytes. - Prefer this endpoint over passing
include_citation_images=trueto/ask-sourceswhenever the answer may cite many pages, or when latency / payload size matters.
Request format
Headers
Path parameters
Query parameters
Supported file types
Plain-text and other non-visual formats are not supported and will return
404.
Response format
Success response (200 OK)
Error responses
Examples
cURL
Python (rendering and saving a citation)
JavaScript (decoding and rendering inline)
Best practices
- Lazy-load on user interaction — call this endpoint only when the user hovers, clicks, or expands a citation. Most citations are never inspected.
- Cache by
(file_id, page_number)— the response is deterministic for a given key. The endpoint returnsCache-Control: public, max-age=3600; respect it on the client to avoid re-rendering the same page. - Pick
max_widthfor the surface you’re rendering —500for tooltips/popovers,900(default) for inline cards,1200+ only when the user opens a full preview. - Combine with
/ask-sourcescitations — pair this endpoint with the structuredcitationsarray from/ask-sourcesrather than parsing the inline[N]markup.
Related
Chat API
Ask questions and receive grounded answers with citations
List Sources
Discover the
file_id values you can pass here
