Skip to main content

DeepSource

CI

pixelrag-langchain

A LangChain Tool + Retriever for PixelRAG — visual, screenshot-native search for AI agents.

This is an unofficial, community-built integration. It is not affiliated with, endorsed by, or maintained by StarTrail-org or the PixelRAG paper authors. All credit for the underlying research and the pixelrag-serve engine belongs to them — see Credits.

Why visual search

Most agent pipelines fetch a page, strip the HTML down to text, chunk it, and embed the chunks. That throws away tables, charts, and layout — information that's often exactly what answers the question. PixelRAG (Wang, Li, Wang, Teiletche, Jin, Zaharia, Gonzalez, Min — UC Berkeley, Princeton, EPFL, Databricks) skips the text step entirely: it renders documents to screenshot tiles, retrieves over the images directly, and hands the retrieved tiles to a vision-language model to read.

This package doesn't reimplement any of that. It just wraps the existing pixelrag-serve search API so it drops into a LangChain (or LangGraph) agent as a normal tool/retriever.

Architecture

flowchart LR
    A["Page / PDF"] --> B["pixelrag-render\n(screenshot tiles)"]
    B --> C["pixelrag-embed\n(Qwen3-VL-Embedding)"]
    C --> D["FAISS index\n(pixelrag-serve)"]
    D -- "this package talks to D" --> E["PixelRAGRetriever /\nPixelRAGSearchTool"]
    E --> F["Your LangChain / LangGraph agent"]
    F --> G["VLM reader\n(your model of choice)"]

Everything left of the dotted line (renderembedindexserve) is upstream PixelRAG, run by you. This package is the box on the right: a client + LangChain adapters.

Install

pip install pixelrag-langchain

This installs only the LangChain adapter (httpx, langchain-core, pydantic) — no GPU, no torch, no CUDA. It talks to a pixelrag-serve instance over HTTP; it doesn't run embedding or indexing itself.

Quickstart — zero setup

Upstream PixelRAG runs an official public production endpoint — no API key or index download required. Nothing to install beyond this package:

from pixelrag_langchain import PixelRAGRetriever, PixelRAGConfig

retriever = PixelRAGRetriever(config=PixelRAGConfig.hosted())
docs = retriever.invoke("What is the capital of France?")

for doc in docs:
    print(doc.metadata["score"], doc.metadata["source"])
    print(doc.metadata["image_url"])  # fetchable PNG URL

PixelRAGConfig.hosted() points at https://api.pixelrag.ai, upstream's documented production endpoint. It uses their infrastructure and Wikipedia index, not your documents. PixelRAG does not publish throughput, latency, or rate-limit guarantees; self-host when you need guaranteed capacity or private data.

Retrieving the actual tile images

Search results identify each screenshot with article_id, tile_index, and chunk_index. Version 0.2 turns those coordinates into the upstream-supported /tile/... URL; the server-relative path field is informational and should not be used to construct URLs.

Use the client when you want explicit control over image downloads:

from pixelrag_langchain import PixelRAGClient, PixelRAGConfig

with PixelRAGClient(PixelRAGConfig.hosted()) as client:
    tile = client.search("diagram of a transformer architecture", n_docs=1)[0]
    print(client.tile_url(tile))
    png_bytes = client.fetch_tile(tile)

The separate GET /tile/{article_id}/{tile_index}/{chunk_index} request is the recommended default because it keeps search responses small. If you need every image inline, explicitly request base64 data:

with PixelRAGClient(PixelRAGConfig.hosted()) as client:
    tiles = client.search("quarterly revenue chart", include_images=True)
    print(tiles[0].image_base64)

PixelRAGRetriever exposes the coordinate URL in both metadata["tile_url"] and metadata["image_url"]. PixelRAGSearchTool provides tile_image_url() and fetch_tile_bytes() for structured LangGraph workflows. See examples/langgraph_node.py for a complete multimodal-message handoff.

The API is currently pre-1.0. Its authoritative machine-readable contract is served at /openapi.json; this package parses additive hit fields leniently.

For operational checks, client.health() returns a best-effort boolean and client.status() returns the server's current index diagnostics.

Quickstart — your own documents

For real use — your own PDFs, internal docs, scraped pages — run pixelrag serve yourself:

pip install 'pixelrag[serve]'

# Download a pre-built Wikipedia index, or build your own from `pip install 'pixelrag[index]'`
huggingface-cli download StarTrail-org/pixelrag-faiss-indexes \
  --repo-type dataset --include "search_index_normed_v2/*" --local-dir ./index

pixelrag serve --index-dir ./index/search_index_normed_v2 --port 30001
from pixelrag_langchain import PixelRAGRetriever, PixelRAGConfig

retriever = PixelRAGRetriever(config=PixelRAGConfig(base_url="http://localhost:30001"))
docs = retriever.invoke("What is the capital of France?")

As an agent tool

from langchain.agents import create_agent
from pixelrag_langchain import PixelRAGSearchTool, PixelRAGConfig

tool = PixelRAGSearchTool(config=PixelRAGConfig.hosted())  # or base_url="http://localhost:30001"
agent = create_agent(model="your-model", tools=[tool])

Nothing here defaults to a single host silently — PixelRAGConfig(base_url=...) accepts any pixelrag-serve-compatible URL, including your own deployment; .hosted() is one explicit opt-in line, not a hidden default.

What this package is not

  • Not a reimplementation of PixelRAG's render/embed/index/serve pipeline — install the upstream project for that.
  • Not a hosted service itself. PixelRAGConfig.hosted() is a convenience pointer to upstream's public endpoint, not infrastructure we run.
  • Not affiliated with StarTrail-org, Berkeley Sky Computing Lab, BAIR, or the Berkeley NLP Group, who built the actual PixelRAG engine and research this wraps.

Benchmarks (from the upstream paper, not measured by this package)

Reported in PIXELRAG: Web Screenshots Beat Text for Retrieval-Augmented Generation (arXiv:2606.28344):

Metric Text-based RAG PixelRAG Context
Prompt tokens, agentic benchmark 37.5M 3.6M MoNaCo multi-step agent benchmark
Accuracy gain baseline up to +18.1% vs. text-based RAG baselines, across NQ/SimpleQA/MMSearch/LiveVQA
Token cost via image compression up to 3x reduction lower-resolution tiles, accuracy preserved

These are the paper's own reported numbers, not something we independently reproduced — treat them as a starting point for your own evaluation on your workload, not a guarantee.

Development

git clone https://github.com/navneet-singh2907/pixelrag-langchain
cd pixelrag-langchain
pip install -e ".[dev]"
pytest

Credits

  • PixelRAG engine, paper, and research: Yichuan Wang, Zhifei Li, Zirui Wang, Paul Teiletche, Lesheng Jin, Matei Zaharia, Joseph E. Gonzalez, Sewon Min. Paper · Code (Apache-2.0).
  • This package: an independent, unofficial LangChain adapter around that work.

License

Apache-2.0 — see LICENSE. This is a new work built to talk to PixelRAG over HTTP; it does not vendor or redistribute any upstream PixelRAG code, so no NOTICE carryover is required, but attribution is given above regardless because it's their research this is built on.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pixelrag_langchain-0.2.1.tar.gz (21.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pixelrag_langchain-0.2.1-py3-none-any.whl (18.3 kB view details)

Uploaded Python 3

File details

Details for the file pixelrag_langchain-0.2.1.tar.gz.

File metadata

  • Download URL: pixelrag_langchain-0.2.1.tar.gz
  • Upload date:
  • Size: 21.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for pixelrag_langchain-0.2.1.tar.gz
Algorithm Hash digest
SHA256 433c54dbda2d746172d04206af508c99c378ed825ff53b9df43670ea0f1f5b0b
MD5 743ccb687b957988266b77cf63861b7d
BLAKE2b-256 89c7463c3962b9839ef36bf6a94f7b60b3b9d43234e06a637224157dbfa6b13a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixelrag_langchain-0.2.1.tar.gz:

Publisher: publish.yml on navneet-singh2907/pixelrag-langchain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pixelrag_langchain-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pixelrag_langchain-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25490055074a750acf06aa0bde3f6e3f94aa5fa6e1073f5057dee2fb2e7f0953
MD5 a3a81d869cb9e3cb8d4eb5be32a0b023
BLAKE2b-256 3a22451d13a6dac995807113a0e1061a66eb7bc87651bb802cbbd74af6539a4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pixelrag_langchain-0.2.1-py3-none-any.whl:

Publisher: publish.yml on navneet-singh2907/pixelrag-langchain

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page