1. Google AI Studio คืออะไร?
Google AI Studio คือเครื่องมือสำหรับทดลองและพัฒนาโมเดล Generative AI เช่น Gemini API และระบบ AI ของ Google
2. การเริ่มต้นใช้งาน
ขั้นตอนเบื้องต้น:
- เข้าสู่ระบบ Google Account
- เข้าเว็บไซต์ Google AI Studio
- สร้าง API Key
- ทดลองเขียน Prompt
3. ตัวอย่างการเรียก API
fetch("https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-goog-api-key": "YOUR_API_KEY"
},
body: JSON.stringify({
contents:[{parts:[{text:"อธิบาย AI คืออะไร"}]}]
})
});
method: "POST",
headers: {
"Content-Type": "application/json",
"x-goog-api-key": "YOUR_API_KEY"
},
body: JSON.stringify({
contents:[{parts:[{text:"อธิบาย AI คืออะไร"}]}]
})
});
4. การใช้งานในเว็บไซต์
สามารถนำ API ไปเชื่อมกับระบบ Chatbot, ระบบวิเคราะห์ข้อมูล หรือสร้างระบบตอบคำถามอัตโนมัติ
5. แนวทางการใช้งานอย่างปลอดภัย
- เก็บ API Key อย่างปลอดภัย
- จำกัดการใช้งาน API
- ตรวจสอบ Input ก่อนส่งให้ AI