pivision
Allows routing vision and image-generation requests to OpenAI-compatible endpoints, including OpenAI, by configuring the base URL and API key.
Provides vision capabilities (image and video recognition) through Xiaohongshu Dots Studio's API.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@pivisionDescribe what's in the image I attached"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
pivision โ MCP Vision & Image Generation Server
One service, two ways to use it: an MCP server for AI assistants (CodeBuddy / Claude Desktop / any MCP client), and a FastAPI HTTP API (port 7002) for your own programs, scripts, and browser.
pivision is a plug-and-play "see images + draw images" toolbox. It recognizes what's inside a local image or video link, and generates images from a text description โ with no coding required to use it.
๐ก Free to use โ both the vision and image-generation APIs backed into pivision are currently free, with generous quotas that are enough for personal use and large projects. You only need to register and get your own API keys (see Getting API Keys).
Think of
r-pic/r-vidas giving your LLM "eyes" โ your AI assistant can finally see the images and videos you hand it, describe them, and answer questions about them.
Vision (see): describe a local picture, parse a video URL โ the model's "eyes"
Generation (draw): text-to-image, infographic-to-image, image-to-image (reference + instruction)
Batch: run hundreds of tasks from a simple text file with resume support
โจ Features
6 MCP tools |
|
Dual interface | MCP (stdio) for AI clients + FastAPI HTTP server (8 endpoints, port 7002) for any program |
Adapter architecture | Two-layer adapters (vendor-specific + OpenAI-compatible generic). Add a new model = fill in |
5 isolated pipelines |
|
Multi-key pool | Generation keys support comma-separated pools; auto-rotate on |
Named instances | Multiple config instances per pipeline, selectable at call time via |
Smart fallback | Video config auto-falls-back to image config; named instances fall back to main instance field-by-field |
Batch engine |
|
Secure by design | Zero hardcoded keys, |
Related MCP server: Gemini Image MCP
๐ Architecture
pivision.py (entry, FastMCP "pivision")
โโโโโโโโโฌโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโ
r-pic r-vid g-pic/i-pic p-pic b-gen
โ โ โ โ โ
โผ โผ โผ โผ โผ
get_vision_adapter get_pipeline_adapter(pipeline, provider, instance)
(prefix VISION_ / (prefix GEN_IMAGE_ / GEN_INFOGRAPH_ / EDIT_IMAGE_,
VISION_VIDEO_ fallback) main instance + named instances)
โ โ โ โ
โผ โผ โผ โผ
/v1/chat/completions /v1/images/generations (url) ยท /v1/images/edits (JSON+base64)
(image / video_url) ยท openai_compat multipart (image-to-image)
api_server.py (FastAPI, :7002 โ same business layer)
/health ยท /tools ยท /r-pic ยท /r-vid ยท /g-pic ยท /i-pic ยท /p-pic ยท /b-gen
utils.py (save/naming/size/base64/batch/history)
adapters/__init__.py (adapter registry + factory + get_config_summary())
On disk: art/*.png ยท pivision_batch_results.txt ยท .bgen_progress.json ยท history.jsonCore design:
Pipeline prefix isolation โ the three generation pipelines read independent env vars (
GEN_IMAGE_*/GEN_INFOGRAPH_*/EDIT_IMAGE_*); switch backend per pipeline without touching code.Vision dual-branch fallback โ
r-vidreusesVISION_*whenVISION_VIDEO_*is not configured: one key set, two use cases.Enable switches โ each pipeline has
{PREFIX}_ENABLED(defaulttrue; set tofalseto fully disable it, no API calls are made).Named instances โ declare multiple config instances per generation pipeline (
{PREFIX}_INSTANCES), select at runtime with theinstancetool parameter.Multi-key pool โ comma-separated keys in
*_API_KEYS; automatic key rotation on401/403/429.
๐ Quick Start
Prerequisite: Python โฅ 3.11.
1. Install
cd pivision # wherever you cloned/unpacked the project
python -m venv .venv
.venv/bin/pip install -e .2. Configure .env
cp .env.example .envFill in your keys: vision โ VISION_API_KEY (video falls back to it automatically when empty); generation โ each section's *_API_KEYS (comma-separated for multiple keys). Pipelines without keys return โ ๆช้
็ฝฎ {xxx_API_KEYS} instead of making wrong requests.
2.5 Get API Keys (free)
Both backed APIs are currently free with generous quotas โ you only register once and grab your keys:
Pipeline | Provider | Where to register | Key to fill in |
Vision ( | dots (Xiaohongshu Dots Studio) | https://dots.ai/platform โ sign in with phone number, then create a key on the API Keys page |
|
Generation ( | SenseNova (SenseTime) | https://platform.sensenova.cn โ register + phone verify, then Console โ API Keys โ create an |
|
Both providers are OpenAI-compatible. If you already have another OpenAI-compatible key (OpenAI / DeepSeek / Moonshot / local gatewayโฆ), point
VISION_BASE_URL/*_BASE_URLto your own endpoint and reuse your existing key โ no extra registration needed.
3a. Use as MCP (for AI assistants)
Register the server in your MCP client (e.g. CodeBuddy โ Settings โ MCP Servers). The pic-config.json / mcp-register.json in the project are ready-to-merge templates:
{
"mcpServers": {
"pivision": {
"command": "<your-project-path>/.venv/bin/python",
"args": ["<your-project-path>/pivision.py"]
}
}
}Replace
<your-project-path>with the actual path on the target machine. The Python code itself uses relative paths โ only the registration JSON needs per-machine paths.
Start / verify:
cd pivision
.venv/bin/python pivision.pyThe service waits silently for the AI client to connect. Once registered, just chat with your assistant โ it will call the tools for you.
3b. Use as HTTP API (for programs & scripts)
cd pivision
.venv/bin/python api_server.pyExpected output:
INFO: Uvicorn running on http://127.0.0.1:7002
INFO: pivision API ๆๅกๅจๅฐฑ็ปช๏ผHTTP ็ซฏๅฃ 7002๏ผThe server listens on 127.0.0.1:7002 (local machine only). Run it in the background if you want it to survive closing the terminal:
nohup python api_server.py > pivision_server.log 2>&1 &
# check: curl http://127.0.0.1:7002/health
# stop: pkill -f api_server.py๐ MCP Tools
Every tool returns a string: success starts with โ
, failure with โ (with reason) โ MCP clients can judge by prefix.
r-pic โ Image recognition
r-pic(image_path, question="่ฏท่ฏฆ็ปๆ่ฟฐ่ฟๅผ ๅพ็็ๅ
ๅฎนใ", provider=None, model=None, max_tokens=1024)image_path: local image (PNG/JPG/WEBP/GIF), requiredquestion: what you want to know about the imagemax_tokens: response length cap, default 1024
r-vid โ Video recognition
r-vid(video_url, question="่ฏท่ฏฆ็ปๆ่ฟฐ่ฟๆฎต่ง้ข็ๅ
ๅฎนใ", provider=None, model=None, max_tokens=8192)video_url: must be a publicly accessible http/https link (local paths / LAN addresses won't work)max_tokens: default 8192 โ video parsing output is long, keep it high
g-pic / i-pic โ Text-to-image
g-pic(prompt, size="2752x1536", n=1, provider=None, instance=None)
i-pic(prompt, size="2752x1536", n=1, provider=None, instance=None)g-pic: general text-to-image (GEN_IMAGE pipeline)i-pic: infographics / posters / charts (GEN_INFOGRAPH pipeline, defaultsensenova-u1-fast)n: 1โ20;n>1is generated one-by-one (the official API supports one per call)instance: named instance, e.g."a"; unknown instance โ explicit error (no silent fallback)
p-pic โ Image-to-image (reference + instruction)
p-pic(prompt, image_path, size="2752x1536", provider=None, instance=None)image_path: reference image path (local), required โ sent asdata:image/*;base64,Data-URIOnly
n=1is allowed
b-gen โ Batch engine
b-gen(task, file_path, interval=0, resume=False, size="2752x1536", n=1)task:g-pic/i-pic/p-pic/r-pic/r-vidReads tasks line-by-line from a
.txt/.mdfile (see format below)resume=True: progress saved to.bgen_progress.json; re-run skips completed rows. Progress auto-invalidates if the task type or input file changes.interval: seconds between tasks (set 1โ2 to avoid rate limits)Results are written to
pivision_batch_results.txt
Task file format (one task per line):
| Line format | Example line |
| 1 prompt |
|
| 1 image path |
|
| 1 video URL |
|
|
|
|
๐ HTTP API (FastAPI, port 7002)
Same business layer as MCP โ no duplicated logic. All endpoints return a unified response structure:
{"code": 0, "msg": "ok", "data": "..."}
| Meaning | How to judge |
| success |
|
| business failure (missing key, file not found) | read |
| internal exception (bug) | read |
8 endpoints:
Method | Endpoint | Purpose | Required fields |
GET |
| health check | โ |
GET |
| list available tools | โ |
POST |
| image recognition |
|
POST |
| video recognition |
|
POST |
| text-to-image |
|
POST |
| infographic generation |
|
POST |
| image-to-image |
|
POST |
| batch engine |
|
Quick test:
curl http://127.0.0.1:7002/health
curl -X POST http://127.0.0.1:7002/g-pic -H "Content-Type: application/json" \
-d '{"prompt": "a cat by a coffee shop window, illustration style"}'โ๏ธ Environment Variables Reference
5 sections โ all new v6 variables (code defaults shown in parentheses; env vars override).
VISION_ โ r-pic image recognition
Variable | Meaning | Default |
| enable switch: |
|
| vision backend: |
|
| vision model |
|
| OpenAI-compatible base URL |
|
| vision API key | empty |
VISION_VIDEO_ โ r-vid video recognition (all empty โ falls back to VISION_*)
Variable | Meaning | Default |
| video switch; empty falls back to |
|
| video backend; empty โ fall back to | same as vision |
GEN_IMAGE_ โ g-pic text-to-image
Variable | Meaning | Default |
| enable switch |
|
|
|
|
| text-to-image model (main instance) |
|
| OpenAI-compatible base URL (main instance) |
|
| comma-separated key pool (main instance) | empty |
| named instance list, e.g. | empty |
GEN_INFOGRAPH_ โ i-pic infographics
Same shape as GEN_IMAGE_*; default model sensenova-u1-fast.
EDIT_IMAGE_ โ p-pic image-to-image
Same shape as GEN_IMAGE_*; default model sensenova-u1.5-lite (decoupled from text-to-image).
openai_compatoptional extras:{PREFIX}_RESPONSE_FORMAT(url/b64_json, defaulturl),{PREFIX}_EDIT_URL(image-edit endpoint override, default${BASE_URL}/images/edits).
Fallback chain (priority order)
named-instance vars ({PREFIX}_{X}_FIELD) โ main-instance vars ({PREFIX}_FIELD) โ code defaultsOnly two fallback types exist, no legacy-variable fallback:
Video โ image:
VISION_VIDEO_*all empty โVISION_*(switch follows the same chain).Named instance โ main instance: instance field empty โ main instance field (no
_ADAPTERper instance;{PREFIX}_ADAPTERis pipeline-level).
๐ Adapter Mechanism
Two-layer: common differences are absorbed by generic adapters, special differences by vendor-specific adapters. The tools only see capability interfaces.
Adapter | Type | Purpose | Special differences handled |
| generation ยท generic | OpenAI-compatible protocol ( | none โ differences handled by config (change MODEL/BASE_URL = switch vendor) |
| generation ยท vendor | SenseNova image generation | multi-key pool, |
| vision ยท generic | OpenAI-compatible vision | none (Bearer auth, |
| vision ยท vendor | dots vision |
|
Add a new OpenAI-compatible model โ zero code:
GEN_IMAGE_ADAPTER=openai_compat
GEN_IMAGE_MODEL=foo-image-x1
GEN_IMAGE_BASE_URL=https://foo.example.com/v1
GEN_IMAGE_API_KEYS=sk-foo-xxxxTools work immediately. Only write a custom adapter when the API is not OpenAI-compatible (private protocols, two-stage polling, special auth headers, JSON+base64 edits, multi-key pools, non-configurable differences) โ register it in adapters/__init__.py in one line, pipeline code untouched.
Multi-key pool constraints: keys in one *_API_KEYS must be same vendor + same BASE_URL + same MODEL (they rotate for one endpoint). Don't mix vendors/URLs/models in one pool (โ 400/404, no key rotation, cascading errors). Use different config sections or named instances for multiple endpoints.
๐ Config Preflight
adapters.get_config_summary() returns the readiness of all 5 pipelines (+ named instances) โ N of M available โ so agents/clients can check before calling. It only reports "configured / not configured", never prints actual keys.
import json
from adapters import get_config_summary
for r in get_config_summary():
print(f"{r['tool']:6s} {r['prefix']:16s} instance={str(r['instance'] or '(main)'):6s} "
f"adapter={r['adapter']:12s} model={r['model']:20s} keys={r['api_keys']:3s} โ {r['status']}")Example output (fully configured case):
g-pic GEN_IMAGE ๅฎไพ=(ไธป) adapter=sensenova model=sensenova-u1.5-lite keys=ๅทฒ้
็ฝฎ โ AVAILABLE
i-pic GEN_INFOGRAPH ๅฎไพ=(ไธป) adapter=sensenova model=sensenova-u1-fast keys=ๅทฒ้
็ฝฎ โ AVAILABLE
p-pic EDIT_IMAGE ๅฎไพ=(ไธป) adapter=sensenova model=sensenova-u1.5-lite keys=ๅทฒ้
็ฝฎ โ AVAILABLE
r-pic VISION ๅฎไพ=(ไธป) adapter=dots model=dots3-note-prev keys=ๅทฒ้
็ฝฎ โ AVAILABLE
r-vid VISION_VIDEO ๅฎไพ=(ไธป) adapter=dots model=dots3-note-prev keys=ๅทฒ้
็ฝฎ โ AVAILABLE
ๆฑๆป๏ผ5 of 5 available๐ Security
Keys live only in
.env(excluded by.gitignore, never committed) โ zero hardcoded keys in code.All adapters redact key fragments in errors and logs via
_safe_error()โ[redacted].get_config_summary()prints only "configured / not configured" โ never the keys themselves.Never put full keys in frontend code, logs, or public repos.
HTTP server binds to 127.0.0.1 by default โ local machine only, not exposed to LAN/Internet unless you change
host.
๐ Notes & FAQ
Q1: Generated image URLs expire?
u1.5-lite URLs expire in 24h, u1-fast in 1h (per official docs). pivision downloads every generated image to local art/ automatically โ always use the local file path, ignore the temp URL.
Q2: Video recognition fails / can't parse?
The video URL must be a publicly reachable http/https link โ LAN addresses, localhost, and local file paths won't work. Parsing can be slow, that's normal; if it times out, use a shorter/smaller video. Default timeout is 180s (TIMEOUT_SECONDS in adapters/vision_base.py).
Q3: "Not configured {xxx}_API_KEYS"?
That pipeline has no key. Fill *_API_KEYS in .env, then restart the service.
Q4: "Pipeline disabled ({PREFIX}_ENABLED=false)"?
The switch is off. Set {PREFIX}_ENABLED to true (or delete the line โ empty counts as on), then restart.
Q5: Key rotation still hits 400/404? Almost certainly a mixed pool โ keys pointing to different models/endpoints in one pool. Split by endpoint using different config sections or named instances.
Q6: Env vars changed but no effect?
.env is loaded once at startup. Restart the service. Note named-instance vars are case-sensitive (GEN_IMAGE_A_MODEL โ instance suffix uppercase).
Q7: Size errors or wrong orientation?
Generation auto-matches the nearest aspect ratio + LANCZOS downscale for unsupported sizes (output notes โก ่ชๅจ็ผฉๆพ). If still failing, make sure size is WxH format (e.g. 1024x1024).
Limits: single image โค 20MB for r-pic; video timeout 180s (adjustable constant); b-gen per-line failure doesn't stop the batch.
๐ฆ Project Layout
pivision/
โโโ pivision.py # MCP entry (FastMCP "pivision")
โโโ api_server.py # FastAPI HTTP server (:7002)
โโโ utils.py # save/naming/size/base64/batch/history
โโโ adapters/ # adapter registry + factory
โ โโโ __init__.py # registry + get_config_summary()
โ โโโ vision_base.py # vision base (timeout, max image size)
โ โโโ vision_openai.py # vision ยท generic OpenAI-compatible
โ โโโ vision_dots.py # vision ยท dots vendor
โ โโโ openai_compat.py # generation ยท generic OpenAI-compatible
โ โโโ sensenova.py # generation ยท SenseNova vendor
โโโ pyproject.toml
โโโ .env.example # config template (fill your keys โ .env)
โโโ pic-config.json # MCP registration template (generic)
โโโ mcp-register.json # MCP registration template (CodeBuddy tagged)
โโโ README-zh.md # ไธญๆ็่ฏดๆ๐ License
To be determined by the project owner โ see repository listing. (Internal / local deployment tool; not published to npm/PyPI.)
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseAqualityDmaintenanceAllows AI assistants to generate and transform high-quality images from text prompts using Google's Gemini model via the MCP protocol.334MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI-powered image generation and editing using Gemini and Imagen models, supporting text-to-image, image editing, and multi-image composition through MCP tools.MIT
- FlicenseAqualityCmaintenanceEnables AI assistants to recognize and extract information from images via GLM-4V, supporting automatic screenshot recognition and MCP-based local image file reading for non-vision models like DeepSeek.1
- AlicenseNot gradedqualityBmaintenanceProvides multimodal vision MCP tools for image analysis, OCR, object detection, text-to-image generation, and image similarity, integrating OpenAI, Qwen, and Gemini.1,1531MIT
Related MCP Connectors
OCR, transcription, file extraction, and image generation for AI agents via MCP.
Generate images with any major model โ one API key, one prepaid balance, one MCP.
Generate on-brand images from your AI agent: design, edit, and render templates over MCP.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/bliubliuing/pivision'
If you have feedback or need assistance with the MCP directory API, please join our Discord server