Co-author: Rachel Saunders
Reviewers: Moi Borah, Joe Holliday, Soo Sung
Over the last few years, Google has launched a number of open source libraries and tools for integrating Gemini into applications and workflows. This post introduces some of these tools and the use cases they support, to help you decide if there’s a Gemini tool that can help you with your next project.
Gemini API libraries (aka the Google GenAI SDK)
For many use cases, the fastest way to integrate Gemini into your app is to use the Gemini API. You can access the Gemini API using the Google GenAI SDK, which provides official, production-ready libraries for popular programming languages like Python, JavaScript, Go, and Java.
Let’s see how you could use the Python library to process multimodal input. Say you have an image of a pipe organ, and you want to learn more about it.

You could do something like this:
from PIL import Image
from google import genai
client = genai.Client()
image = Image.open("/path/to/organ.png")
response = client.models.generate_content(
model="gemini-3-flash-preview",
contents=[image, "Tell me about this instrument"]
)
print(response.text)
The second line, `from google import genai`, imports the Google GenAI Python SDK, which provides an interface to Gemini and other Google models.
You use `genai` to initialize a client and then use `models.generate_content` to make a request to the Gemini API. You specify the model (`“gemini-3-flash-preview”`) in the request and then pass along the image and text inputs. The output should tell you all about pipe organs.
The `generate_content` method also takes a `config` parameter, which you can use to configure the model. This next example shows how to configure a system instruction (“You are a cat. Your name is Neko.”) to help guide the behavior of the model:
from google import genai
from google.genai import types
client = genai.Client()
response = client.models.generate_content(
model="gemini-3-flash-preview",
config=types.GenerateContentConfig(
system_instruction="You are a cat. Your name is Neko."),
contents="Hello there"
)
print(response.text)
Because of the system instruction, the model should respond with something like “Purrrrrr… hello! I’m Neko. Do you have any treats, or maybe a nice sunny spot for me to nap in?” Note that this example also imports the `google.genai.types` module. The Python API methods support Pydantic types and dictionaries, which you can access from `google.genai.types`. In this case, the example uses the `GenerateContentConfig` class to help configure the optional system instruction.
The Gemini API libraries provide many other features and capabilities, including image generation, video generation, code execution, and thinking. For many use cases, it provides the fastest path to building, productionizing, and scaling Gemini-powered applications.
In some cases, you might need specific enterprise features that aren’t available through the Gemini Developer API. For such cases, you can use the Vertex AI Gemini API, which is also accessible through the Google GenAI SDK. The code for using the two APIs is very similar. Here’s an example of making a request to the Gemini Developer API:
from google import genai
client = genai.Client()
response = client.models.generate_content(
model="gemini-2.5-flash", contents="Explain how AI works in a few words"
)
print(response.text)
And here’s the example rewritten for the Vertex AI Gemini API:
from google import genai
client = genai.Client(
vertexai=True, project='your-project-id', location='us-central1'
)
response = client.models.generate_content(
model="gemini-2.5-flash", contents="Explain how AI works in a few words"
)
print(response.text)
By passing the appropriate parameters to the client, you can integrate with Vertex AI, which offers a comprehensive ecosystem of enterprise ready features and services for building and deploying generative AI applications backed by the Google Cloud Platform.
Agent Development Kit (ADK)
If you’re interested in developing Gemini-powered AI agents, you should consider using Agent Development Kit (ADK). ADK is a framework for developing and deploying AI agents, and although it’s model-agnostic, it’s optimized for Gemini and the Google ecosystem. ADK provides libraries in Python, JavaScript, Go, and Java.
The Python library provides an `adk` CLI that you can use to generate and run an agent. Here’s a generated agent that’s configured to use Gemini 2.5 Flash:
from google.adk.agents.llm_agent import Agent
root_agent = Agent(
model='gemini-2.5-flash',
name='root_agent',
description='A helpful assistant for user questions.',
instruction='Answer user questions to the best of your knowledge',
)
The `adk` tool creates a directory structure that includes a `.env` file with your API key and other information. You can then use `adk` to start an interactive session in the terminal:
...
Running agent root_agent, type exit to exit.
[user]: Tell me about yourself.
[root_agent]: I am a large language model, trained by Google.
My internal name is "root_agent" and I am designed to be a helpful assistant
for user questions. I can provide information, generate text, answer questions,
and assist with a wide range of topics.
This is a promising start, but for many use cases you’ll probably want the agent to use tools to retrieve information and interact with external APIs. ADK makes it easy to configure such tools. Let’s look at an example taken from one of the ADK quickstarts:
root_agent = Agent(
name="weather_time_agent",
model="gemini-2.0-flash",
description=(
"Agent to answer questions about the time and weather in a city."
),
instruction=(
"You are a helpful agent who can answer user questions about the time and weather in a city."
),
tools=[get_weather, get_current_time],
)
The `weather_time_agent` has access to two tools: `get_weather` and `get_current_time`, which are configured in the `tools` list. The tools in the example don’t actually do much. Here’s the get_weather` function:
def get_weather(city: str) -> dict:
"""Retrieves the current weather report for a specified city.
Args:
city (str): The name of the city for which to retrieve the weather report.
Returns:
dict: status and result or error msg.
"""
if city.lower() == "new york":
return {
"status": "success",
"report": (
"The weather in New York is sunny with a temperature of 25 degrees"
" Celsius (77 degrees Fahrenheit)."
),
}
else:
return {
"status": "error",
"error_message": f"Weather information for '{city}' is not available.",
}
If you ask the agent about the weather in New York, you get a hardcoded response. Otherwise, you get an error message. But you could create a `get_weather` function that uses an external API to retrieve actual weather data for New York and other cities.
These minimal examples don’t look much different from chatbots, but ADK can help you create powerful workflows using a few primitives, including
- Specialized workflow agents that orchestrate the execution flow of sub-agents
- Callbacks that let you observe and customize the agent’s behavior at predefined points
- Session management services for handling conversation context and history
- Events, which represent user inputs, agent responses, tool use, and other occurrences during the interaction lifecycle.
To learn more about the basic ADK building blocks, see the technical overview.
To get a sense of what you can build with ADK, it’s worth looking at the ADK samples repo. The sample agents work across various domains, including research, search optimization, customer service, data engineering, marketing strategy, and finance. When you’re ready to start building, ADK can help you implement various agentic patterns, including a multi-tool agent, an agent team, and a streaming agent. Then, when you’re ready to deploy your agent, you can use one of the supported deployment options, which include Vertex AI Agent Engine, Cloud Run, and Google Kubernetes Engine (GKE).
Gemini CLI
The Google GenAI SDK and ADK both help you integrate Gemini into your apps and services. The Gemini CLI is a little bit different: It helps you integrate Gemini into your developer workflow, regardless of what you’re building.
Gemini CLI is an open source AI agent that brings Gemini into your terminal. You can use Gemini CLI to edit files, run shell commands, search the web, explain code, and generally assist you with a variety of development tasks within the context of your local project.
Let’s say you’re working on the weather_time_agent from the ADK example. After installing the Gemini CLI, you can open it in your project directory by running the `gemini` command. Then you can interact with your project files. You could start by asking Gemini to explain the weather_time_agent code, which — following the ADK tutorial — is located in `multi_tool_agent/agent.py`.
> What does @multi_tool_agent/agent.py do?
...
The multi_tool_agent/agent.py file defines a weather_time_agent powered by the
gemini-2.0-flash model. This agent is designed to answer questions about the
time and weather in a city. It utilizes two functions as tools: get_weather
to retrieve weather reports and get_current_time to provide the current time,
both currently limited to "New York".
Pretty cool. Now let’s try something more interesting:
Update the get_weather function to return a response for "Seattle" like it does
for "New York".
The model proposes adding the following condition:
elif city.lower() == "seattle":
return {
"status": "success",
"report": (
"The weather in Seattle is cloudy with a temperature of 10 degrees"
" Celsius (50 degrees Fahrenheit)."
),
}
After accepting the changes, you can ask the agent about the weather in Seattle. Of course, you wouldn’t implement a real `get_weather` function with hardcoded cities and weather reports, but the point in this case is that Gemini can update the function in a way that makes sense in this particular context.
Now that the function is updated, you might want to test it:
Create a unit test for the get_weather function in @multi_tool_agent/agent.py
After getting your permission to make the required changes, Gemini creates `test_agent.py` and adds the following code:
import unittest
from .agent import get_weather
class TestGetWeather(unittest.TestCase):
def test_get_weather_new_york(self):
result = get_weather("new york")
self.assertEqual(result["status"], "success")
self.assertIn("New York", result["report"])
def test_get_weather_seattle(self):
result = get_weather("seattle")
self.assertEqual(result["status"], "success")
self.assertIn("Seattle", result["report"])
def test_get_weather_unknown_city(self):
result = get_weather("paris")
self.assertEqual(result["status"], "error")
self.assertIn("not available", result["error_message"])
if __name__ == '__main__':
unittest.main()
Then it runs the tests, which pass.
It’s easy to see how Gemini CLI could cut significant time and toil from your development workflow, and there’s a lot more that you can do with it. For ideas, see the Gemini CLI overview and examples.
Other Gemini libraries and tools
We won’t look at every Gemini tool in this post, but there are definitely others that are worth checking out.
Google AI Studio is a great place to start if you’re still exploring options for programming with Gemini. Unlike the libraries and tools we’ve seen so far, AI Studio is not open source. But you can use it to generate code that interacts with the Gemini API. To learn more, see the Google AI Studio quickstart.
Genkit is an open-source framework for building full-stack AI-powered applications. It offers a unified interface for integrating various AI models, including Gemini. To learn more, see Get started with Genkit.
Firebase AI Logic enables you to build secure, production-grade AI features directly in your mobile and web apps using languages and frameworks you’re already familiar with — like iOS (Swift), Android (Kotlin), Web (JavaScript), Flutter (Dart), and even Unity. To learn more, see Get started with the Gemini API using the Firebase AI Logic SDKs.
We’re excited to see what you build using the latest libraries and tools for Google Gemini!
A tour of Google Gemini libraries and tools was originally published in Google Cloud – Community on Medium, where people are continuing the conversation by highlighting and responding to this story.
Source Credit: https://medium.com/google-cloud/a-tour-of-google-gemini-libraries-and-tools-38a6c31d7467?source=rss—-e52cf94d98af—4
