@apicity/machgen

中文文档
0.27.0发布于 2026/11/06MITTypeScriptES Module近 30 天下载 3022

MachGen video generation API provider.

原始使用文档
文档目录11 节
  1. Installation
  2. Quick Start
  3. Video models
  4. Reference-to-video
  5. Upscale and sharpen
  6. API Reference
  7. assets
  8. generate
  9. tasks
  10. upscale
  11. License

@apicity/machgen

npm dependencies TypeScript docs

MachGen video generation API provider.

Image generation uses the same api.v0.generate method: set task_type to T2I or I2I and supply image_config with height and optional width/aspect_ratio. The frontier image IDs are GPT-Image-2, GPT-Image-2.5-Sunburst, GPT-Image-2.5-Flare, Nano-Banana-2 and Nano-Banana-2.1. Edits take public HTTP(S) src_image_urls, up to 16 on the GPT Image models and 14 on the Nano Banana models (MACHGEN_I2I_MAX_IMAGES), or previous image src_task_ids. Poll api.v0.tasks for task_output.image. GPT Image 2 defaults to high quality; optimization_level: "EXPRESS" selects low quality. The recorded 1280×544 EXPRESS request billed $0.001385 before Generation Credit. Send Alibaba-Wan-3.0 requests with MachGen's documented video_config: aspect_ratio: "adaptive", fps: 30 and audio: true. On 2026-10-22, seven Wan 3.0 tasks that omitted aspect_ratio and fps and sent audio: false were accepted, then failed upstream with Request Rejected at zero charge. With the documented config, 2-second 480p T2V, I2V and R2V requests completed. Which of the three fields MachGen requires has not been isolated.

Runtime dependencies:

  • zod@^4.6.6 — request schemas attached to every POST endpoint as .schema

Installation

npm install @apicity/machgen
# or
pnpm add @apicity/machgen

Quick Start

import { createMachGen } from "@apicity/machgen";

const machgen = createMachGen({ apiKey: process.env.MACHGEN_API_KEY! });

Video models

Pass a model id with a task_type it supports. For the ids below, machgen.api.v0.generate.schema also checks the height, duration_secs and aspect_ratio against the model's grid (MACHGEN_VIDEO_GRIDS, which holds each T2V and R2V grid too), the I2V frame rules, the R2V reference limits, the UPSCALE targets (MACHGEN_VIDEO_UPSCALE) and the SHARPEN heights (MACHGEN_VIDEO_SHARPEN); other ids pass unchecked. MachGen answers an off-grid request with HTTP 400 before it accepts the task, and does not bill it. The grids were read from those 400 responses on 2026-10-25, MiniMax-H3-Omni's on 2026-11-01, and the SHARPEN heights on 2026-10-31. -1 asks the model for a Smart length.

ModelT2VI2VR2VUPSCALESHARPENI2V framesI2V heightsI2V secondsPriced
Wan2.2-A14B✓✓480, 7205T2V, I2V
LTX-2.3-Pro✓✓start + end1080, 1440, 21606, 8, 10T2V, I2V
Vidu-Q3-Turbo✓✓✓start + end540, 7201-16T2V, I2V, R2V
Vidu-Q3-Pro✓✓✓start + end540, 720, 10801-16T2V, I2V, R2V
MiniMax-H3✓✓✓✓✓start + end, or end only480, 768, 1080, 14401-30T2V, I2V, R2V, UPSCALE, SHARPEN
MiniMax-H3-Turbo✓✓✓start + end, or end only480, 768, 10804-15T2V, I2V, R2V
MiniMax-H3-Omni✓R2V
Seedance-2.5✓✓✓start + end480, 720, 1080-1, 4-30T2V, I2V, R2V
Seedance-2.0✓✓✓start + end480, 720, 1080, 2160-1, 4-15T2V, I2V, R2V
Seedance-2.0-Fast✓✓✓start + end480, 720-1, 4-15T2V, I2V, R2V
Seedance-2.0-Mini✓✓✓start + end480, 720-1, 4-15T2V, I2V, R2V
Kling-v3✓✓start + end720, 1080, 21603-15T2V, I2V
Kling-o3✓✓T2V, R2V
Vidu-Q3✓R2V
Vidu-Q4-Preview✓✓540, 720, 1080, 1440, 21603-16I2V, R2V
Vidu-Q3-Pro-Fast✓720, 10801-16I2V
Alibaba-Wan-3.0✓✓✓start + end480, 720, 1080-1, 2-30T2V, I2V, R2V
Veo-3.1✓T2V
Veo-3.1-Fast✓T2V
Pixverse-V6✓✓✓360, 540, 720, 10801-15T2V, I2V, R2V
Pixverse-C1✓✓✓360, 540, 720, 10801-15T2V, I2V, R2V
HappyHorse-1.1✓✓✓720, 10803-15T2V, I2V, R2V
HappyHorse-1.0✓✓✓720, 10803-15T2V, I2V, R2V
Grok-Imagine-Video✓T2V
Grok-Imagine-Video-1.5✓480, 720, 10801-15I2V
Topaz-Video-Precision✓
Topaz-Video-Precision-Animation✓
Topaz-Video-Generative✓
Topaz-Video-Generative-Fast✓

An I2V request takes one start frame in src_image_urls. Where the table lists "start + end", entry 1 is the end frame; "end only" means keyframe_indices: [-1] animates toward a single image used as the end frame. MachGen also accepts task_type: "F2F" for two-image I2V; the schema keeps the documented I2V form. MiniMax-H3 and MiniMax-H3-Turbo list 1080p, but MachGen answers 403 to accounts without access to it, and the pricebook has no 1080p rate. The pricebook's LTX-2.3-Pro 540p and 720p tiers are not requestable.

Reference-to-video

An R2V request takes reference images, videos and audio clips in src_image_urls, src_video_urls (public http(s) URLs) and src_audio_urls, or earlier outputs in src_task_ids. reference_video_start_secs lists one start second per reference video. reference_video_operation edits or extends the video instead of using it as a reference; an edit renders at the video's own length, so MachGen ignores duration_secs. MiniMax-H3-Omni is missing from MachGen's models table, but its model page and pricebook list it, and it takes R2V only. Beyond the caps below, every video task takes at most 9 images in src_image_urls, the limit MachGen documents for references, and at most 3 each in src_video_urls and src_audio_urls.

ModelR2V heightsR2V secondsReferencesReference video
Vidu-Q3-Turbo540, 7201-16up to 7 images; no videos or audionone
Vidu-Q3-Pro540, 7201-16up to 7 images; no videos or audionone
MiniMax-H3480, 768, 1080, 14401-30up to 9 images, 3 videos, 3 audio; 15 in allreference; start offsets
MiniMax-H3-Turbo480, 768, 10804-15up to 9 images, 3 videos, 3 audio; 15 in allreference; start offsets
MiniMax-H3-Omni7681-15up to 9 images, 3 videos, 3 audio; 12 in all; audio needs an image or videoreference
Seedance-2.5480, 720, 1080-1, 4-30not checkedreference, edit, extend
Seedance-2.0480, 720, 1080, 2160-1, 4-15up to 9 images, 3 videos, 3 audio; audio needs an image or videoreference
Seedance-2.0-Fast480, 720-1, 4-15up to 9 images, 3 videos, 3 audio; 12 in all; audio needs an image or videoreference
Seedance-2.0-Mini480, 720-1, 4-15up to 9 images, 3 videos, 3 audio; 12 in all; audio needs an image or videoreference
Kling-o3720, 1080, 21603-15up to 7 images; no videos or audionone
Vidu-Q3540, 720, 10803-16up to 7 images; no videos or audionone
Vidu-Q4-Preview540, 720, 1080, 1440, 21603-16up to 3 audio; no videos; images not checkednone
Alibaba-Wan-3.0480, 720, 1080-1, 2-30not checkednot checked
Pixverse-V6360, 540, 720, 10801-15up to 3 images; no videos or audionone
Pixverse-C1360, 540, 720, 10801-15up to 3 images; no videos or audionone
HappyHorse-1.1720, 10803-15not checkednot checked
HappyHorse-1.0720, 10803-15not checkednot checked

Upscale and sharpen

An UPSCALE task re-renders a finished video, named in src_task_ids or src_video_urls, at the target video_config.height; set duration_secs to the source's length. MiniMax-H3 upscales only its own 768p outputs of 5 s or more. MachGen also rejects a target at or below the source's height, and a gaia-2 target above twice it; those depend on the source, so the schema cannot check them.

ModelTarget heightsEnginesPriced
MiniMax-H31440✓
Topaz-Video-Precision1080, 1440, 2160, 4320artemis-hq, artemis-lq, artemis-mq, gaia-cg, gaia-hq, proteus
Topaz-Video-Precision-Animation720, 960, 1080, 1440, 2160, 4320gaia-2
Topaz-Video-Generative1080, 1440, 2160starlight-hq, starlight-mini, starlight-precise-2-5, starlight-sharp
Topaz-Video-Generative-Fast1080, 1440, 2160starlight-fast-2

A SHARPEN task sharpens one owned video and keeps its length: a MachGen output named in src_task_ids, or an upload referenced as @input/<artifact_path> in src_video_urls. MachGen refuses a public URL. It takes duration_secs, not num_frames. MachGen's quote prices the source's height and seconds, whatever the request's height or duration_secs, so set video_config.height to the source's height.

ModelHeightsPriced
MiniMax-H3480, 768✓

Priced lists the task types computeEstimate from @apicity/cost prices per output second. An R2V reference video also bills the seconds MachGen reads from it, after any start offset, so pass their total as costHints.inputDurationSeconds; an edit's output is that long too. An upscale bills by its source's length, so it needs the same hint; MiniMax-H3 bills those seconds in and out. A sharpen needs the hint too and bills the seconds once. Topaz bills vendor credits that depend on the source's frames and resolution, so computeEstimate does not price it; api.v0.upscale.quote asks MachGen for the exact price, and resolveMachGenUpscaleEstimate turns that quote into an estimate. Kling-v3, Kling-o3 and the Pixverse models price audio on and off apart, so set video_config.audio. api.v0.tasks.billing returns a finished task's actual charge in micro-USD.

import { createMachGen } from "@apicity/machgen";

const machgen = createMachGen({ apiKey: process.env.MACHGEN_API_KEY! });

const task = await machgen.api.v0.generate({
  model: "MiniMax-H3-Turbo",
  task_type: "I2V",
  prompt: "The cat slowly blinks and turns its head toward the window.",
  video_config: { height: 480, duration_secs: 4 },
  src_image_urls: [
    "https://example.com/start.jpg",
    "https://example.com/end.jpg",
  ],
});

let status = await machgen.api.v0.tasks(task.task_id);
while (status.status === "PENDING" || status.status === "RUNNING") {
  await new Promise((resolve) => setTimeout(resolve, 10_000));
  status = await machgen.api.v0.tasks(task.task_id);
}
const bill = await machgen.api.v0.tasks.billing(task.task_id);
console.log(bill.generation_cost_micros / 1e6); // 0.06

API Reference

5 endpoints across 4 groups. Each method mirrors an upstream URL path.

assets

GET machgen.api.v0.assets

GET https://api.machgen.ai/api/v0/assets/{taskId}

Cost tier: expensive

Upstream docs ↗

const res = await machgen.api.v0.assets({ /* ... */ });

Source: packages/provider/machgen/src/machgen.ts

generate

POST machgen.api.v0.generate

POST https://api.machgen.ai/api/v0/generate

Cost tier: expensive

Upstream docs ↗

const res = await machgen.api.v0.generate({ /* ... */ });

Source: packages/provider/machgen/src/machgen.ts

tasks

GET machgen.api.v0.tasks

GET https://api.machgen.ai/api/v0/tasks/{taskId}

Cost tier: expensive

Upstream docs ↗

const res = await machgen.api.v0.tasks({ /* ... */ });

Source: packages/provider/machgen/src/machgen.ts

GET machgen.api.v0.tasks.billing

GET https://api.machgen.ai/api/v0/tasks/{taskId}/billing

Cost tier: expensive

Upstream docs ↗

const res = await machgen.api.v0.tasks.billing({ /* ... */ });

Source: packages/provider/machgen/src/machgen.ts

upscale

POST machgen.api.v0.upscale.quote

POST https://api.machgen.ai/api/v0/upscale/quote

Cost tier: expensive

Undocumented upstream: MachGen's REST docs do not list this endpoint (read 2026-10-26), so MachGen may change or remove it without notice. MachGen's web app prices an upscale with it before submitting, and the MCP server's quote_video_upscale tool (docs) is the documented form of the same check. The quote is free, creates no task and answers { cost_micros }, the micro-USD the upscale of a source you own would bill; a recorded Topaz upscale billed exactly its quote. On 2026-10-26 a 2160p Topaz Video Generative Fast upscale of a 4 s 480p task quoted 596000 micros (recording machgen/topaz-video-generative-fast-upscale-quote). resolveMachGenUpscaleEstimate in @apicity/cost turns a quote into an estimate.

const res = await machgen.api.v0.upscale.quote({ /* ... */ });

Source: packages/provider/machgen/src/machgen.ts

Part of the apicity monorepo.

License

MIT — see LICENSE.

版本与发布记录

@apicity/machgen 共发布 16 个版本,首次发布于 2026/10/23;过去 12 个月发布了 16 个版本。

版本发布日期距今
0.27.0latest2026/11/061 天前
0.26.02026/11/053 天前
0.25.02026/11/034 天前
0.24.12026/11/025 天前
0.24.02026/11/016 天前
0.23.12026/11/016 天前

关于 @apicity/machgen 的常见问题

@apicity/machgen 是什么?

MachGen video generation API provider.

如何安装 @apicity/machgen?

在项目目录运行 npm install @apicity/machgen,或使用 pnpm add / yarn add / bun add。

@apicity/machgen 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@apicity/machgen 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@apicity/machgen 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@apicity/machgen 可以商用吗?

@apicity/machgen 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@apicity/machgen 的下载量有多少?

根据 npm 官方下载统计,@apicity/machgen 在 2026/10/06 – 2026/11/04 这 30 天内被下载 3,022 次,日均约 101 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@apicity/machgen 还在维护吗?

最新版本 0.27.0 发布于 2026/11/06(1 天前);至今共发布 16 个版本,其中过去 12 个月发布了 16 个;首次发布于 2026/10/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。