@dtmirizzi/pi-openrouter-multimodal

extensionmaintained

OpenRouter multimodal tools for Pi — search, fetch, image gen, vision, video, PDF, TTS, STT

by · v1.6.0 · published 2mo ago

$ pi install npm:@dtmirizzi/pi-openrouter-multimodal
downloads/mo
0
stars
2
last push
2mo ago
open issues
0

Signals

license: MITtestspi manifest: missinginstall size: —deps: 0peer deps: 0

Download trend

No downloads in the last 12 weeks.

README

@dtmirizzi/pi-openrouter-multimodal

OpenRouter multimodal tool integration for Pi. Provides 8 independently toggleable tools with per-modality model selection and session-persistent settings.

ToolWhat it does
web_searchServer-side web search with real-time results
web_fetchFetch page content from a URL (web, docs, PDFs)
image_generateText-to-image generation via OpenRouter chat completions
image_understandAnalyze images via vision models
video_understandAnalyze videos (YouTube links work with Gemini)
pdf_readExtract and analyze PDF content
tts_speakText-to-speech via OpenRouter /audio/speech endpoint
stt_transcribeSpeech-to-text via OpenRouter /audio/transcriptions endpoint

Install

pi install npm:@dtmirizzi/pi-openrouter-multimodal

Or from a local checkout:

pi install /path/to/pi-openrouter-multimodal

API Key

The extension resolves the OpenRouter API key from (priority order):

  1. OPENROUTER_API_KEY environment variable
  2. Pi model registry (provider openrouter)
  3. ~/.pi/agent/models.json under providers.openrouter.apiKey

Commands

CommandDescription
/web-toolsToggle tools on/off and configure search/fetch engines
/web-modelsSelect models per modality (image, vision, video, PDF, TTS voice, STT)
/web-searchToggle web_search and configure search engine
/web-fetchToggle web_fetch and configure fetch engine

Each command opens an interactive overlay. Use ↑↓ to navigate, ←→ to cycle values, Esc to close. Settings persist across sessions and survive compaction, shutdown, and tree navigation.

/web-tools

Toggle each tool on/off and set search/fetch engine preferences. Also includes a verbose/compact status-bar display toggle.

/web-models

Select the model for each modality from a list fetched live from the OpenRouter API at startup. Falls back to a comprehensive built-in list if the API is unavailable.

Tools

web_search

ParameterTypeDefaultDescription
querystringrequiredSearch query
enginestringautoauto, native, exa, firecrawl, parallel
max_resultsinteger5Results per search (1-25)
search_context_sizestringlow (5K), medium (15K), high (30K)
allowed_domainsstring[]Only return results from these domains
excluded_domainsstring[]Exclude results from these domains

web_fetch

ParameterTypeDefaultDescription
urlstringrequiredURL to fetch content from
enginestringautoauto, native, exa, openrouter, firecrawl, parallel
max_content_tokensintegerMax content length (approximate tokens)

image_generate

ParameterTypeDefaultDescription
promptstringrequiredText prompt describing the image
modelstringstateOverride the default model from /web-models

Selected via /web-models. Models are fetched live from OpenRouter at startup; fallback list includes Gemini Flash Image, GPT-5 Image, FLUX.2, Seedream, Riverflow, Recraft, Grok Imagine, and more.

image_understand

ParameterTypeDefaultDescription
urlstringrequiredImage URL or base64 data URL
promptstringDescribe this image in detailAnalysis prompt
modelstringstateOverride default from /web-models

video_understand

ParameterTypeDefaultDescription
urlstringrequiredVideo URL (YouTube links work with Gemini)
promptstringDescribe what happens in this videoAnalysis prompt
modelstringstateOverride default from /web-models

pdf_read

ParameterTypeDefaultDescription
urlstringrequiredURL of the PDF document
promptstringSummarize this documentAnalysis prompt
modelstringstateOverride default from /web-models
enginestringcloudflare-aicloudflare-ai (free), mistral-ocr (scanned docs), or native

tts_speak

ParameterTypeDefaultDescription
textstringrequiredText to convert to speech
modelstringstateOverride default from /web-models
voicestringstateOverride default from /web-models

stt_transcribe

ParameterTypeDefaultDescription
audiostringrequiredBase64-encoded audio data
formatstringrequiredwav, mp3, flac, m4a, ogg, webm, aac
modelstringstateOverride default from /web-models
languagestringISO-639-1 language code (optional)

How It Works

All tools proxy requests through OpenRouter's API:

  • web_search / web_fetch — Chat completions with server tool definitions (openrouter:web_search / openrouter:web_fetch)
  • image_generate — Chat completions with modalities: ["image", "text"] on the selected image generation model
  • image_understand / video_understand — Chat completions with multimodal content blocks (image_url, video_url)
  • pdf_read — Chat completions with file content block and file-parser plugin
  • tts_speak — Direct call to /api/v1/audio/speech
  • stt_transcribe — Direct call to /api/v1/audio/transcriptions

Model Discovery

On startup, the extension fetches available models from GET /api/v1/models?output_modalities=... and caches them for use in the /web-models settings panel. If the API is unreachable, a comprehensive set of fallback models is used.

Development

# Install dependencies
npm install

# Run tests
npm test               # all tests
npm run test:unit      # unit tests only
npm run test:integration  # requires OPENROUTER_API_KEY

# Format and lint
npm run fmt            # format all files
npm run lint           # lint + fix all files
npm run check          # format + lint + organize imports
npm run check:ci       # strict CI check (format + lint, no writes)

The repo uses Biome for formatting and linting. CI enforces both on every push and PR.

Assets

Logo

References