A Unity C# wrapper for the Google Gemini API.
Hey everyone,
UGemini was my early wrapper to make Google's Gemini API easy to use in Unity projects. Thanks a ton to everyone who's tried it, starred the repo, downloaded it, opened issues, and donated over the years. It's meant a lot!
As of recently, I've moved on from using this package in my projects in favour of a server-based implementation, so I haven't been developing this much. Google has now released their own SDKs for implementing the Gemini API for .NET and for Unity specifically.
As their GenAI SDK and Firebase AI Logic SDK supports more endpoints than this package, I've decided to archive this package. Even though the GenAI SDK is not available for Unity directly, I believe it should work through NuGetForUnity as it targets netstandard2.0.
Here are the links to the official Google packages:
- GenAI SDK for .NET: https://www.nuget.org/packages/Google.GenAI
- Firebase AI Logic SDK: https://firebase.google.com/docs/ai-logic
Please feel free to fork this repo if needed, and thank you once again.
This should work on any reasonably modern Unity version. Built and tested in Unity 6000.0.26f1 (Unity 6).
- Open project settings
- Select
Package Manager - Add the OpenUPM package registry:
- Name:
OpenUPM - URL:
https://package.openupm.com - Scope(s)
com.uralstechcom.utilities*
- Name:
- Open the Unity Package Manager window (
Window->Package Manager) - Change the registry from
UnitytoMy Registries - Add the
UGemini,Utilities.Async* andUtilities.Encoder.Wav* packages
- Open the Unity Package Manager window (
Window->Package Manager) - Select the
+icon andAdd package from git URL... - Paste the UPM branch URL and press enter:
https://github.com/Uralstech/UGemini.git#upm
- Check the instructions for
UCloud.OperationsandUtils.Singletonto install the dependencies.
Adding additional dependencies:
See the installation steps for the Utilities.Async* and Utilities.Encoder.Wav* packages.
- Clone or download the repository from the desired branch (master, preview/unstable)
- Drag the package folder
UGemini/UGemini/Packages/com.uralstech.ugeminiinto your Unity project'sPackagesfolder - In the
Packagesfolder of your project, add the following line to the list inmanifest.json:"com.uralstech.ugemini": "2.x.x", - Check the instructions for
UCloud.OperationsandUtils.Singletonto install the dependencies.
Adding additional dependencies:
See the installation steps for the Utilities.Async* and Utilities.Encoder.Wav* packages.
*Optional, but Utilities.Async is required for streaming content and Utilities.Encoder.Wav is recommended if you don't want to bother with encoding your AudioClips into Base64 strings manually.
Do not use preview versions (i.e. versions that end with "-preview") for production use as they are unstable and untested.
-
modelsendpoint-
batchEmbedContentsmethod -
countTokensmethod -
embedContentmethod -
generateAnswermethod 🧪 -
generateContentmethod -
getmethod -
listmethod -
streamGenerateContentmethod
-
-
cachedContentsendpoint 🧪-
createmethod -
deletemethod -
getmethod -
listmethod -
patchmethod
-
-
corporaendpoint 🧪 (Unstable)-
documentsendpoint-
chunksendpoint-
batchCreatemethod -
batchDeletemethod -
batchUpdatemethod -
createmethod -
deletemethod -
getmethod -
listmethod -
patchmethod
-
-
createmethod -
deletemethod -
getmethod -
listmethod -
patchmethod -
querymethod
-
-
createmethod -
deletemethod -
getmethod -
listmethod -
patchmethod -
querymethod
-
-
filesendpoint 🧪-
deletemethod -
getmethod -
listmethod
-
-
mediaendpoint 🧪-
uploadmethod
-
-
tunedModelsendpoint 🧪-
createmethod -
deletemethod -
generateContentmethod -
getmethod -
listmethod -
patchmethod -
transferOwnershipmethod
-
-
tunedModels.operationsendpoint*-
cancelmethod -
getmethod -
listmethod
-
-
operationsendpoint*-
listmethod
-
🧪 - Using the v1beta API
*Through package dependency UCloud.Operations.
See https://uralstech.github.io/UGemini/DocSource/QuickStart.html or APIReferenceManual.pdf and Documentation.pdf in the package documentation for the reference manual and tutorial.