跳到正文
GitHub·· 7 天前AI 评分38

Claude Code 插件 openrouter-media:用 OpenRouter 任意模型生成图片和视频

khang859/openrouter-media

AI 导读

khang859/openrouter-media 是一个 Claude Code 插件,通过 Rust 命令行工具 ormedia 和 generate-media 技能,让 Claude 调用 OpenRouter 上的任意模型生成和编辑图片、生成视频。

正文

A Claude Code plugin that generates and edits images, and generates videos, with any model on OpenRouter.

It adds two things:

  • ormedia, a small command-line tool written in Rust.
  • A generate-media skill that tells Claude when and how to use it.

Install

/plugin marketplace add khang859/openrouter-media
/plugin install openrouter-media@openrouter-media

Then ask Claude for an image or a video. The first time ormedia runs, it downloads the program for your computer from the GitHub release, one time. It needs curl for that, and nothing else. The first time, Claude runs ormedia login, your browser opens, and you approve. The API key is stored in ~/.config/openrouter-media/credentials.json, readable only by you. You never paste a key into the chat.

To use a key you already have, set OPENROUTER_API_KEY instead. It wins over the stored key.

Commands

Command What it does
ormedia login Sign in with the browser and store an API key
ormedia logout Delete the stored API key
ormedia status Show which key is in use and its spend
ormedia models <image|video> List models and the options each one takes
ormedia image --prompt <text> Generate or edit an image
ormedia video --prompt <text> Generate a video
ormedia job <job-id> Check a video job, and download it when it is done
ormedia config Show the settings, or save one with set and unset

Run ormedia --help for every option.

ormedia image --prompt "A flat vector fox logo, orange on white" --aspect-ratio 1:1 --out assets/
ormedia image --prompt "Make it night. Keep everything else." --image ./street.png
ormedia video --prompt "Waves roll onto a black sand beach, slow push in" --duration 4

Results are saved to the current folder, or to --out, or to the out setting. A file that already exists is never overwritten. Add --json to get the result as JSON.

Models

The defaults are google/gemini-nano-banana-2.1 for images and x-ai/grok-imagine-video-1.5-lite for videos. Change them per call with --model, or for good with ormedia config.

Settings

ormedia config shows every setting and where its value comes from. Add --json to get that as JSON.

ormedia config set image-model openai/gpt-image-2
ormedia config set out ~/Pictures/generated
ormedia config unset image-model
Setting What it does Default
image-model Model for ormedia image google/gemini-nano-banana-2.1
video-model Model for ormedia video x-ai/grok-imagine-video-1.5-lite
out Folder that results are saved to The current folder
open true or false: open a new image in Fleet true
timeout Minutes to wait for a video 20

Settings are stored in ~/.config/openrouter-media/config.json. A flag on the command line always wins over a saved setting. ORMEDIA_IMAGE_MODEL and ORMEDIA_VIDEO_MODEL also win over the saved models. A relative out folder is relative to the folder you run the command in.

Videos take time

A video takes from 30 seconds to several minutes. ormedia video prints the job id first, then waits up to 20 minutes, or the timeout setting. If the wait ends early, the job still runs on OpenRouter. Get the result later with ormedia job <job-id> --wait.

Fleet

Inside a Fleet pane, a new image opens in a Fleet tab on its own. Pass --no-open to stop that once, or run ormedia config set open false to stop it for good. With open set to false, pass --open to open one result.

Development

You need the latest stable Rust.

cargo test
cargo build --release
claude plugin validate .
claude --plugin-dir .

bin/ormedia runs target/release/ormedia when it exists, so a checkout uses your own build.

License

MIT

来源:GitHub · github.com