Skip to content
프로젝트

소개

Javascript SDK for real-time interactive video generation with Xmax AI

디자인 및 미디어

이 수치를 측정하는 방법

What you can do

  • Character Swapping - Replace anyone in your live feed with a designated avatar in real-time. - ▶ Play demo
  • Prompt: 视频中角色替换成参考图中角色 Reference image: Select a clear image of the desired character with a clean background.
  • Virtual Try-On - Seamlessly change outfits, preserving exact body shape, natural motion, and an authentic fit. - ▶ Play demo
  • Prompt: 视频中人物衣服替换成参考图中衣服 Reference image: Select a clear image of the target outfit with a clean background.

측정된 스타 증가

in 24h
0
in 7 days
+1
in 15 days
+2
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

XmaxSDK — Realtime Interactive Video Generation

JavaScript ES2020 Realtime AI MIT License

We introduce XmaxSDK, a JavaScript SDK designed for real-time interactive video generation via Xmax models. XmaxSDK implements an end-to-end pipeline covering media acquisition, video streaming, frame-by-frame generation, and on-device rendering, enabling developers to seamlessly integrate low-latency, high-fidelity video transformations into creative applications at a much lower cost than alternative solutions.

X-Lab realtime generation demoX-Lab index demoX-Lab storage demo


What you can build with XmaxSDK

Realtime Use Case Description Demo
Character Swapping Replace anyone in your live feed with a designated avatar in real-time. Play the Character Swapping demo
▶ Play demo
Prompt: 视频中角色替换成参考图中角色

Reference image: Select a clear image of the desired character with a clean background.
Virtual Try-On Seamlessly change outfits, preserving exact body shape, natural motion, and an authentic fit. Play the Virtual Try-On demo
▶ Play demo
Prompt: 视频中人物衣服替换成参考图中衣服

Reference image: Select a clear image of the target outfit with a clean background.
Video Restyling Reimagine your world in any style with an immersive visual experience. Play the Video Restyling demo
▶ Play demo
Prompt: 视频风格变为参考图指定的风格

Reference image: Select an image that captures the artistic style you want to apply.
AI Companions Summon virtual characters into your live camera feed and interact with them through gestures. Play the AI Companions demo
▶ Play demo
Prompt: 指定角色在场景中互动

Reference image: Select a clear image of the virtual character you want to summon with a clean background.
Live Photo Animate and control characters in your images simply by drawing motion trajectories. Play the Live Photo demo
▶ Play demo
Prompt: 让画面自然动起来

Reference image: Use the input image as the reference

Why XmaxSDK?

Low latency
Low latency
Cost efficiency
Cost efficiency
High fidelity
High fidelity
End-to-end latency is measured in hundreds of milliseconds, ensuring that updates to generation conditions and interaction controls are reflected instantly. Run on a single RTX 5090, reducing inference costs by orders of magnitude versus datacenter GPUs like H100. Our models support real-time generation at up to 1080p, delivering production-ready, high-quality video output.

Prerequisites

  • A WebRTC-enabled browser running on HTTPS or localhost
  • Node.js 18 or later, with pnpm or npm for development
  • An Xmax API key

[!WARNING] Never commit your Xmax API key to version control or embed a long-lived key in client-side bundles. Use short-lived temporary keys issued by your backend through the Xmax API. For step-by-step instructions, see Authentication.


Installation

npm install @xmaxai/web-sdk

The package includes optional React components at @xmaxai/web-sdk/react. React applications use their own React installation; non-React applications do not need React.

For HTML pages without a build tool, see the browser distribution.


Quick Start

Create a camera stream, start realtime generation, and display the result:

import {
  CameraPosition, RealtimeConfiguration, RealtimeContext, RealtimeModel,
  RealtimeCameraPreset, XmaxClient, XmaxConfiguration, XmaxEnvironment,
  XmaxRealtimeDualVideoView,
} from '@xmaxai/web-sdk'

// Initialize the client
const client = new XmaxClient(new XmaxConfiguration({
  apiKey: '<YOUR_XMAX_API_KEY>',
  environment: XmaxEnvironment.global,
}))

// Initialize the realtime manager
const realtime = client.createRealtimeManager(
  new RealtimeConfiguration({ model: RealtimeModel.x2_1 })
)

// Create the video view
const videoView = new XmaxRealtimeDualVideoView()
videoView.attach(container) // container is a sized element on your page

// Create a camera stream and bind the preview
const localStream = await realtime.createLocalCameraStream({
  preset: RealtimeCameraPreset.resolution1920x1080,
  position: CameraPosition.front,
  useMicrophone: false,
})
videoView.localTrack = localStream.videoTrack

// Once the preview is ready, start generation and display the result
const remoteStream = await realtime.startGeneration({
  localStream,
  context: new RealtimeContext({
    prompt: "视频中角色替换成参考图中角色",
    referencePath: "https://cdn.22duck.cn/images/source/charx/charx_real_image7.png?presetVersion=20260909",
  }),
})
videoView.remoteTrack = remoteStream.videoTrack

// Run the following when generation is no longer needed
await realtime.close()

Session HTTP heartbeats begin when the session first enters generating, then continue every 10 seconds after the preceding heartbeat finishes. The SDK measures the time from connection startup, before creating the session, until entering generating, including render warmup and any wait before generation starts. The first heartbeat sends this duration as firstHeartbeatGraceSeconds, rounded up to whole seconds; later heartbeats omit it. This value is calculated automatically and is not sent when creating a session. The backend determines how the reported duration affects session expiry and billing.

Example Project

A complete React application is available in examples/xlab-react. It demonstrates camera, image and video inputs, reference images, touch interaction, statistics, and recording.


Dependencies

  • Tencent Cloud TRTC SDK for Web enables low-latency, real-time audio and video communication.
  • Agora RTC SDK for Web provides an alternative RTC transport for the Agora model.
  • Volcengine VeRTC SDK for Web enables real-time audio and video communication.
  • Tencent Cloud COS SDK handles media upload and download via object storage.

Contact us

For bug reports and feature requests, please open a GitHub Issue. For integration assistance and technical support, contact us at [email protected].


License

XmaxSDK Web is available under the terms of the MIT License. Third-party dependencies retain their respective licenses.

관련 프로젝트 살펴보기

불러오는 중…