Skip to main content
This guide demonstrates how to integrate a real-time Zero Runtime AI agent with a Unity application. The agent, powered by Google’s Gemini Live API, acts as a high-energy game show host, guiding the user through a number-guessing game via voice.

Prerequisites

Before you begin, ensure you have the following:
  • A Zero Runtime account (create one from the Zero Runtime Dashboard).
  • Unity 2022.3 LTS or later.
  • Python 3.11+ for the AI agent.
  • A Google API Key for the Gemini Live API.
You need a Zero Runtime account to generate a token and a Google API key for the Gemini Live API. Generate a token from the Zero Runtime Dashboard and a Google API key from Google AI Studio.

1. Unity Frontend

Step 1: Install the RTC SDK package

  1. Open Unity’s Package Manager by selecting from the top bar: Window -> Package Manager.
  2. Click the + button in the top left corner and select Add package from git URL.
  3. Paste the following URL and click Add:
Install the package from the Unity Package Manager using the git URL above.
  1. Add the com.unity.nuget.newtonsoft-json package by following the instructions provided here.

Step 2: Platform setup

To integrate the RTC SDK into your Android project, follow these steps:
  1. Add the following repository configuration to your settingsTemplate.gradle file:
settingsTemplate.gradle
  1. Install the Android SDK in mainTemplate.gradle:
mainTemplate.gradle
  1. If your project has set android.useAndroidX=true, then set android.enableJetifier=true in the gradleTemplate.properties file to migrate your project to AndroidX and avoid duplicate class conflicts.
gradleTemplate.gradle

Step 3: Create a meeting room

Create a static roomId using the Zero Runtime API. Both the Unity app and the AI agent will use this ID to connect to the same meeting.
Replace YOUR_JWT_TOKEN_HERE with your Zero Runtime auth token. Copy the roomId from the response for the next steps.

Step 4: Configure the Unity project

Update GameManager.cs with your Zero Runtime auth token and the roomId you just created.
Unity/Assets/Scripts/GameManager.cs

Step 5: Set up platform-specific permissions

Add the following permissions to your AndroidManifest.xml file:
AndroidManifest.xml

2. Python AI Agent

Step 1: Setup the project

Use Python 3.11 or higher, then install the Zero Runtime Agents SDK. Create and activate a virtual environment, then install zrt and python-dotenv. Every provider plugin ships with zrt.
New to uv? See the uv install guide.

Step 2: Configure environment variables

Create a .env file in the Unity-quickstart directory to store your keys and token securely for the Python agent:
.env

Step 3: Create the AI agent backend

The Python agent joins the same meeting room to interact with the user. Create agent-unity.py with your roomId.
agent-unity.py

3. Run the Application

Step 1: Run the AI agent

Open a terminal, navigate to the Unity-quickstart directory, activate your virtual environment, and run the agent. It reads GOOGLE_API_KEY from the .env file.

Step 2: Run the Unity application

  1. Open the Unity/ project in Unity Hub.
  2. Once the project is loaded, press the Play button in the Unity Editor to start the application.
  3. Click the Join Meeting button in the app to connect to the session.
Once you join the meeting, the AI agent will greet you and start the game.

Troubleshooting

  • Ensure both the Unity application and the agent are running.
  • Check that the roomId matches in GameManager.cs and agent-unity.py.
  • Verify your Zero Runtime token is valid.
  • Check platform permissions for microphone access (see Step 5 in Part 1).
  • Ensure your Google API key has Gemini Live API access enabled.
  • Verify your GOOGLE_API_KEY is set in the .env file.
  • Check that the Gemini Live API is enabled in your Google Cloud Console.

Next Steps

Quickstart Example

Complete working example with source code.

Build Your First Voice Agent

Learn the Cascade and Realtime pipelines in depth.