prompt-inspector-ux 🔍
prompt-inspector-ux is a local, interactive middleware and visualizer for generative AI and Agentic workflows. It intercepts outgoing LLM API payloads pre-flight and streams them to a local dashboard, allowing you to visualize exactly what tokens, images, audio, documents (PDFs, Word docs), and templates you are sending to model providers before making API requests.
📚 Interactive Documentation
For detailed installation guides, programmatic APIs, and configuration references: 👉 prompt-inspector-ux Documentation Site
Key Features
- One-Line Integration: Just add
import prompt_inspector; prompt_inspector.inspect()at the top of your script. - Multi-Provider Patches: Automatically hooks and captures:
- OpenAI (Sync/Async Chat Completions, Azure OpenAI, Groq, and compatible endpoints).
- Anthropic (Sync/Async Messages).
- Google GenAI (New
google-genaiand legacygoogle-generativeaiclient model calls).
- Framework Agnostic: Works out of the box with LangChain, LangGraph, and LlamaIndex by intercepting the underlying client SDK calls.
- Rich Multimodal Visualizer Dashboard:
- Prompt timeline sidebar tracking all model queries.
- HTML Document Sandbox: Preview parsed templates inside a secure iframe.
- Code Panel: View code snippets, syntax highlighted.
- Inline Document Reader: Scroll and inspect PDFs and Word Documents (.docx) directly in the dashboard UI (powered by in-browser Mammoth.js conversion).
- Media Players: Native HTML5 players for audio waves (
.wav,.mp3) and video tokens. - Zero Overhead: Serves local files from the filesystem via a loopback port instead of sending massive base64 strings, saving CPU and memory.
Installation
Install using pip:
pip install prompt-inspector-ux
Or using uv:
uv add prompt-inspector-ux
Quickstart
Just call inspect() at the very beginning of your application. This spins up the server in a background thread and opens the browser tab to your dashboard:
import prompt_inspector
from openai import OpenAI
# 1. Start the visualizer and auto-patch all SDKs
prompt_inspector.inspect(port=8989)
# 2. Make your LLM calls normally (no other changes required!)
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o",
messages=[
{"role": "user", "content": "Explain quantum mechanics in 1 sentence."}
]
)
Run Standalone CLI
To run the visualization server independently (for example, to persist your trace history across different script runs):
prompt-inspector start --port 8989
Then open http://localhost:8989 in your browser. Any scripts executing prompt_inspector.inspect() will detect the active server and stream traces to it.
Framework Integration Examples
1. LangChain / LangGraph
Since LangChain packages wrap standard provider SDKs under the hood, prompt-inspector captures them automatically with zero additional config or callbacks:
import prompt_inspector
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage, SystemMessage
prompt_inspector.inspect()
# Works with standard, Groq, Azure, or self-hosted OpenAI instances
llm = ChatOpenAI(
model="qwen/qwen3.6-27b",
base_url="https://api.groq.com/openai/v1",
api_key="your-groq-key"
)
messages = [
SystemMessage(content="You are an expert systems architect."),
HumanMessage(content="Explain Reciprocal Rank Fusion.")
]
llm.invoke(messages)
2. Google GenAI (Gemini)
Gemini supports rich multimodal prompts including images and document PDFs:
import prompt_inspector
from PIL import Image
from google import genai
from google.genai import types
prompt_inspector.inspect()
client = genai.Client()
# Send text, PIL Images, and PDF bytes directly
contents = [
"Analyze this workflow diagram and summarize the text inside the PDF:",
Image.open("flowchart.png"),
types.Part.from_bytes(
data=open("document.pdf", "rb").read(),
mime_type="application/pdf"
)
]
client.models.generate_content(
model='gemini-2.5-flash',
contents=contents
)
3. LlamaIndex
LlamaIndex models are patched automatically through their underlying completions layer:
import prompt_inspector
from llama_index.llms.openai import OpenAI
prompt_inspector.inspect()
llm = OpenAI(model="gpt-4")
response = llm.complete("Explain Retrieval-Augmented Generation.")
4. Anthropic Claude
Captures message blocks, system prompts, and media objects:
import prompt_inspector
import anthropic
prompt_inspector.inspect()
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1000,
temperature=0,
system="Respond only in markdown.",
messages=[
{
"role": "user",
"content": [
{
"type": "text",
"text": "What does this code do?"
}
]
}
]
)
Multimodal Payload Examples (Audio, Video, PDF, Word & Combinations)
prompt-inspector fully extracts and visualizes various document and media formats. Here is how you can send them using different SDKs and model providers.
1. Google GenAI (Gemini)
Gemini models support native multimodal inputs. You can send images (using PIL), audio, video, PDFs, and Word docs as inline bytes:
import base64
import prompt_inspector
from PIL import Image
from google import genai
from google.genai import types
prompt_inspector.inspect()
client = genai.Client()
# Helper to read file bytes
def read_bytes(path):
with open(path, "rb") as f:
return f.read()
# --- Example A: Sending an Audio File ---
audio_contents = [
"Analyze the sound cue in this clip:",
types.Part.from_bytes(data=read_bytes("instructions.wav"), mime_type="audio/wav")
]
client.models.generate_content(model="gemini-2.5-flash", contents=audio_contents)
# --- Example B: Sending a Video File ---
video_contents = [
"Provide a summary of the activity in this video:",
types.Part.from_bytes(data=read_bytes("screen_recording.mp4"), mime_type="video/mp4")
]
client.models.generate_content(model="gemini-2.5-flash", contents=video_contents)
# --- Example C: Sending a PDF Document ---
pdf_contents = [
"Verify the ranking equations in this PDF:",
types.Part.from_bytes(data=read_bytes("equations.pdf"), mime_type="application/pdf")
]
client.models.generate_content(model="gemini-2.5-flash", contents=pdf_contents)
# --- Example D: Sending a Word Document (.docx) ---
docx_contents = [
"Summarize this project brief:",
types.Part.from_bytes(
data=read_bytes("project_brief.docx"),
mime_type="application/vnd.openxmlformats-officedocument.wordprocessingml.document"
)
]
client.models.generate_content(model="gemini-2.5-flash", contents=docx_contents)
# --- Example E: Combination Payload (Text + Image + Audio + PDF) ---
complex_contents = [
"Review the flowchart, listen to the audio instructions, and verify with the pdf sheet:",
Image.open("flowchart.png"),
types.Part.from_bytes(data=read_bytes("instructions.wav"), mime_type="audio/wav"),
types.Part.from_bytes(data=read_bytes("formulas.pdf"), mime_type="application/pdf")
]
client.models.generate_content(model="gemini-2.5-flash", contents=complex_contents)
2. OpenAI / Groq / Compatible Endpoints
For OpenAI-compatible endpoints, you pass multimodal structures inside the messages array:
import base64
import prompt_inspector
from openai import OpenAI
prompt_inspector.inspect()
client = OpenAI()
def encode_b64(path):
with open(path, "rb") as f:
return base64.b64encode(f.read()).decode("utf-8")
# --- Combination Payload (Text + Image + Audio + Document) ---
messages = [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Analyze the diagram, hear the sound, and verify with the PDF document:"
},
{
"type": "image_url",
"image_url": {"url": f"data:image/png;base64,{encode_b64('diagram.png')}"}
},
{
"type": "input_audio",
"input_audio": {
"data": encode_b64("instructions.wav"),
"format": "wav"
}
},
{
"type": "document",
"document": {
"data": {
"base64": encode_b64("reference.pdf")
},
"mime_type": "application/pdf"
}
}
]
}
]
client.chat.completions.create(
model="gpt-4o",
messages=messages
)
Local Development Setup
If you want to run or contribute to prompt-inspector locally:
-
Clone the repository:
git clone https://github.com/SachinMishra-ux/prompt-inspector.git cd prompt-inspector
-
Set up the virtual environment:
uv sync -
Build the React Dashboard UI: The frontend is built using Vite and Tailwind CSS. Build the static assets:
npm run build --prefix ui
This compiles the bundle directly into the python package's
static/directory so it is distributed with the PyPI wheel. -
Run Unit Tests:
uv run python3 -m unittest discover -s tests/unit
License
This project is licensed under the MIT License.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prompt_inspector_ux-0.1.2.tar.gz.
File metadata
- Download URL: prompt_inspector_ux-0.1.2.tar.gz
- Upload date:
- Size: 15.2 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bcd5c980a3e3979fbeea7a7f476e462545f2592a37a0a96e5f8f822b987fe74d
|
|
| MD5 |
84d598b19bc1bfafe54e1e0c501b02be
|
|
| BLAKE2b-256 |
a884f19d876daf648fcbe1a72fa5c36c38aafa5976f3b1fa22a44eb15bbcac35
|
Provenance
The following attestation bundles were made for prompt_inspector_ux-0.1.2.tar.gz:
Publisher:
python-publish.yml on SachinMishra-ux/prompt-inspector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prompt_inspector_ux-0.1.2.tar.gz -
Subject digest:
bcd5c980a3e3979fbeea7a7f476e462545f2592a37a0a96e5f8f822b987fe74d - Sigstore transparency entry: 2569722491
- Sigstore integration time:
-
Permalink:
SachinMishra-ux/prompt-inspector@78327fe50325b03aa24d644124e8097da309bf15 -
Branch / Tag:
refs/tags/V0.1.2 - Owner: https://github.com/SachinMishra-ux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@78327fe50325b03aa24d644124e8097da309bf15 -
Trigger Event:
release
-
Statement type:
File details
Details for the file prompt_inspector_ux-0.1.2-py3-none-any.whl.
File metadata
- Download URL: prompt_inspector_ux-0.1.2-py3-none-any.whl
- Upload date:
- Size: 200.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1f55e8dec59d82ad433ca5c3a8298fc440250b4a73a55f4935b8685558e2fdb
|
|
| MD5 |
b11bce6aa8ad06be6dde901affb56961
|
|
| BLAKE2b-256 |
854e0a524e4f4c70e4fd5e31cbacab64f41863dc3bb109380a22be90f923cee5
|
Provenance
The following attestation bundles were made for prompt_inspector_ux-0.1.2-py3-none-any.whl:
Publisher:
python-publish.yml on SachinMishra-ux/prompt-inspector
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prompt_inspector_ux-0.1.2-py3-none-any.whl -
Subject digest:
a1f55e8dec59d82ad433ca5c3a8298fc440250b4a73a55f4935b8685558e2fdb - Sigstore transparency entry: 2569722497
- Sigstore integration time:
-
Permalink:
SachinMishra-ux/prompt-inspector@78327fe50325b03aa24d644124e8097da309bf15 -
Branch / Tag:
refs/tags/V0.1.2 - Owner: https://github.com/SachinMishra-ux
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@78327fe50325b03aa24d644124e8097da309bf15 -
Trigger Event:
release
-
Statement type: