
Building Voice NPCs on the OpenAI Realtime API vs Using Neocortex
On Friday night you connect a microphone to gpt-realtime-2.1, write a system prompt for a grumpy blacksmith, and by Sunday he is insulting your armour choices out loud. It feels finished. It is not.
Speech-to-speech models make a talking NPC demo an afternoon's work. Shipping that NPC to players takes much longer, and almost none of the extra work is about the model. This post lays out what building voice NPCs directly on the OpenAI Realtime API involves in Unity, and where Neocortex fits.
What the Realtime API gives you
- Speech-to-speech models, currently led by gpt-realtime-2.1, with configurable reasoning effort, function calling and a 128K context window.
- Connections over WebRTC for browsers and mobile, WebSocket from a server, and SIP for phone calls.
- Short-lived client secrets your server creates for each session, so the API key stays off the client.
- Built-in voices, ten of them. The voice cannot change once the model has spoken in a session.
- Custom voices from recordings, limited to eligible customers who contact OpenAI sales, with a consent recording from the voice owner.
- Token-based pricing for audio and text, input and output.
- Sessions capped at 60 minutes.
- Official SDKs for JavaScript, Python, .NET, Java, Go and Ruby. Unity support comes from community libraries.
DIY on OpenAI Realtime vs Neocortex
| DIY on OpenAI Realtime | Neocortex | |
|---|---|---|
| Unity client | Write your own, or adopt a community library | Unity SDK, Unity 6, six sample scenes |
| Session handling | Client secrets server, reconnect before 60 minutes | No session cap: each turn is a separate API call |
| Character design | Prompts in code | Visual node editor |
| Voice | Built-in voices; custom voices for eligible customers | Voice cloning and voice design on Pro and Team |
| Game actions | Wire up function calls | Actions with target IDs and scene objects built in |
| Story structure | Your own state machine | Conversation Flows with flowState checkpoints |
| Engines | Whatever you build | Unity, Unreal Engine 5, Godot (beta), Web API |
| Model choice | OpenAI models | Managed for you, plus local models through Ollama in Unity for text chat prototypes |
| Cost | Audio and text tokens | Monthly plans with included credits |
The eight things you would build yourself
To ship a voiced NPC on the Realtime API, your team owns:
- A Unity audio client that captures the microphone, streams it, and plays the reply without gaps, including in WebGL builds, where Unity has no built-in microphone input.
- A small backend that authenticates players and mints a client secret per session, because your API key can never ship in a game build.
- Character design as prompts, kept consistent across every model update and every writer who touches them.
- Session lifecycle: reconnecting before the 60-minute cap, and carrying the conversation across the gap.
- Game integration, so function calls turn into actions on the right objects in your scene.
- Guardrails, so the blacksmith stays a blacksmith when players try to make him something else.
- Cost control, since every second of audio in and out is billed in tokens.
- Upkeep every time models, prices or APIs change, across every engine you ship on.
None of it is impossible. All of it is time you are not spending on your game.
A shopkeeper NPC, built both ways
Say the player walks into a shop and asks the owner for a healing potion. The owner should answer in character, sound annoyed if the player was rude earlier, and actually hand over the item.
On the Realtime API
You write a prompt describing the shopkeeper and the shop's stock, and define a give_item function.
Your backend mints a client secret, your Unity client opens the session, streams the player's voice and plays the reply. When the model calls give_item, your code finds the potion and moves it to the inventory.
For the shopkeeper's mood, you track rudeness in game state and inject it into the prompt, then add an animation cue by parsing the text or asking the model for structured output. If the voice should be unique to this character, you check whether you qualify for custom voices.
On Neocortex
You build the shopkeeper in the visual editor: Personality and a starting Emotion for temperament, Knowledge for the stock list, an Intent for buying and an Action for handing over an item. You clone or design a voice for him.
In Unity, your game sends nearby objects and recent events, including the player's rude remark. The reply arrives as lines with an emotion tag, so the animator knows he is annoyed, plus an action like { "name": "GIVE_ITEM", "targetId": "potion_01" } that your game executes.
You test the whole exchange in the browser first, without using credits.
Both versions use a capable model. The difference is where the shopkeeper lives: in a prompt string and glue code your engineers maintain, or in a character a designer can open, read and change without touching the build.
Build the game, not the plumbing
The real cost of the DIY route shows up after launch. A model update changes how the blacksmith phrases things, a price change shifts your margins, a new Unity version breaks the community library you relied on. Each one lands on your team, usually while you are busy with something else.
The Realtime API is a model you build a voice stack around. Neocortex is the voice stack, with the character, the engine SDKs and the gameplay hooks already in place, maintained by us as models and APIs change. Designers edit personality, emotion, knowledge, intents and actions as nodes in a graph rather than a prompt buried in code, and your engineers spend their weeks on the game.
OpenAI details were last checked in October 2026.
Frequently Asked Questions
Does the OpenAI Realtime API have a Unity SDK?
No. OpenAI's official SDKs cover JavaScript, Python, .NET, Java, Go and Ruby, and Unity support comes from community libraries. Neocortex has a Unity SDK for Unity 6 with six sample scenes, plus Unreal Engine 5, Godot (beta) and a Web API.
How long can an OpenAI Realtime session last?
Realtime sessions are capped at 60 minutes, so long play sessions need reconnect logic and a way to carry context over. With Neocortex, each turn is a separate API call and the SDK handles it, so there is no session to time out, and you work with replies and actions.
Does the OpenAI Realtime API support custom voices?
Custom voices from recordings are limited to eligible customers who go through OpenAI sales; everyone else picks from the built-in voices. Neocortex lets you clone a voice from a short sample you have the rights to or design one from a text description, with 5 custom voices on Pro and 20 on Team.
How is the OpenAI Realtime API priced?
By text and audio tokens in and out, so every second of speech adds to the bill. Neocortex plans are monthly with included credits, and testing a character in the browser editor never uses credits.
Written by
Neocortex Team
Date
Oct 17, 2026
Updated
Oct 20, 2026
Read time
5 min






