Sử dụng phương thức generateContent để gửi yêu cầu đến Gemini API.
import{GoogleGenAI}from"@google/genai";constai=newGoogleGenAI({apiKey:"YOUR_API_KEY"});asyncfunctionmain(){constresponse=awaitai.models.generateContent({model:"gemini-2.0-flash",contents:"Explain how AI works in a few words",});console.log(response.text);}awaitmain();
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 về 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-03-25 UTC."],[],[]]