import { Reactor, fetchInsecureJwtToken } from "@reactor-team/js-sdk";
// Authenticate
const jwtToken = await fetchInsecureJwtToken(apiKey);
// Create instance
const reactor = new Reactor({
modelName: "livecore",
});
// Set up video display
reactor.on("streamChanged", (videoTrack) => {
if (videoTrack) {
const stream = new MediaStream([videoTrack]);
document.getElementById("video").srcObject = stream;
}
});
// Connect to the model
await reactor.connect(jwtToken);
// Send commands
await reactor.sendCommand("schedule_prompt", {
new_prompt: "A sunset over the ocean",
timestamp: 0
});
await reactor.sendCommand("start", {});