@google/generative-ai 코드 있으면 port
Legacy @google/generative-ai 가 2025 년 8 월 EOL. 마이그레이션은 mechanical 이고 새 패키지가 같은 문제를 더 깔끔한 모양으로 해결.
여섯 가지가 변함
| Aspect | Legacy | New |
|---|---|---|
| 클래스 | GoogleGenerativeAI | GoogleGenAI |
| Import | @google/generative-ai | @google/genai |
| Model | genAI.getGenerativeModel({model}) | (없음 — 호출당 model pass) |
| 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 | 별도 FileManager | ai.files.upload(...) |
| Vertex | 별도 @google-cloud/vertexai | GoogleGenAI({vertexai: true}) |
.text() vs .text 버그
port 할 때 가장 큰 함정 한 개: legacy 는 result.response.text() (method 호출) 사용. New SDK 는 response.text (property 접근). 괄호 빼는 거 잊으면 TypeError: response.text is not a function. port 할 때 코드베이스에서 .text() grep 하고 한 번에 다 고쳐.