中文文档 · Docs · Provider Guide · GitHub Pages
Use one TypeScript API with built-in direct-HTTP adapters for selected OpenAI image/video, Gemini image, Qwen/Wan video, Volcengine Doubao/Seedance, HappyHorse, and custom media-provider workflows.
AI Media Router is for product teams that do not want image and video generation logic scattered across provider SDKs, webhook formats, polling loops, size rules, and result shapes.
- Switch providers without rewriting your business layer
- Run sync image APIs and async video jobs through one lifecycle
- Normalize dimensions, count splitting, polling, cancellation, and output assets
- Keep stable cross-provider fields in
input/optionsand native knobs inproviderOptions - Add private or regional providers with the same plugin contract used by the built-ins
| Provider | Built-in models | Best fit today |
|---|---|---|
| OpenAI |
gpt-image-1, gpt-image-1-mini, gpt-image-1.5, gpt-image-2, sora-2, sora-2-pro
|
selected official image generation/editing and text-to-video workflows |
| Gemini image models | selected Gemini Interactions API image-generation workflows | |
| Google Veo | Veo 3.1 preview video models | selected Gemini predictLongRunning video-generation workflows |
| Qwen / Wan | Qwen image models, wan2.7
|
text-to-image, image editing, text/image-to-video |
| Volcengine Doubao | Seedream and Seedance models | China-region image and video generation workflows |
| HappyHorse | happy-horse |
video generation and editing through a custom provider facade |
Audio and 3D request contracts are available for custom providers. The built-in adapters currently focus on image and video workflows.
-
@miragari/ai-media-router-core: shared types, validation, dimensions, errors, and provider contracts -
@miragari/ai-media-router-client: router client, polling helpers, batching, profiles, and defaults -
@miragari/ai-media-router: built-in providers pluscreateMediaRouter()
npm install @miragari/ai-media-routerOr install only the layers you need:
npm install @miragari/ai-media-router-core @miragari/ai-media-router-clientimport { createMediaRouter } from "@miragari/ai-media-router"
const client = createMediaRouter({
provider: "openai",
providers: {
openai: process.env.OPENAI_API_KEY!,
},
image: {
model: "gpt-image-1",
},
})
const result = await client.generateImage({
prompt: "A minimal product render of a matte white desk lamp",
width: 1024,
height: 1024,
quality: "high",
})
console.log(result.asset)const qwen = createMediaRouter({
provider: "qwen",
providers: {
qwen: process.env.DASHSCOPE_API_KEY!,
},
image: {
model: "qwen-image-2.0",
},
})
await qwen.generateImage({
prompt: "A clean ecommerce hero image for a white desk lamp",
width: 1328,
height: 1328,
count: 2,
})const video = createMediaRouter({
provider: "qwen",
providers: {
qwen: process.env.DASHSCOPE_API_KEY!,
},
video: {
model: "wan2.7",
duration: 5,
quality: "high",
},
})
const job = await video.createVideo({
prompt: "A slow camera push toward a matte white desk lamp on a walnut table",
width: 1280,
height: 720,
})
const result = await video.wait(job)
console.log(result.assets)AI Media Router keeps stable request fields in input and options, and pushes unstable provider-native switches into providerOptions.
- Image:
prompt,negativePrompt,images,mask,width,height,count,seed,quality,outputFormat - Video:
prompt,image,images,video,videos,audio,duration,fps,mode,quality - Audio:
prompt,text,audio,audios,duration,voice,format,sampleRate - Model3D:
prompt,images,model,format,quality,texture
import { createMediaRouter } from "@miragari/ai-media-router"
const client = createMediaRouter({
providers: {
openai: process.env.OPENAI_API_KEY!,
qwen: process.env.DASHSCOPE_API_KEY!,
},
profiles: {
thumbnail: {
type: "image",
width: 1024,
height: 1024,
quality: "high",
},
teaserVideo: {
type: "video",
provider: "qwen",
model: "wan2.7",
options: { duration: 5 },
},
},
})- English quick start: docs/en/getting-started.md
- Chinese quick start: docs/zh-CN/getting-started.md
- Provider compatibility: docs/en/provider-compatibility.md · 中文
- Releasing packages: docs/en/releasing.md
- Provider authoring: packages/providers/README.md
- Local SDK Tester:
examples/sdk-tester— run locally withpnpm --filter @miragari/sdk-tester dev; it stores provider settings in browser localStorage and must not be deployed with credentials. - Community guide: CONTRIBUTING.md
packages/
core/ Shared protocol and validation layer
client/ Runtime router and normalization layer
providers/ Built-in providers and factory helpers
examples/
basic/ Small usage sample
sdk-tester/ Local browser SDK test console
site/ GitHub Pages static website
docs/ Bilingual written documentation
This repository includes:
- GitHub Actions CI
- GitHub Pages deployment
- Changesets-based package release workflow
Maintainers can publish packages with:
pnpm changeset
pnpm version-packages
pnpm release:publishThis project is released under the MIT License.