Zum Hauptinhalt springen
V

dsh-mimo-video

vainhappy/dsh-mimo-video

Adds a mimo_video tool that sends video, audio, or images to Xiaomi MiMo and returns a text answer, reusing a provider from Settings > Models.

Installation

dsh plugin --profile web add github:vainhappy/dsh-mimo-video

README

dsh-mimo-video

Video understanding for DeepSeek Harness, powered by Xiaomi MiMo's video API.

The agent passes a video and a question; MiMo samples frames, watches it, and answers in text. There is also a Settings → MiMo video page for the call recipe.

中文说明见 README.zh.md。

What it adds

Toolmimo_video — one video plus one question in, a written answer out
Settings pageModel id, endpoint, frame rate, resolution tier, timeout, size cap
CredentialResolved from DSH credentials, then the environment — never stored in config

Install

dsh plugin --profile web add @vainhappy/dsh-mimo-video

Or from the DSH GUI: Plugins → Add plugin, and paste the package name.

Then open Settings → MiMo video and confirm the API-key badge is green. If it is not, store a MiMo key first — see Credentials below.

Use

Just ask, in chat:

Summarise this video https://cdn.example.com/demo.mp4
Describe what happens in /path/to/clip.mp4

Or the agent may call the tool directly:

{
  "video": "https://cdn.example.com/demo.mp4",
  "question": "Summarise with approximate timestamps.",
  "fps": 3,
  "media_resolution": "max"
}

Video requirements

Direct media links only. The URL must serve the video bytes, not a page that plays them. A video-site watch page (Bilibili, YouTube, …), a cloud-drive preview, or an SPA player returns HTML, and the provider receives no video at all. Resolve such a page to its real media URL first.

Video: MP4, MOV, AVI, WMV. Audio: MP3, WAV, FLAC, M4A, OGG. Image: JPEG, PNG, GIF, WebP, BMP.

For audio and image files, fps and media_resolution are ignored.

Size — the two routes differ:

Local filePublic URL
How it travelsbase64 in the request bodythe provider downloads it
Inflation4/3 (×1.33)none
Limit37.5 MB originalVideo 300 MB / Audio 100 MB / Image 50 MB
Checked bythis plugin, before sendingMiMo's server

Base64 encodes every 3 bytes into 4 characters, so the encoded string is exactly 4/3 the file size; MiMo caps that string at 50 MB, which puts the hard ceiling for a local file at 37.5 MB. The plugin's own default cap is 35 MB, which leaves a little headroom.

Asking for a useful answer

Only text comes back, and timestamps are not included by default:

  • ask for them explicitly (with approximate timestamps)
  • state the shape you need (a list, N points, per-scene)
  • audio is not transcribed unless you ask
  • the call is synchronous and can take tens of seconds

The two knobs that matter

ParameterRangeDefaultWhen to raise it
fps0.1 – 102fast motion, ordering, timing detail
media_resolutiondefault / maxdefaultsmall text, small objects, fine texture

Both raise token cost.

Credentials

MiMo issues a different Base URL and key per account region, and they do not interoperate:

PlanKey formatEndpoint
Token Plantp-xxxxx / ttp-xxxxxhttps://token-plan-{cn,sgp,ams}.xiaomimimo.com/v1
Pay as you gosk-…https://api.xiaomimimo.com/v1

A Token Plan key sent to the pay-as-you-go host returns 401 Invalid API Key.

When a provider is selected, the plugin reads only that provider's own credential reference — it never falls back to another account's key. This ensures you cannot accidentally spend a subscription you did not pick.

Without a provider (flat-field mode via config file), the lookup order is:

  1. The configured apiKeyEnv reference
  2. XIAOMI_TOKEN_PLAN_CN_API_KEY, XIAOMI_TOKEN_PLAN_SGP_API_KEY, XIAOMI_TOKEN_PLAN_AMS_API_KEY
  3. MIMO_API_KEY, XIAOMI_API_KEY

Each is resolved through DSH credentials first, then the process environment, then .env.

Reusing a provider from Settings > Models

If your MiMo account is already configured on Settings > Models (for example both xiaomi and xiaomi-token-plan-cn), you do not need to enter the key again: the Model provider dropdown on Settings > MiMo video lists every MiMo-related provider, and the selected one supplies both its credential and its endpoint.

Switching providers takes effect on the next call. If the chosen provider has no API key yet, the error names it, so you know exactly where to fix it.

The dropdown only lists MiMo providers already configured on Settings > Models. Selecting one reuses its credential and endpoint entirely.

Multiple accounts or subscriptions

Add a separate provider for each MiMo account on Settings > Models (e.g. xiaomi-token-plan-cn, xiaomi-token-plan-sgp), then switch between them in the Settings > MiMo video dropdown. Each provider's credential and endpoint are independent and never cross-used.

Advanced: the accounts and activeAccount fields can still be edited manually in the config file for setups that need plugin-local account management. The UI no longer exposes them; using providers from Settings > Models is recommended.

MiMo also offers an Anthropic-protocol endpoint and a Batch API; neither accepts video, so this plugin uses the OpenAI-compatible protocol only.

Configuration

Every field is live, so settings apply to the next call without a restart.

FieldDefaultMeaning
modelmimo-v2.6-flashMiMo model id (mimo-v2.6-flash, mimo-v2.6-pro, mimo-v2.6-pro-ultraspeed)
baseURLToken Plan CN hostEndpoint; /chat/completions is appended
apiKeyEnvXIAOMI_TOKEN_PLAN_CN_API_KEYCredential reference
fps2Default frames per second, 0.1–10
mediaResolutiondefaultdefault or max
timeoutSeconds600This plugin's own budget, not a MiMo limit (1–3600)
maxLocalMegabytes35Pre-flight cap for local files (max 37)

Token estimation

The plugin uses the official MiMo formula to estimate video token cost. The usage.videoTokens and usage.audioTokens in the result are actual values reported by the API.

Factors:

  • duration × fps → frame count (capped at 2048)
  • resolution + media_resolution → tokens per frame (default caps at 300/frame)
  • audio ≈ duration(s) × 6.25 tokens

If the estimate exceeds 100k tokens, consider lowering fps/resolution or splitting into shorter segments.

Timestamp precision

Accuracy depends on fps: at fps=2 each frame covers 0.5s, so timestamps are approximate to ±0.5s. At fps<1 the error exceeds 1 second. For precise alignment, raise fps or analyse shorter excerpts.

Errors

CodeMeaning
MIMO_VIDEO_NOT_FOUND / MIMO_VIDEO_NOT_FILEThe local path is missing or is not a file
MIMO_VIDEO_UNSUPPORTED_FORMATFormat not in the supported video/audio/image list
MIMO_VIDEO_TOO_LARGEAbove a size limit — compress, or use a URL
MIMO_VIDEO_MISSING_CREDENTIALNo API key found
MIMO_VIDEO_PROVIDER_ERRORNon-2xx from MiMo; 401/403 usually means key and endpoint disagree; moderation rejections suggest retry / lower fps / split
MIMO_VIDEO_NETWORKNetwork error, usually transient — retry
MIMO_VIDEO_EMPTY_RESPONSENo text answer — rephrase and retry
MIMO_VIDEO_INVALID_ARGSBad fps or media_resolution

Concurrency and moderation

Each call is an independent HTTP request and the tool is marked concurrency-safe: analysing several segments or images can be issued in parallel rather than queued serially.

MiMo runs server-side content moderation and may reject some inputs (e.g. "high risk"). The API gives no frame or category detail, and sampling is partly random — a retry may pass; otherwise lower fps to resample, or split the clip and analyse a shorter segment.

Privacy

Videos and questions are sent to Xiaomi's servers for analysis. With the plugin disabled, the tool disappears and no video leaves the machine.

Development

The package is plain ESM with no build step:

src/index.js     entry: resolves the Host's shared packages, exports apply + Config
src/runtime.js   tool implementation and the Config schema
src/client.js    the Settings page (browser module)
cordis.patch.yml the bundle patch

runtime.js must stay a static import of index.js: HMR builds its reload graph from Node's static link table, so a dynamic import() would hide the edge and editing it would never reload the plugin.

Check syntax with node --check src/*.js. There is no test suite yet.

License

MIT

Ähnliche Plugins