Xmax-AI/XmaxSDK-Web
حول
Javascript SDK for real-time interactive video generation with Xmax AI
التصميم والوسائطما يمكنك فعله
- 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.
النمو المقاس للنجوم
- خلال 24 ساعة
- ٠
- خلال 7 أيام
- +١
- خلال 15 يومًا
- +٢
- خلال شهر
- جارٍ جمع السجل
تغيّر صافي النجوم خلال فترات متداخلة، وليس مجموعًا يوميًا. تبقى القياسات المفقودة فارغة. النجوم تقيس الاهتمام لا جودة البرمجيات.
README.md
الأصل
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.



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 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. |
||
| Video Restyling | Reimagine your world in any style with an immersive visual experience. |
▶ 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 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 demo |
Prompt: 让画面自然动起来
Reference image: Use the input image as the reference |
Why XmaxSDK?
|
Low latency |
Cost efficiency |
High fidelity |
|---|---|---|
| End-to-end latency is measured in |
Run on a |
Our models support real-time generation at up to |
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.
استكشف مشاريع مشابهة ومرتبطة
جارٍ التحميل…