Sử dụng phương thức generateContent để gửi yêu cầu đến Gemini API.
const{GoogleGenerativeAI}=require("@google/generative-ai");constgenAI=newGoogleGenerativeAI("YOUR_API_KEY");constmodel=genAI.getGenerativeModel({model:"gemini-1.5-flash"});constprompt="Explain how AI works";constresult=awaitmodel.generateContent(prompt);console.log(result.response.text());
Bước tiếp theo
Giờ đây, khi đã tạo yêu cầu API đầu tiên, bạn nên khám phá các hướng dẫn sau đây để tìm hiểu cách Gemini hoạt động:
[[["Dễ hiểu","easyToUnderstand","thumb-up"],["Giúp tôi giải quyết được vấn đề","solvedMyProblem","thumb-up"],["Khác","otherUp","thumb-up"]],[["Thiếu thông tin tôi cần","missingTheInformationINeed","thumb-down"],["Quá phức tạp/quá nhiều bước","tooComplicatedTooManySteps","thumb-down"],["Đã lỗi thời","outOfDate","thumb-down"],["Vấn đề về bản dịch","translationIssue","thumb-down"],["Vấn đề về mẫu/mã","samplesCodeIssue","thumb-down"],["Khác","otherDown","thumb-down"]],["Cập nhật lần gần đây nhất: 2025-02-28 UTC."],[],[]]