Unity package for integrating OpenAI's real-time conversation API into your Unity projects.
Before installing this package, add NativeWebSocket:
- Open Unity Package Manager (Window → Package Manager)
- Click + → Add package from git URL
- Enter:
https://github.com/endel/NativeWebSocket.git#upm - Click Add
- Open Unity Package Manager (Window → Package Manager)
- Click + → Add package from git URL
- Enter:
https://github.com/danieloquelis/Unity-QuestConversationalAI.git?path=/com.convai.openai - Click Add
- Create an account at OpenAI Platform
- Navigate to API Keys
- Generate a new API key
- In Unity, go to
Assets/Resources/ - Right-click → Create → OpenAI → Config
- Paste your API key in the configuration asset
- Save the configuration
The main prefab for handling OpenAI real-time conversations.
Setup:
- Drag
RealtimeConversationManagerprefab into your scene - Assign your OpenAI config asset to the
configfield - Configure the
systemPromptfor AI behavior - Run the scene and start speaking
Key Properties:
| Property | Type | Description |
|---|---|---|
config |
OpenAIConfig |
Configuration asset with API key |
systemPrompt |
string |
AI behavior instructions |
autoStart |
bool |
Start conversation automatically |
Prefab for managing custom tools that the AI can invoke during conversations.
Setup:
- Drag
AgentToolsBindingprefab into your scene - Assign your tool scripts to the binding component
- Configure tool schema JSON files
Custom tools let the AI perform actions in your scene. See the Complete Tools Guide for detailed examples.
1. Create a C# script with tool methods:
using System.Threading.Tasks;
using Newtonsoft.Json.Linq;
using UnityEngine;
public class MyTools : MonoBehaviour
{
// Method signature: public async Task<JObject> ToolName(JObject args)
public async Task<JObject> Light_TurnOn(JObject args)
{
GetComponent<Light>().enabled = true;
await Task.Yield();
return new JObject { ["ok"] = true };
}
}2. Create a JSON schema:
{
"tools": [{
"type": "function",
"name": "Light_TurnOn",
"description": "Turn on the light",
"parameters": { "type": "object", "properties": {} }
}]
}3. Wire up in Unity:
- Attach
MyToolsscript to a GameObject - In
ToolBindingscomponent:- Set
Tools Json→ your JSON file - Set
Target→ GameObject with your script
- Set
See tools.md for complete guide with patterns and troubleshooting.
onAgentTranscript: Fired when AI speaks (provides transcript text)onUserTranscript: Fired when user speaks (provides transcript text)onUserSpeaking: Fired when user speaking state changes (bool)onAgentSpeaking: Fired when AI speaking state changes (bool)