UGemini

A Unity C# wrapper for the Google Gemini API.

openupm openupm

Installation

This should work on any reasonably modern Unity version. Built and tested in Unity 2022.3.

  1. Open project settings
  2. Select Package Manager
  3. Add the OpenUPM package registry:
    • Name: OpenUPM
    • URL: https://package.openupm.com
    • Scope(s)
      • com.uralstech
      • com.utilities*
  4. Open the Unity Package Manager window (Window -> Package Manager)
  5. Change the registry from Unity to My Registries
  6. Add the UGemini, 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.

Preview Versions

Do not use preview versions (i.e. versions that end with "-preview") for production use as they are unstable and untested.

Gemini API Support

  • ✔️ models endpoint

    • ✔️ batchEmbedContents method
    • ✔️ countTokens method
    • ✔️ embedContent method
    • ✔️ generateAnswer method 🧪
    • ✔️ generateContent method
    • ✔️ get method
    • ✔️ list method
    • ✔️ streamGenerateContent method
  • ✔️ cachedContents endpoint 🧪

    • ✔️ create method
    • ✔️ delete method
    • ✔️ get method
    • ✔️ list method
    • ✔️ patch method
  • corpora endpoint 🧪

  • ✔️ files endpoint 🧪

    • ✔️ delete method
    • ✔️ get method
    • ✔️ list method
  • ✔️ media endpoint 🧪

    • ✔️ upload method
  • ✔️ tunedModels endpoint 🧪

    • ✔️ create method
    • ✔️ delete method
    • ✔️ generateContent method
    • ✔️ get method
    • ✔️ list method
    • ✔️ patch method
    • ✔️ transferOwnership method
  • ✔️ tunedModels.operations endpoint*

    • ✔️ cancel method
    • ✔️ get method
    • ✔️ list method
  • ✔️ operations endpoint*

    • ✔️ list method

🧪 - Using the v1beta API

*Through package dependency UCloud.Operations.

Documentation

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.