UGemini: Effortlessly Use the Gemini API in Unity!

Hello! I am making an app with the Gemini API in Unity, and I thought I’d share the code I used to interact with the Gemini API!

UGemini is a free and open-source Unity package available on OpenUPM and GitHub which allows you to interface the Gemini API through C# code without handling the requests themselves!

The package supports both versions of the API, the general support is listed below:

  • models endpoint :warning:

    • batchEmbedContents method

    • countTokens method

    • embedContent method

    • generateAnswer method :test_tube:

    • generateContent method

      • JSON output :test_tube:
      • System instructions :test_tube:
      • Text generation
      • Vision
      • Function calling :test_tube:
      • Safety settings
    • get method

    • list method

    • streamGenerateContent method

  • cachedContents endpoint :test_tube:

  • corpora endpoint :test_tube:

  • files endpoint :test_tube:

  • media endpoint :test_tube:

  • tunedModels endpoint

  • operations endpoint

:warning: - Not all methods/features are supported
:test_tube: - Using the v1beta API

Any and all feedback is appreciated!

GitHub Repository
OpenUPM Package

you kiddin me, have you tried it?

you kiddin me, have you tried it?

I see that Gemini is improving and that it’s cheaper than GPT, so I’m using the package in some of my in-development apps. I’ve also included some samples in the package to help.

Since my last update here, I’ve added a lot of new features!

  • models endpoint
    • get method
    • list method
    • streamGenerateContent method
  • files endpoint :test_tube:
    • delete method
    • get method
    • list method
  • media endpoint :test_tube:
    • upload method

:test_tube: - Using the v1beta API

The documentation is also available here: UGemini/UGemini/Packages/com.uralstech.ugemini/Documentation~/README.md at master · Uralstech/UGemini · GitHub
See UGemini: Main Page for reference manual.

Update! The whole models endpoint should now be supported in the preview! Also, I forgot to mention that tunedModels.generateContent is supported.

Update: I’ve restructured the classes in the package and have updated the existing endpoints to match the recent updates to the Gemini API, including support for Code Execution! The updates are still in preview and have not been tested yet.

All of cachedContents and Code Execution is now supported, in production! I’ve also added in full support for tunedModels, but that’s in preview right now and is unstable.

Full tunedModels support has been released. The operations and tunedModels.operations endpoints are also supported through package dependency UCloud.Operations.