- open an Adventure or Directing session
- create a world and show build progress
- save and reattach a world
- stream the live world into a video element
- expose controls appropriate to the selected experience
Install the SDK
- npm
- pnpm
@reactor-models/happy-oyster. The world walkthrough imports its React bindings from
@reactor-models/happy-oyster/react.
Mint a client token
Keep the Reactor API key on your server. Exchange it for a short-lived JWT and return only the JWT to the browser:Mount the provider
The mode belongs on the provider, not oncreateWorld(). Use "adventure" for movement controls or
"directing" for text steering:
Create a world
createWorld() accepts parameters for the provider’s mode and resolves when the world reaches
ready.
createWorld() does not take a mode
field.
Reopen a saved world
Worlds persist beyond a session. Reopen one by its encrypted id:attachWorld() rejects it with code
403001. Drop the saved id and create a new world.
The world must belong to the provider’s selected mode. Attach an Adventure world through an
Adventure provider and a Directing world through a Directing provider.
Start and stop a travel
Mount<HappyOysterVideo /> before starting. Once the current world is ready:
endTravelSession() ends the live travel but keeps the Reactor session and world ready.
disconnect() closes the session; the world remains available for a later attachWorld().
Show the remaining travel time
An Adventure travel runs for up to 2 minutes, and the platform ends the stream when that budget runs out. The hook reports the granted length asmaxExperienceTimeSec. Count down from it, with
ADVENTURE_MAX_EXPERIENCE_SEC covering the render before a travel is open:
maxExperienceTimeSec as null. Count its
clock down from that length and call endTravelSession() when it reaches zero.
Add Adventure controls
Adventure input is held state. Callmove, look, or interact when an input begins, then release
the corresponding axis when it ends:
Add Directing controls
Directing uses text instructions and playback controls:useHappyOysterTravelStatus() to track whether a Directing travel is running, paused, or
completed.
Handle errors
Awaited setup calls reject on failure. Gate and upstream failures useHappyOysterActionError:
Runtime stream errors are available through
useHappyOysterTravelError().
Add an Acting experience
Acting uses a reusable character and a performance. The token route above includesreactor/happy-oyster-acting in authorization_details. An Acting-only app can scope its route to
that model alone. Keep the API key on the server and return the same token for the session’s life.
Create or attach a character
- Supply a character prompt and exactly one image source to
create_character. For portrait9:16, use an image with width/height from 0.5 to 0.667. For landscape16:9, use a ratio from 1.5 to 2.0. - Mirror
session_stateto show build progress. The command returns before the build finishes. - Save the account-scoped
character_idfor later reuse withattach_character. The API specifies no retention period; handleCHARACTER_NOT_FOUNDif a saved id cannot be attached. - Wait for
character_status: "ready"before starting a performance.
Perform and direct
Callstart_performance and wait for snapshot phase live. Display main_video with speech from
main_audio. Supply a playback control for browsers that block audible autoplay. Receiving an audio
track alone does not establish audible playback.
Send instruct commands with a text field for actions and speech. Track pending and performed
instructions in the snapshot. Paused instructions take effect after resume; an acknowledgment does
not mean the character performed an instruction. A rejected instruction can leave the performance
live.
Read the end_performance result from the awaited call, then wait for snapshot phase ended before
starting another performance. The character stays attached. Keep Start disabled through starting
and ending, and show failures from the current snapshot alongside SDK call errors.
The active performance limit excludes paused time. performance_elapsed_seconds includes it, so
subtracting that field from performance_max_seconds gives an incorrect countdown after a pause.
Keep connection state current
Mirror the authoritativesession_state broadcast, and apply replies from get_state only to the
connection that requested them. Clear local snapshots when the connection ends. Ignore replies and
uploads from older connections so they cannot restore stale state in a new session.
The Acting reference lists command
fields, image formats, URL alternatives, replies, phase gates, and errors.
Next steps
- Read the SDK reference for world methods, React bindings, Acting commands, and model state.
- Use the prompt guide to author more stable worlds.
- Clone the HappyOyster example for a complete Next.js implementation.