TL;DR
Genie 4 is Google DeepMindโs real-time interactive world model. It generates 720p video at 24 fps with synchronized stereo audio, and lets you navigate or change a scene while it runs. Developer access opened through the Gemini API on November 19, 2026. This guide covers Python frame capture, reference-image setup, browser playback, and session costs.
Key Takeaways
- Genie 4 streams 720p video at 24 fps with synchronized stereo sound.
- Use Python over WebSocket to save individual frames and audio. Use WebRTC to play the stream in a browser.
- Send one setup event per world. Use keyboard events to move and text to change the scene.
- End the session explicitly to stop server-side generation and billing.
- Keep the Gemini API key on your server. Give the browser a short-lived session token when the reader starts the player.
What is Genie 4?
A Genie 4 session starts with a scene and keeps generating what you see and hear as you explore. In a harbor scene, pressing W takes you toward the boats. A text instruction can bring in fog while you are still moving. Each input acts on the world already on screen.
What you can control
Choose a starting view with text or a landscape image. Use WASD to move, arrow keys to look around, and a short instruction to introduce an event. You can try these controls in the Genie 4 playground before writing code.

A hummingbird and an orange flower appear inside a transparent sphere in Google DeepMindโs Genie 4 announcement. The accompanying demos show how scenes respond to live input.
What do you need before calling the Genie 4 API?
Use Python 3.11 or later for the timeout in this example, a paid-tier Gemini API key, and a connection that permits outbound WebSocket traffic. Work in a fresh directory so the files from this run are easy to identify. Googleโs Genie 4 quickstart describes the session lifecycle.
Install the Google SDK in the Python environment that will run your script.
python -m pip install --upgrade google-genai
Set the Gemini key in your macOS or Linux shell.
export GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
On Windows, set the same variable in PowerShell.
$env:GEMINI_API_KEY="YOUR_GEMINI_API_KEY"
How do you use the Genie 4 API with Python?
Step 1. Choose a starting scene
Save the following prompt as world_prompt.txt in the directory where you will run the script. The bridge gives you a destination, and the lighthouse gives you a landmark to look for when you turn back.
At sunrise, I face a stone bridge in a small coastal town. A lighthouse stands on the distant hill. A wooden fishing boat rests in the harbor. Warm light filters through fog. I hear waves, gulls, and my footsteps on stone. As I walk toward the boat, keep the view continuous and the lighthouse in place.
Step 2. Open the session and collect video and audio
Save the script below as explore.py beside world_prompt.txt. It sends the scene once, collects approximately six seconds of video frames, and asks the server to finish. On a successful run, youโll find two JPEGs beside the script: first_frame.jpg from frame 1 and last_frame.jpg from frame 144. The audio chunks are joined into a stereo WAV file.
Start explore.py with the imports and session variables below. Append the next three snippets to the same file, keeping their indentation.
import asyncio
import base64
import wave
from pathlib import Path
from google import genai
async def main():
prompt = Path("world_prompt.txt").read_text(encoding="utf-8")
client = genai.Client(http_options={"api_version": "v1beta"})
interaction = await client.aio.interactions.create(
model="genie-4", api_version="v1beta"
)
first_frame = None
audio = bytearray()
frames = 0
Connect to the world and send the starting scene. In the receive loop, stop on completion and surface any server error.
async with client.aio.interactions.connect(
interaction.id, api_version="v1beta"
) as session:
ending = False
try:
async with asyncio.timeout(45):
await session.send({
"event_type": "world_setup",
"world_prompt": {"text": prompt},
})
async for event in session.receive():
if event.event_type == "interaction.completed":
ending = True
break
if event.event_type == "error":
raise RuntimeError(str(event))
if event.event_type != "step.delta":
continue
At frame 1, keep the opening view and press W. At frame 48, release W and ask for light rain. At frame 144, keep the closing view and request completion. Collect incoming audio chunks in order.
delta = event.delta
if delta.type == "video" and delta.data:
frames += 1
if first_frame is None:
first_frame = base64.b64decode(delta.data)
await session.send({
"event_type": "user_action", "action": "key_down", "input": "key_w"
})
if frames == 48:
await session.send({
"event_type": "user_action", "action": "key_up", "input": "key_w"
})
await session.send("Light rain begins over the harbor.")
if frames == 144:
last_frame = base64.b64decode(delta.data)
await session.complete()
ending = True
elif delta.type == "audio" and delta.data:
audio.extend(base64.b64decode(delta.data))
finally:
if not ending:
await session.cancel()
After the connection closes, save both JPEGs and the stereo WAV file. An early stop before frame 144 raises an error so you can tell the capture is incomplete. The last line starts the script.
if last_frame is None:
raise RuntimeError(f"Capture ended before frame 144 ({frames} frames received)")
if not first_frame or not audio:
raise RuntimeError(f"Incomplete capture: {frames} frames, {len(audio)} audio bytes")
Path("first_frame.jpg").write_bytes(first_frame)
Path("last_frame.jpg").write_bytes(last_frame)
with wave.open("world_audio.wav", "wb") as wav:
wav.setparams((2, 2, 48000, 0, "NONE", "not compressed"))
wav.writeframes(audio)
print(f"Saved first_frame.jpg and world_audio.wav ({frames} video frames received)")
print("Saved last_frame.jpg (frame 144)")
asyncio.run(main())
Step 3. Run the script and inspect your capture
Run the command below from the directory containing explore.py and world_prompt.txt. The first frame typically arrives after five to nine seconds. The script then captures about six seconds of generated output.
python explore.py
Compare first_frame.jpg with last_frame.jpg. Look for a change in distance from the bridge and signs of rain in the later view. Each JPEG is a still image. Play world_audio.wav to hear the session.
How do you build an interactive Genie 4 experience?
With the basic Python session working, you can seed a world from an image, send movement and event controls, and build a browser player with WebRTC.
Start a world from a reference image
Use a single landscape image with a 16:9 aspect ratio. For WebRTC, Google recommends keeping a compressed JPEG under 48 KB so the encoded setup event fits the data channel.
Place reference.jpg beside your script. Inside the connected session, replace the original world_setup send with this image-based setup. Keep the receive loop that follows it.
Read the JPEG and encode its bytes inside the connected session.
import base64
from pathlib import Path
image_bytes = Path("reference.jpg").read_bytes()
encoded_image = base64.b64encode(image_bytes).decode("utf-8")
Use the encoded image as the starting view. Describe what the player should see and hear when the stream begins.
world_setup = {
"event_type": "world_setup",
"world_prompt": {
"text": (
"Explore this futuristic city in first person. "
"Preserve its architecture and lighting. "
"Audio: Traffic, wind, and footsteps."
)
},
"reference_image": {
"mime_type": "image/jpeg",
"data": encoded_image
}
}
await session.send(world_setup)
Send the setup before receiving the first frame. To change the weather later in the same world, send a text event through the open session.
Control movement and trigger live events
In explore.py, frame 1 triggers forward movement. At frame 144 it keeps the final JPEG in memory and requests completion. The files are written after the connection closes. At frame 144 it saves the final view and ends generation. The excerpt below highlights the controls already built into Step 2. To try another weather change, edit the rain instruction in explore.py and run it in a fresh directory.
if frames == 1:
await session.send({
"event_type": "user_action", "action": "key_down", "input": "key_w"
})
elif frames == 48:
await session.send({
"event_type": "user_action", "action": "key_up", "input": "key_w"
})
await session.send("Light rain begins over the harbor.")
Stream the world in a browser with WebRTC
Use a backend to keep your long-lived Gemini key private. The backend creates the interaction and returns a short-lived session token to the browser.
Install the JavaScript SDK in your Node.js backend and in the frontend project that bundles the browser module.
npm install @google/genai
Create the session on your server
Use this function in an authenticated POST /api/genie/session handler. Return its result as JSON to the requesting browser.
On the server, open an interaction using your Gemini API key.
import { GoogleGenAI } from "@google/genai";
const serverAI = new GoogleGenAI({
apiKey: process.env.GEMINI_API_KEY,
apiVersion: "v1beta"
});
export async function createGenieSession() {
const interaction = await serverAI.interactions.create({
model: "genie-4",
api_version: "v1beta"
});
Finish the function by issuing a short-lived token for this interaction. Return both values to the browser.
const { auth_token } =
await serverAI.interactions.authTokens.create(
interaction.id,
{ api_version: "v1beta" }
);
return {
interactionId: interaction.id,
authToken: auth_token
};
}
Connect the browser player and bind controls
Save this browser module as genie-client.js. It connects the video element and exposes methods for movement, weather changes, and stopping the session.
Start genie-client.js by connecting the session to your video element. Append the next two snippets inside the same function.
import { GoogleGenAI } from "@google/genai";
export async function startGenieWorld(
interactionId, authToken, videoElement
) {
const client = new GoogleGenAI({
apiKey: authToken,
apiVersion: "v1beta"
});
const session = await client.interactions.connect(
interactionId,
{ transport: "webrtc", api_version: "v1beta" },
{ timeout_ms: 30000 }
);
session.transport.setVideoElement(videoElement);
Send the island scene once when the connection opens.
await session.send({
event_type: "world_setup",
world_prompt: {
text: "First-person exploration of a tropical island. " +
"Palm trees move in the wind and waves reach the beach. " +
"Audio: Ocean surf and tropical birds."
}
});
Return controls that your interface can call when the player moves, changes the weather, or ends the visit.
return {
moveForward: () => session.send({
event_type: "user_action",
action: "key_down",
input: "key_w"
}),
stopMoving: () => session.send({
event_type: "user_action",
action: "key_up",
input: "key_w"
}),
changeWeather: () => session.send(
"A tropical storm approaches from the horizon."
),
stop: () => session.complete()
};
}
Add a video element to the page that hosts the player.
<video id="world-video" autoplay playsinline></video>
Run this in your frontend module after the video element loads. Start from a user click and wire the returned controls to your interface.
import { startGenieWorld } from "./genie-client.js";
export async function openWorld() {
const response = await fetch("/api/genie/session", { method: "POST" });
if (!response.ok) throw new Error("Could not create a Genie session");
const { interactionId, authToken } = await response.json();
return startGenieWorld(
interactionId, authToken, document.querySelector("#world-video")
);
}
Call moveForward() when the forward key goes down and stopMoving() when it comes up. Connect a visible End session button to stop() so the reader can end generation deliberately.
How do you troubleshoot a Genie 4 API session?
The request fails before the first frame
If you get an authentication or access error, check that GEMINI_API_KEY is set in the terminal that launches explore.py and belongs to a project with paid API access. If the interaction opens but a frame never arrives, check the WebSocket connection and confirm the client sent one world_setup event. Initial generation normally takes about five to nine seconds.
The frame arrives but the audio sounds distorted
Check the WAV header against the WebSocket audio format. Decode each audio delta from base64, preserve arrival order, and write the bytes as two-channel, 16-bit PCM at 48 kHz. A mono header or the wrong sample rate changes how the player interprets those bytes.
The browser player opens but stays blank
Inspect the response from your own session endpoint. The browser needs both the interaction ID and its short-lived token. Then check that the video element exists when startGenieWorld runs and that the connection reaches world_setup. If video plays silently, try starting playback from a user click.
How much does a Genie 4 session cost?
Google bills $17.50 per million video output tokens at the standard rate, including audio. Each frame uses 240 tokens. At 24 fps, a minute uses 345,600 video tokens and costs $6.048 before rounding.
| Duration | Estimated video cost |
|---|---|
| 10 seconds | $1.01 |
| 30 seconds | $3.02 |
| 60 seconds | $6.05 |
| 120 seconds | $12.10 |
Estimates use the standard rates listed on November 25, 2026. Input and text-output charges are additional.
A session lasts up to 120 seconds. When planning a shared demo, also check your concurrent session limit. Tier 1 allows two active sessions and 50 requests per day.
For a prototype budget, twenty 30-second visits add up to ten minutes of generated output, or about $60.48 before input and text-output charges. Count the seconds that each session generates, including time a visitor spends standing still.
What does CometAPI charge to draft the scene?
If you write world_prompt.txt yourself, you can skip the CometAPI call. If you use Gemini 4 Neon to draft it, CometAPI lists $2.40 per million standard input tokens and $12.00 per million output tokens. A request billed for 1,000 input tokens and 250 output tokens costs $0.0054, just over half a cent.
You can reuse the saved prompt across sessions. Google bills each Genie 4 stream at the video rate shown above.
FAQ
Can I try Genie 4 before writing code?
Yes. Open the Genie 4 playground in Google AI Studio, describe a scene and explore it with the movement controls. To run the Python tutorial or connect your own player, use a paid-tier Gemini API project.
How much does a 30-second Genie 4 session cost?
About $3.02 for generated video with synchronized audio at the standard rate. Input and text-output tokens are billed separately.
Why does a saved JPEG look still even though the world is interactive?
The Python example saves two stills, one at frame 1 and one at frame 144. Open them side by side to compare the harbor before and after the movement and weather request. To replay the journey, save subsequent JPEGs in arrival order and encode them at 24 fps with the WAV track. For immediate playback, use the browser example.
Can I reconnect to the same Genie 4 world after closing a tab?
Genie 4 does not support session resumption. A local disconnect can leave the server generating output. Use complete() or cancel() to end generation, then create a fresh interaction if the user returns.
Why does a landmark move when I turn back toward it?
Objects can drift as the scene changes, particularly after a long turn or several edits. Google reports the strongest object permanence during the first 45โ90 seconds. For a navigation prototype, try a short out-and-back route before adding weather changes or characters.
Conclusion
For a first prototype, give the player one recognizable destination and one action to take there. Walk to the bridge, ask for rain, then turn back toward the lighthouse. That short route tells you whether movement feels responsive and the scene stays recognizable. Once it works for your audience, add a second interaction and measure the cost of a complete visit.
