openrouter-multimodal

v4.5.1
io.github.stabgan/openrouter-multimodal Checked 5 days ago Published 7 months ago

Chat with 300+ LLMs via OpenRouter.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

chat_completion

Send messages to an OpenRouter model and get a text response. Supports provider routing (quantizations / ignore / sort / order / require_parameters / data_collection / allow_fallbacks), model variant suffixes (`:nitro` fastest, `:floor` cheapest, `:exacto` tool-calling accuracy), reasoning token passthrough, web search, and response caching. Fails when: - INVALID_INPUT: messages array is empty - UPSTREAM_REFUSED: provider rejected the request (credits, content policy, or rate limit) - UPSTREAM_TIMEOUT: upstream did not respond within the SDK timeout - MODEL_NOT_FOUND: model slug does not exis…

ParameterTypeDescription
messages *array
cachebooleanEnable OpenRouter response caching via `X-OpenRouter-Cache: true`. Server-wide default settable via `OPENROUTER_CACHE_RESPONSES=1`.
cache_clearbooleanBust the cache entry for this exact request.
cache_ttlstringCache TTL (e.g. `"5m"`, `"1h"`, `"24h"`; 1s-24h range).
include_reasoningbooleanSurface the model's chain-of-thought on `_meta.reasoning` for R1 / Opus 4.7 / Gemini Thinking.
max_tokensnumberMax completion tokens. Falls back to `OPENROUTER_MAX_TOKENS` env var if unset.
modelstringModel ID (optional, uses default). Append `:nitro` for the fastest variant, `:floor` for the cheapest, or `:exacto` for the best tool-calling accuracy. Example: `openai/gpt-4o:nitro`.
onlinebooleanEnable OpenRouter's web-search plugin (Exa-backed, $4 / 1000 results).
providerobjectOpenRouter provider-routing overrides. Merges on top of `OPENROUTER_PROVIDER_*` env defaults. See https://openrouter.ai/docs/features/provider-routing
temperaturenumber
web_max_resultsnumberMax web-search results when `online: true` (default 5).

analyze_image

Analyze an image with a vision model. Accepts local file paths, http(s) URLs, or base64 data URLs. Output is model-generated and tagged `_meta.content_is_untrusted: true`. Fails when: - INVALID_INPUT: image_path missing or malformed - UNSAFE_PATH: local path escaped the sandbox - RESOURCE_TOO_LARGE: image exceeded configured fetch size cap - UPSTREAM_REFUSED: provider SSRF guard blocked the URL or content policy rejected Works with: search_models (find vision-capable models), generate_image (follow-up creation).

ParameterTypeDescription
image_path *stringFile path, URL, or data URL
cacheboolean
cache_clearboolean
cache_inputbooleanAttach `cache_control: ephemeral` to the image block so Anthropic / Gemini prompt-cache it. Repeat questions about the same image save ~10x on Anthropic.
cache_ttlstring
modelstring
questionstringQuestion about the image

analyze_audio

Transcribe or analyze an audio file (WAV / MP3 / FLAC / OGG / etc.) using a multimodal model. Output is tagged `_meta.content_is_untrusted: true`. Fails when: - INVALID_INPUT: audio_path missing - UNSUPPORTED_FORMAT: decoder could not identify the file as audio - RESOURCE_TOO_LARGE: input exceeded size cap - UPSTREAM_REFUSED: blocked host or content policy Works with: generate_audio (text-to-speech follow-up).

ParameterTypeDescription
audio_path *stringFile path, URL, or data URL (base64-encoded audio)
cacheboolean
cache_clearboolean
cache_inputboolean
cache_ttlstring
modelstring
questionstringQuestion or instruction about the audio (default: transcribe)

analyze_video

Describe or analyze a video (mp4 / mpeg / mov / webm) using a multimodal model. Default model: google/gemini-2.5-flash. Output is tagged `_meta.content_is_untrusted: true`. Fails when: - INVALID_INPUT: video_path missing - UNSUPPORTED_FORMAT: not a recognized video container - RESOURCE_TOO_LARGE: exceeds fetch cap - UPSTREAM_REFUSED: SSRF block or provider refusal Works with: generate_video (text-to-video), get_video_status (poll async jobs).

ParameterTypeDescription
video_path *stringFile path, HTTP(S) URL, or base64 data URL. Supported: mp4 / mpeg / mov / webm.
cacheboolean
cache_clearboolean
cache_inputboolean
cache_ttlstring
modelstring
questionstring

search_models

Search OpenRouter's model catalog by name, provider, or capability. Returns a paginated list; use `offset` / `limit` / `next_offset` to page through. Fails when: - UPSTREAM_HTTP: /models endpoint returned an error - UPSTREAM_REFUSED: invalid API key Works with: validate_model, get_model_info.

ParameterTypeDescription
capabilitiesobject
limitnumber
offsetnumber
providerstring
querystring

get_model_info

Get pricing / context-length / capability details for a specific model id. Fails when: - INVALID_INPUT: model not provided - MODEL_NOT_FOUND: model slug does not exist - UPSTREAM_HTTP: model list fetch failed Works with: search_models (discover ids), validate_model (cheap existence check).

ParameterTypeDescription
model *string

validate_model

Check whether a model id exists on OpenRouter. Cheap boolean lookup against the cached catalog. Fails when: - INVALID_INPUT: model not provided - UPSTREAM_HTTP: catalog refresh failed Works with: get_model_info (detailed lookup), chat_completion (pre-flight validation).

ParameterTypeDescription
model *string

generate_image

Generate an image from a text prompt. Optional reference images condition the output for style / identity consistency. Default model: google/gemini-2.5-flash-image. Fails when: - INVALID_INPUT: prompt empty, bad aspect_ratio / image_size, unreadable reference image - UNSAFE_PATH: save_path or input_images path escaped the sandbox - UPSTREAM_REFUSED: provider content policy rejected or insufficient credits - MODEL_NOT_FOUND: model slug invalid Works with: analyze_image (verify the result), generate_video_from_image (next step in workflow).

ParameterTypeDescription
prompt *string
aspect_ratiostring
image_sizestring
input_imagesarray
max_tokensnumber
modalitiesarray
modelstring
save_pathstring

generate_audio

Generate audio (speech / music) from a text prompt. Format auto-detected, extension auto-corrected. Fails when: - INVALID_INPUT: prompt empty - UNSAFE_PATH: save_path escaped the sandbox - UPSTREAM_REFUSED: content policy or credit issues Works with: analyze_audio (verify the result).

ParameterTypeDescription
prompt *string
formatstring
modelstring
save_pathstring
voicestring

generate_video

Generate a video from a text prompt (optionally conditioned on first/last-frame or reference images). Submits an async job, polls until completion or max_wait_ms, and downloads the result. Emits MCP progress notifications when the client provides a `progressToken`. Default model: google/veo-3.1. Fails when: - INVALID_INPUT: prompt empty - UNSAFE_PATH: save_path or reference image paths escaped the sandbox - UPSTREAM_REFUSED: content policy, credits, or bad request - JOB_FAILED: provider marked the job as failed - UNSUPPORTED_FORMAT: reference/frame image could not be decoded Returns successf…

ParameterTypeDescription
prompt *string
aspect_ratiostring
durationnumber
first_frame_imagestring
last_frame_imagestring
max_wait_msnumber
modelstring
poll_interval_msnumber
providerobject
reference_imagesarray
resolutionstring
save_pathstring
seednumber

generate_video_from_image

Narrower convenience wrapper around generate_video for image-to-video workflows. Takes a single `image` argument (used as the first frame) and `prompt`. Per arxiv 2511.03497, narrower tools with fewer parameters improve tool-call hit rate. For last-frame conditioning or reference images, use generate_video directly. Fails when: - INVALID_INPUT: image or prompt missing - UNSAFE_PATH: image path escaped the sandbox - UPSTREAM_REFUSED / JOB_FAILED: same as generate_video Returns successfully with `_meta.code: JOB_STILL_RUNNING` on timeout (resumable via get_video_status). Works with: generate_…

ParameterTypeDescription
image *stringFirst-frame image (path, URL, or data URL). Required.
prompt *string
aspect_ratiostring
durationnumber
max_wait_msnumber
modelstring
poll_interval_msnumber
resolutionstring
save_pathstring
seednumber

get_video_status

Poll an async video-generation job by id. Downloads the result when complete (and saves if save_path given). Fails when: - INVALID_INPUT: video_id missing - UNSAFE_PATH: save_path escaped the sandbox - JOB_FAILED: provider marked the job as failed Returns successfully with `_meta.code: JOB_STILL_RUNNING` (NOT an error) when the job is still in flight — response carries `_meta.last_status` and `_meta.progress` so callers can retry later. Works with: generate_video, generate_video_from_image.

ParameterTypeDescription
video_id *string
save_pathstring

rerank_documents

Re-order a list of documents by relevance to a query using an OpenRouter reranker. Default model: cohere/rerank-english-v3.0. Fails when: - INVALID_INPUT: query missing, documents empty, non-string document elements - MODEL_NOT_FOUND: reranker model slug does not exist - UPSTREAM_HTTP: provider returned an error Works with: search_models (discover rerankers), chat_completion (answer grounded in top-ranked docs).

ParameterTypeDescription
documents *array
query *string
modelstring
return_documentsboolean
top_nnumber

health_check

Verify API-key validity, OpenRouter reachability, and return server + protocol versions. No args. Fails when: never returns an error result — always returns `{ ok, api_key_valid, ... }` so ops can programmatically branch on the payload. Works with: every other tool (run once at startup to confirm credentials).