Need clarification about Google AI python packageS (google-genai vs google-generativeai)

Hi there!

I would like to use Gemini 2.0 in my application, in particular I would like to swap it with my current OpenAI Python client (which involves async multiple-function calling).

The problem I encounter is the existence of two different Python packages offered by Google.

First, there is the generative-ai-python (github: /google-gemini/generative-ai-python), installed as pip install -U google-generativeai and imported as import google.generativeai as genai. The README points to these URLs: https://ai.google.dev/ & github: /google-gemini/gemini-api-cookbook/.

Then, there is the python-genai repo (github: /googleapis/python-genai). It is installed using pip install google-genai and imported as from google import genai

The README of the Cookbook (another repo!) states that " [Google GenAI SDKs](github: /googleapis/python-genai) will eventually replace the older [Developer SDK](github: /google/generative-ai-python)". When will that happen?

As a developer, I don’t want to waste time building onto a lib that’s going to be deprecated soon. In the other hand, most of the documentation is about the “Developer SDK” and not “Google GenAI SDK”. Although I want to use your models (which I know perform well) this situation is quite a pain.

PS: Is the project of a compatibility with OpenAI’s python client still on tracks? This page has not been updated since 2024-11-26, and for instance, my function calling schema (which works with the OpenAI endpoint) does not work with Gemini’s one.

3 Likes

Hi,

the newer python-genai package is the recommended one for new(er) projects. It’s the successor package the two previous SDKs (yes, there’s one for Google AI and another for Vertex AI).

See here for nice summary: Google.generativeai vs python-genai - #3 by CincyAI

Hope this helps.

1 Like

Hello,

The import statement the goes import google.generativeai as genai is the old version of importing Gemini API library where as the other import statement from google import genai is the newer version of importing the library. I would suggest to use the newer version of importing the library because of higher level of facade and abstraction. For more detailed summary visit Google.generativeai vs python-genai

Hope this helps

1 Like