Skip to main content
The get_page_screenshot method renders one page of a source file (PDF, image, or Office document) as a base64-encoded PNG. It is the recommended way to display visual previews for citations returned by ask — call it lazily, only when the user actually wants to inspect a citation.

Method overview

Sync Method

client.sources.get_page_screenshot()

Async Method

await client.sources.get_page_screenshot() (using AsyncGraphor)

Method signature

Parameters

Supported file types

Plain-text and other non-visual formats are not supported and will raise NotFoundError.

Response

Code examples

Basic — render and save a page

Lazy-loading citations from ask

The recommended pattern: call ask, render only the pages the user inspects.

Async usage

Best practices

  1. Lazy-load on user interaction — call this method only when the user hovers, clicks, or expands a citation. Most citations are never inspected.
  2. Cache by (file_id, page_number) — the response is deterministic for a given key. Cache the base64 string in memory for the duration of the session to avoid re-rendering.
  3. Pick max_width for the surface you’re rendering500 for tooltips/popovers, 900 (default) for inline cards, 1200+ only when the user opens a full preview.
  4. Prefer this over include_citation_images=True in ask — embedding base64 inline bloats the JSON payload by hundreds of KB per cited page and runs all renders synchronously before the answer returns. See When to use include_citation_images.

Error handling

Chat

Ask questions and receive grounded answers with citations

List Sources

Discover the file_id values you can pass here