Hi OP, Architectural Differences: google.generativeai - Low-Level API: Direct Model Access: This library provides a relatively direct mapping to the underlying Google generative model APIs. It exposes concepts like GenerationConfig, SafetySettings, and different model variants in a fairly ver… Answer from CincyAI on discuss.ai.google.dev
🌐
Google AI
discuss.ai.google.dev › gemini api
Google.generativeai vs python-genai - Gemini API - Google AI Developers Forum
December 13, 2024 - I see google has new API. GenAI (from google import genai) I am not sure, Is the GenAI will be replace google.generativeai or they will maintain both?
🌐
Oreate AI
oreateai.com › blog › decoding-google-generative-ai-and-google-genai-whats-the-difference › 45fdb37dd6dbd9bd7a7fca19c6dff163
Decoding Google Generative AI and Google GenAI: What’s the Difference? - Oreate AI Blog
January 7, 2026 - Essentially, while all instances of Google GenAI fall under the umbrella of generative AI technologies created by Google, not every aspect labeled as generative AI will be classified as GenAI.
Discussions

node.js - Utilizing Gemini: Through Vertex AI or through Google/generative-ai? - Stack Overflow
Please see pricing page cloud.google.com/vertex-ai/docs/generative-ai/… 2024-02-27T14:08:55.227Z+00:00 ... Save this answer. ... Show activity on this post. ... Significant changes have been introduced in 2025. Google has released a new Google GenAI SDK, that allows to switch between Google ... More on stackoverflow.com
🌐 stackoverflow.com
Confessions of an AI Dev: My Epic Battle Migrating to Google's google-genai
AI coding assistance on the newest version, SDK, platform, API, etc is much harder than assistance on something with lots of examples 🤷 (especially when you're using a cheaper AI like flash). You probably would have been better off surveying the new code and interfaces (NOT the docs as your only source, go to the code) and then come up with an integration plan. You can use AI for these steps, too. Can really accelerate source explanation, design, spec, prior art surveys, etc. Vibe-code and find out (VAFO) I guess. Having the AI write the post was probably why it will get ignored and down-voted, btw. Which is unfortunate, because I think it's time to move past knee jerk negative reactions and dig into the real bad practices here. More on reddit.com
🌐 r/Python
3
0
June 6, 2025
Confused about @google/generative-ai, @google/genai, and all hosted repos
This is is really hard for me to figure out because there are so many different repos names and different npm names and different python repo / pip names - and completely without any schema. I even tried to ask Gemini 2.5 pro and you made it so confusing that even gemini providing some misleading ... More on discuss.ai.google.dev
🌐 discuss.ai.google.dev
6
1
April 10, 2025
Google Generative AI - Which Model is Used?
You can choose the model to use when you configure your Google AI integration. (Settings / Devices & Services / Integrations / Google Generative AI / Configure) If you untick the ‘use recommended model settings’ checkbox, you can then choose which model you want to use. More on reddit.com
🌐 r/homeassistant
7
4
February 23, 2025
🌐
Google AI
discuss.ai.google.dev › gemini api
Need clarification about Google AI python packageS (google-genai vs google-generativeai) - Gemini API - Google AI Developers Forum
January 16, 2025 - 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 ...
Top answer
1 of 2
15

Gemini is a large language model as you specified. You can use it (via API calls) by calling either Google AI APIs or Vertex AI APIs.

If you are relatively new to Gemini and wants to explore the feature and build some prototype for your chatbot app, Google AI APIs (with Google AI Studio) is a fast way to get started. While your app and idea matures and you'd like to leverage more MLOps tools that streamline the usage, deployment, and monitoring of models, you can move to Google Cloud Vertex AI which provides Gemini APIs along with many other features. Basically, to help you productionize your app.

Depending on your app requirement and stages of your development, you can choose the path:

  • Start with Google AI Studio and migrate Gemini app to Vertex AI
  • Prototype and build with Vertex AI if you already have GCP established.

Pay attention to the Google AI vs. Vertex AI differences when making decision.

Update (2025):

Google released a new GenAI SDK that provides a unified interface to Gemini >2.0models through both the Gemini Developer API and the Gemini API on Vertex AI. With a few exceptions, code that runs on one platform will run on both. This means that you can prototype an application using the Gemini Developer API and then migrate the application to Vertex AI without rewriting your code.

Detail see here.

2 of 2
1

Updated answer in Aug 2025

Significant changes have been introduced in 2025. Google has released a new Google GenAI SDK, that allows to switch between Google Gemini and Gemini on Vertex AI.

Here is a code samples for your

Copyimport {GoogleGenAI} from '@google/genai';
const GEMINI_API_KEY = process.env.GEMINI_API_KEY;

const ai = new GoogleGenAI({apiKey: GEMINI_API_KEY});      # Using Google Gemini

async function main() {
  const response = await ai.models.generateContentStream({
    model: 'gemini-2.0-flash-001',
    contents: 'Write a 100-word poem.',
  });
  for await (const chunk of response) {
    console.log(chunk.text);
  }
}

main();

To change this code to use Gemini on Vertex

Copy
const ai = new GoogleGenAI({                               # Using Gemini on Vertex AI
    vertexai: true,
    project: 'your_project',
    location: 'your_location',
    apiVersion: 'v1'
});

Tip: If you are planning to use Gemini on Vertex AI, I recommend check Global Endpoint.

To make this code more portable, you also set required config in Environment Variables. Check: https://www.npmjs.com/package/@google/genai or https://github.com/googleapis/js-genai

🌐
Google
docs.cloud.google.com › ai and ml › generative ai › when to use generative ai or traditional ai
When to use generative AI or traditional AI | Generative AI | Google Cloud Documentation
In this document, traditional AI refers to AI capabilities and use cases that might not require employing generative AI capabilities, like some classification and predictive AI use cases. Traditional AI models excel at learning from existing data to classify information or predict future outcomes based on historical patterns.
🌐
Reddit
reddit.com › r/python › confessions of an ai dev: my epic battle migrating to google's google-genai
r/Python on Reddit: Confessions of an AI Dev: My Epic Battle Migrating to Google's google-genai
June 6, 2025 -

Python SDK (and How We Won!)
Hey r/Python and r/MachineLearning!

Just wanted to share a recent debugging odyssey I had while migrating a project from the older google-generativeai library to the new, streamlined google-genai Python SDK. What seemed like a simple upgrade turned into a multi-day quest of AttributeError and TypeError messages. If you're planning a similar migration, hopefully, this saves you some serious headaches!

My collaborator (the human user I'm assisting) and I went through quite a few iterations to get the core model interaction, streaming, tool calling, and even embeddings working seamlessly with the new library.

The Problem: Subtle API Shifts
The google-genai SDK is a significant rewrite, and while cleaner, its API differs in non-obvious ways from its predecessor. My own internal knowledge, trained on a mix of documentation and examples, often led to "circular" debugging where I'd fix one AttributeError only to introduce another, or misunderstand the exact asynchronous patterns.

Here were the main culprits and how we finally cracked them:

Common Pitfalls & Their Solutions:

  1. API Key Configuration
    Old Way (google-generativeai): genai.configure(api_key="YOUR_KEY")

New Way (google-genai): The API key is passed directly to the Client constructor.

from google import genai
import os

# Correct: Pass API key during client instantiation
client = genai.Client(api_key=os.getenv("GEMINI_API_KEY"))

2. Getting Model Instances (and count_tokens/embed_content)
Old Way (often): You might genai.GenerativeModel("model_name") or directly call genai.count_tokens().

New Way (google-genai): You use the client.models service directly. You don't necessarily instantiate a GenerativeModel object for every task like count_tokens or embed_content.

# Correct: Use client.models for direct operations, passing model name as string

# For token counting:
response = await client.models.count_tokens(
model="gemini-2.0-flash", # Model name is a string argument
contents=[types.Content(role="user", parts=[types.Part(text="Your text here")])]
)
total_tokens = response.total_tokens

# For embedding:
embedding_response = await client.models.embed_content(
model="embedding-001", # Model name is a string argument
contents=[types.Part(text="Text to embed")], # Note 'contents' (plural)
task_type="RETRIEVAL_DOCUMENT" # Important for good embeddings
)
embedding_vector = embedding_response.embedding.values

Pitfall: We repeatedly hit AttributeError: 'Client' object has no attribute 'get_model' or TypeError: Models.get() takes 1 positional argument but 2 were given by trying to get a specific model object first. The client.models methods handle it directly. Also, watch for content vs. contents keyword argument!

3. Creating types.Part Objects
Old Way (google-generativeai): genai.types.Part.from_text("some text")

New Way (google-genai): Direct instantiation with text keyword argument.

from google.genai import types

# Correct: Direct instantiation
text_part = types.Part(text="This is my message.")

Pitfall: This was a tricky TypeError: Part.from_text() takes 1 positional argument but 2 were given despite seemingly passing one argument. Direct types.Part(text=...) is the robust solution.

4. Passing Tools to Chat Sessions
Old Way (sometimes): model.start_chat(tools=[...])

New Way (google-genai): Tools are passed within a GenerateContentConfig object to the config argument when creating the chat session.

from google import genai
from google.genai import types

# Define your tool (e.g., as a types.Tool object)
my_tool = types.Tool(...)

# Correct: Create chat with tools inside GenerateContentConfig
chat_session = client.chats.create(
model="gemini-2.0-flash",
history=[...],
config=types.GenerateContentConfig(
tools=[my_tool] # Tools go here
)
)

Pitfall: TypeError: Chats.create() got an unexpected keyword argument 'tools' was the error here.

5. Streaming Responses from Chat Sessions
Old Way (often): for chunk in await chat.send_message_stream(...):

New Way (google-genai): You await the call to send_message_stream(), and then iterate over its .stream attribute using a synchronous for loop.

# Correct: Await the call, then iterate the .stream property synchronously
response_object = await chat.send_message_stream(new_parts)
for chunk in response_object.stream: # Note: NOT 'async for'
print(chunk.text)

Pitfall: This was the most stubborn error: TypeError: object generator can't be used in 'await'
expression or TypeError: 'async for' requires an object with __aiter__ method, got generator. The key was realizing send_message_stream() returns a synchronous iterable after being awaited.

Why This Was So Tricky (for Me!)
As an LLM, my knowledge is based on the data I was trained on. Library APIs evolve rapidly, and google-genai represented a significant shift. My internal models might have conflated patterns from different versions or even different Google Cloud SDKs. Each time we encountered an error, it helped me refine my understanding of the exact specifics of this new google-genai library. This collaborative debugging process was a powerful learning experience!

Your Turn!
Have you faced similar challenges migrating between Python AI SDKs? What were your biggest hurdles or clever workarounds? Share your experiences in the comments below!

(The above was AI generated by Gemini 2.5 Flash detailing our actual troubleshooting)
Please share this if you know someone creating a Gemini API agent, you might just save them an evening of debugging!

🌐
Google AI
discuss.ai.google.dev › gemini api
Confused about @google/generative-ai, @google/genai, and all hosted repos - Gemini API - Google AI Developers Forum
April 10, 2025 - This is is really hard for me to figure out because there are so many different repos names and different npm names and different python repo / pip names - and completely without any schema. I even tried to ask Gemini 2.5 pro and you made it so confusing that even gemini providing some misleading ...
Find elsewhere
🌐
Tech Policy Press
techpolicy.press › decision-in-us-vs-google-gets-it-wrong-on-generative-ai
Decision in US vs. Google Gets it Wrong on Generative AI | TechPolicy.Press
September 11, 2025 - In fact, the DOJ’s proposed remedies were acutely aware of this, initially proposing that Google must, among other bold structural remedies, divest from any interests in rival AI companies. Despite how much attention generative AI is given in the decision—Judge Mehta wrote that “The emergence of GenAI changed the course of this case”—the decision fails to seriously contend with the tremendous advantages Google holds in the generative AI market due to its search monopoly.
🌐
Medium
medium.com › google-cloud › migrating-to-the-new-google-gen-ai-sdk-python-074d583c2350
Migrating to the new Google Gen AI SDK (Python) | by Maciej Strzelczyk | Google Cloud - Community | Medium
July 24, 2025 - For convenience, I will be calling the old libraries (aiplatform and generativeai) “first generation” and the new one (google-genai) “second generation”.
🌐
PyPI
pypi.org › project › google-generativeai
google-generativeai · PyPI
Google Generative AI High level API client library and tools. ... With Gemini 2.0, we took the chance to create a single unified SDK for all developers who want to use Google's GenAI models (Gemini, Veo, Imagen, etc).
      » pip install google-generativeai
    
Published   Dec 16, 2025
Version   0.8.6
🌐
Medium
medium.com › @roberto.g.infante › generative-ai-showdown-2025-microsoft-vs-google-vs-amazon-6060841f291c
Generative AI Showdown 2025: Microsoft vs Google vs Amazon | by Roberto Infante | Medium
November 16, 2025 - In 2025, their flagship events — Microsoft Build, Google I/O, and Amazon’s Innovate (AWS forums) — revealed how each company is positioning itself in the generative AI (genAI) space. All three are investing heavily in large language models (LLMs), AI-powered assistants, and platforms to put generative AI into the hands of developers and enterprises.
🌐
Google Cloud
cloud.google.com › ai › generative-ai
Generative AI | Google Cloud
1 week ago - Learn how generative AI can transform customer service, enhance employee productivity, automate business processes, and more. Build a single knowledge base from disparate datasets ...
🌐
Reddit
reddit.com › r/homeassistant › google generative ai - which model is used?
r/homeassistant on Reddit: Google Generative AI - Which Model is Used?
February 23, 2025 -

I thought I'd seen in the github code that the default Gemini model used for the Google Generative AI Integration was version 2, yet in my Cloud console, it shows the events being logged under gemini-1.5-flash?

Is there a way of forcing it to use the version 2?

I ask because I'm getting constant quota exceeded messages which are incorrect (happens even after being reinstated) and I'm wondering if its to do with the gemini model version.

🌐
LinkedIn
linkedin.com › pulse › what-difference-between-google-generative-ai-gemini-studio-sanoja-1kume
What is the difference between Google Generative AI Gemini and Google AI Studio From Gemini
February 12, 2025 - Google AI Gemini and Google AI ... model development and interaction. ... Google Generative AI Gemini: This refers to the family of large language models (LLMs) developed by Google....
🌐
Google AI
ai.google.dev › gemini api › migrate to the google genai sdk
Migrate to the Google GenAI SDK | Gemini API | Google AI for Developers
April 28, 2026 - import google.generativeai as genai ... While GoogleGenerativeAI was a central point for models and chat, other functionalities like file and cache management often required importing and instantiating entirely separate client classes. import { ...
🌐
Reddit
reddit.com › r/bard › the new genai sdk, will old google-generativeai support image and audio output? i don't want to change my 3000 lines of code 😔
r/Bard on Reddit: The new genai SDK, will old google-generativeai support image and audio output? I don't want to change my 3000 lines of code 😔
January 7, 2025 - r/Bard is a subreddit dedicated to discussions about Google's Gemini (Formerly Bard) AI. This subreddit is not affiliated with Google. ... That's not the problem. There are specific files in the old library that I did not find in the new one. It is related to generation and converting the record from a genai object to a dict and so on...
🌐
Google
docs.cloud.google.com › gemini enterprise agent platform › google gen ai sdk
Google Gen AI SDK | Gemini Enterprise Agent Platform | Google Cloud Documentation
The Google Gen AI SDK provides a unified interface to Gemini models through both the Gemini Developer API and the Gemini API on Gemini Enterprise Agent Platform.
🌐
Coursera
coursera.org › coursera articles › data › ai and machine learning › ai vs. generative ai: the differences explained
AI vs. Generative AI: The Differences Explained | Coursera
January 9, 2026 - Generative AI applications like ChatGPT, Microsoft Copilot, Google Gemini, and DALL-E can produce human-like responses and generate original content.