Com.openai.unity
A Non-Official OpenAI Rest Client for Unity (UPM)
Install / Use
/learn @RageAgainstThePixel/Com.openai.unityREADME
OpenAI
Based on OpenAI-DotNet
A OpenAI package for the Unity to use though their RESTful API. Independently developed, this is not an official library and I am not affiliated with OpenAI. An OpenAI API account is required.
All copyrights, trademarks, logos, and assets are the property of their respective owners.
Installing
Requires Unity 2021.3 LTS or higher.
The recommended installation method is though the unity package manager and OpenUPM.
Via Unity Package Manager and OpenUPM
Terminal
openupm add com.openai.unity
Manual
- Open your Unity project settings
- Add the OpenUPM package registry:
- Name:
OpenUPM - URL:
https://package.openupm.com - Scope(s):
com.openaicom.utilities
- Name:

- Open the Unity Package Manager window
- Change the Registry from Unity to
My Registries - Add the
OpenAIpackage
Via Unity Package Manager and Git url
[!WARNING] This repo has dependencies on other repositories! You are responsible for adding these on your own.
- Open your Unity Package Manager
- Add package from git url:
https://github.com/RageAgainstThePixel/com.openai.unity.git#upm
Documentation
Check out our new api docs!
https://rageagainstthepixel.github.io/OpenAI-DotNet
Table of Contents
- Authentication
- Azure OpenAI
- OpenAI API Proxy
- Models
- Responses
- Conversations
- Realtime
- Assistants
- List Assistants
- Create Assistant
- Retrieve Assistant
- Modify Assistant
- Delete Assistant
- Assistant Streaming
- Threads
- Vector Stores
- Chat
- Audio
- Images
- Files
- Fine Tuning
- Batches
- Embeddings
- Moderations
Authentication
There are 4 ways to provide your API keys, in order of precedence:
[!WARNING] We recommended using the environment variables to load the API key instead of having it hard coded in your source. It is not recommended use this method in production, but only for accepting user credentials, local testing and quick start scenarios.
- Pass keys directly with constructor :warning:
- Unity Scriptable Object :warning:
- Load key from configuration file
- Use System Environment Variables
You use the OpenAIAuthentication when you initialize the API as shown:
Pass keys directly with constructor
[!WARNING] We recommended using the environment variables to load the API key instead of having it hard coded in your source. It is not recommended use this method in production, but only for accepting user credentials, local testing and quick start scenarios.
var api = new OpenAIClient("sk-apiKey");
Or create a OpenAIAuthentication object manually
var api = new OpenAIClient(new OpenAIAuthentication("sk-apiKey", "org-yourOrganizationId", "proj_yourProjectId"));
Unity Scriptable Object
You can save the key directly into a scriptable object that is located in the Assets/Resources folder.
You can create a new one by using the context menu of the project pane and creating a new OpenAIConfiguration scriptable object.
[!WARNING] Beware checking this file into source control, as other people will be able to see your API key. It is recommended to use the OpenAI-DotNet-Proxy and authenticate users with your preferred OAuth provider.

Load key from configuration file
Attempts to load api keys from a configuration file, by default .openai in the current directory, optionally
Related Skills
node-connect
340.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
340.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.2kCommit, push, and open a PR