GeminiApp Gets a Major Upgrade: Seamless Transition Between Google AI Studio and Vertex AI, Enhanced Functionality, Multimodal Input, and More!
Image credit: Created by Gemini for Workspace

GeminiApp Gets a Major Upgrade: Seamless Transition Between Google AI Studio and Vertex AI, Enhanced Functionality, Multimodal Input, and More!

The GeminiApp library, a solution I created for integrating Google's Gemini AI models into your Google Apps Script projects, has had a major update! 

Since its publication last year it has been great to hear and see how GeminiApp is being used by the community, including members of Google's DevRel team highlighting it as an option. This new release introduces significant enhancements, expanding the library's capabilities for building sophisticated AI-powered applications directly within Google Workspace.

This post will explore the key enhancements included in the 2025.01 version bump, focusing on how these changes empower you to do even more with Gemini and Apps Script.

What's New?

The latest update to the GeminiApp library is a significant leap forward in terms of functionality, flexibility, and ease of deployment. The library now boasts enhanced capabilities that allow for more intricate interactions with the Gemini API, and perhaps more importantly, it facilitates a smooth transition from the Google AI Studio environment to Vertex AI. 

Enhanced Functionality and Control

Beyond cross-compatibility, the GeminiApp library has also evolved to offer enhanced control over how you interact with Gemini models. This includes the following new features:

  • JSON-Controlled Generation: Generate content in JSON format by providing a schema or letting the model infer the schema from your prompt. This is useful for creating structured outputs that can be easily integrated into applications. 
  • Code Execution: You can now generate and execute code directly within your prompts using the gemini-2.0 models. This feature lets the model perform calculations and execute programmatic logic within the API call, opening up new possibilities for dynamic and interactive applications. 
  • System Instructions: You can now guide the model’s behavior and persona by providing system instructions during the initialization of the GenerativeModel. This gives you fine-grained control over the model’s responses and allows you to tailor the AI’s output to specific contexts and user needs. 
  • Caching: Improve efficiency and reduce token usage by caching file uploads. This enables repeated processing of the same document without incurring the full token cost each time.  Note: For now the cache integration is limited to Google AI Studio, but I’ll be keeping an eye on changes to the Vertex AI APIs to make it possible there as well.

Easier Copy/Paste Programming 

One of the other small enhancements in this update is making it easier to copy/paste code generated with  Google AI Studio. To make it easier to transition from Google AI Studio and other examples published for the Javascript client library, GeminiApp now supports initialization using both new GeminiApp() and new GoogleGenerativeAI(). This means you can use Google AI Studio to experiment with prompts and Gemini API advanced features then use the ‘Get code’ output in your Apps Script project. For example, if you explore the Google Gemini Generate AI JS sample, you’ll see most of them are used in the GeminiApp tests/tests.js.

Key Code Changes

The 2025.01 version bump isn't just about the new features outlined above and if you dig into the commit there are over 1.5K new lines of code mostly across three key files:

  • src/GeminiApp.js: This file contains the core logic of the GeminiApp library. The modifications here are extensive and include the implementation of the new features like code execution, JSON-controlled generation, system instructions, and caching. 
  • src/GoogleAICacheManager.js: This optional file manages the caching mechanism, including the creation, listing, getting, updating, and deleting of cached content. The caching functionality helps improve efficiency and reduce token usage.
  • tests/tests.js: This file contains the test suite for the GeminiApp library. The new test cases ensure the library functions correctly after the update, covering features like text generation, chat, code execution, JSON-controlled generation, multimodal interactions, and function calling.

Updating existing GeminiApp projects

If you have existing projects using the older version of the GeminiApp library you should be able to replace your existing GeminiApp.gs code with the updated library, with no additional changes, but if you have projects in production I would recommend testing before redeploying.

Getting Started

If you are new to the GeminiApp library it supports multiple setup options. To start using the new features, you can refer to the updated examples and test cases in the README.md file. 

Important Considerations

While these updates bring significant enhancements, there are a few points to keep in mind:

  • Model Selection: Always refer to the Google AI Studio and Vertex AI documentation for the latest information on model selection and API usage. Note that for certain features like code execution, you may need to specify the apiVersion as v1beta.
  • Prototyping vs. Production: Remember that Google AI Studio should be used for prototyping, while Vertex AI is suitable for both prototyping and production.
  • Caching: The caching mechanism requires including the GoogleAICacheManager.js file in your project..

A Step Forward for Google Workspace AI

The 2025.01 update to the GeminiApp library marks a significant step forward for developers looking to integrate the power of Gemini into their Google Workspace applications. With the ability to seamlessly transition from Google AI Studio to Vertex AI, along with new features like code execution, JSON-controlled generation, system instructions and enhanced multimodal input, the possibilities are endless. This release provides developers with the tools they need to create more powerful, efficient, and user-friendly AI solutions.

By using these new capabilities and the cross-compatibility between Google AI Studio and Vertex AI, you can create more robust and versatile applications. This update not only improves functionality but also gives developers a broader set of tools to create more personalized and efficient workflows. As the Gemini API evolves, libraries like GeminiApp will continue to bridge the gap between powerful AI models and Google Workspace users. The easy transition between environments means that your projects can grow with your needs, starting with simple prototypes and evolving into full-fledged production applications.

If you have interesting use cases for the GeminiApp, code improvements or feature requests, please feel free to get in touch!

To view or add a comment, sign in

More articles by Martin Hawksey

Others also viewed

Explore content categories