Skip to main content
POST /v1/attributions/heatmap returns the raw material behind every attribution: how much attention each answer token pays to each document token. Use it for research, debugging, and custom visualizations. For citations and highlights, use POST /v1/attributions, which does the aggregation for you.

Shape

The matrix is sparse and uses coordinate (COO) format. Three parallel arrays list only the cells above threshold:
This excerpt is from the answer Revenue improved because enterprise demand increased. Answer token 1 ( improved) puts 76% of its attention on document token 1 (also improved). Token ranges usually include the leading space. row, col, and data always have the same length. shape and both offset arrays always describe every token, even when threshold filters out most cells. Each answer token’s attention adds up to 1 across everything the model reads, including the question and prompt. So the values in one row add up to at most 1.

Map cells back to text

Request "offset_encoding": "utf-32" when you slice in Python.

Threshold

threshold sets the smallest data value included. The default is 0.001.

Limits

The heatmap comes from a single model context and is never windowed. document is capped at 400,000 characters, and a document that still does not fit the model’s context fails with 413 prompt_too_long. See Long documents. Copyable code for dense matrices and plots is in the raw heatmap cookbook.