If you have @google/generative-ai code, port it
The legacy @google/generative-ai reached EOL in August 2025. The migration is mechanical and the new package fits the same problem with cleaner shape.
Six things change
| Aspect | Legacy | New |
|---|---|---|
| Class | GoogleGenerativeAI | GoogleGenAI |
| Import | @google/generative-ai | @google/genai |
| Model | genAI.getGenerativeModel({model}) | (none — pass model per call) |
| Generate | model.generateContent(text) | ai.models.generateContent({model, contents}) |
| Response text | result.response.text() (method) | response.text (property) |
| Chat | model.startChat() | ai.chats.create({model}) |
| Files | Separate FileManager | ai.files.upload(...) |
| Vertex | Separate @google-cloud/vertexai | GoogleGenAI({vertexai: true}) |
The .text() vs .text bug
The single biggest porting gotcha: legacy used result.response.text() (method call). The new SDK uses response.text (property access). Forgetting to drop the parentheses gives you TypeError: response.text is not a function. Grep your codebase for .text() when porting and fix all of them at once.