Skip to Content
Introducing PageIndex Flash
CookbookMultimodal

Multimodal Retrieval & Understanding

Some answers are in a document’s pictures, not its text. PageIndex Cloud saves a document’s images when it indexes it, and the agent can fetch one and show it to a model that can see images.

Ask what the image on page 5 of a pump manual shows, in two steps:

  1. Ask the question.
  2. Look at the image the agent fetched.

Set up

pip install -U pageindex

The chat model has to read images, so pick a vision-capable one:

import os from pageindex import PageIndexClient os.environ["PAGEINDEX_API_KEY"] = "pageindex_demo_readonly_key" os.environ["OPENAI_API_KEY"] = "Your OpenAI API key here" client = PageIndexClient(index="cloud", chat="gpt-5.6-luna") doc_id = "pi-cmu6jnfbb001k09ntgqmw5swr" # a pump manual on the demo account

Ask about the image

for chunk in client.chat("Describe the image in page 5", doc_id=doc_id, stream=True): print(chunk, end="", flush=True)
[tool_call] get_document_structure {"doc_name": "49eeaa61-....pdf", "folder_id": "cmu6jms8l000004l3cpmp7k6c"} [tool_call] get_page_content {"doc_name": "49eeaa61-....pdf", "folder_id": "cmu6jms8l000004l3cpmp7k6c", "pages": "5"} [tool_call] get_document_image {"image_path": "49eeaa61-....pdf/img-7.jpeg", "folder_id": "cmu6jms8l000004l3cpmp7k6c"} Page 5 shows a schematic of the Hydra-Cell pump installation: - The pump is positioned to the right, with a **pressure gauge** and **pressure regulator** on the discharge side. - A **suction line** runs from the pump toward the inlet/supply tank. - A **vacuum/pressure gauge** monitors the suction line. - Fluid exits through the **discharge line** at the top left. - A **bypass line** returns fluid from the pressure-regulator area to the inlet tank. - Arrows indicate the flow direction through the suction, discharge, and bypass lines.

The agent read page 5 and found that it has an image, img-7.jpeg. It fetched the image with get_document_image and described what it saw.

Show the image

get_document_image() returns a link to the same image:

from IPython.display import Image Image(url=client.get_document_image(doc_id, "img-7.jpeg"))
Line drawing of a pump installation: the pump at the right with a pressure gauge and pressure regulator, a suction line and a bypass line running to an inlet tank at the left, a vacuum/pressure gauge on the suction line, and a discharge line at the top left. Arrows mark the flow.

Every labeled part of the drawing is in the description.

Result

The answer comes from the picture, not the text around it.

The notebook runs this with your key: open it in Colab .

Last updated on