·Y Build Team
Gemini 3.1 Pro API: คู่มือนักพัฒนาพร้อมตัวอย่างโค้ด (2026)
คู่มือนักพัฒนาฉบับสมบูรณ์สำหรับ Gemini 3.1 Pro API ครอบคลุม Model ID (gemini-3.1-pro-preview-customtools) ราคา ตัวอย่างโค้ด Python และ JavaScript เครื่องมือที่กำหนดเอง การเรียกฟังก์ชัน และการผสานรวมกับแอปของคุณ
GeminiGoogleAPIDeveloper GuidePythonJavaScriptAIFunction Calling2026
Y
G3สรุป
| Gemini 3.1 Pro | |
|---|---|
| Model ID | gemini-3.1-pro, gemini-3.1-pro-preview-customtools |
| หน้าต่างบริบท | 1M โทเค็น |
| ราคาอินพุต | $2/1M โทเค็น |
| ราคาเอาต์พุต | $12/1M โทเค็น |
| ฟีเจอร์หลัก | เครื่องมือที่กำหนดเอง, การเรียกฟังก์ชัน, grounding, มัลติโมดอล |
| API | Google AI Studio / Vertex AI |
Gemini 3.1 Pro เป็นโมเดล frontier ล่าสุดของ Google เปิดตัวมีนาคม 2026 API frontier ที่ถูกที่สุดต่อโทเค็น มีบริบทเนทีฟ 1M และแนะนำ เครื่องมือที่กำหนดเอง
เริ่มต้นเร็ว: Python
bash
pip install google-genai
python
from google import genai
client = genai.Client(api_key="YOUR_API_KEY")
response = client.models.generate_content(
model="gemini-3.1-pro",
contents="Explain quantum computing in 3 sentences."
)
print(response.text)
Early Access
Be first to build with AI
Y Build is the AI-era operating system for startups. Join the waitlist and get early access.
เริ่มต้นเร็ว: JavaScript
bash
npm install @google/genai
javascript
import { GoogleGenAI } from "@google/genai";
const ai = new GoogleGenAI({ apiKey: "YOUR_API_KEY" });
const response = await ai.models.generateContent({
model: "gemini-3.1-pro",
contents: "Explain quantum computing in 3 sentences.",
});
console.log(response.text);
ราคา
| Gemini 3.1 Pro | GPT-5.2 | Claude Sonnet 4.6 | |
|---|---|---|---|
| อินพุต | $2/1M | $5/1M | $3/1M |
| เอาต์พุต | $12/1M | $15/1M | $15/1M |
| บริบท | 1M | 400K | 1M (beta) |
แพลนฟรี: 60 คำขอ/นาที, 1M โทเค็น/นาที, ไม่ต้องใช้บัตรเครดิต
เปรียบเทียบ API
| ฟีเจอร์ | Gemini 3.1 Pro | GPT-5.2 | Claude Sonnet 4.6 |
|---|---|---|---|
| มัลติโมดอล | ข้อความ + ภาพ + เสียง + วิดีโอ | ข้อความ + ภาพ + เสียง | ข้อความ + ภาพ |
| โค้ดดิ้ง (SWE-bench) | 76.8% | 80.0% | 79.6% |
| คณิตศาสตร์ (AIME) | ~88% | 100% | ~90% |
บทสรุป
Gemini 3.1 Pro คือ API frontier ที่คุ้มค่าที่สุด ในมีนาคม 2026 ที่ $2/$12 ต่อล้านโทเค็น ถูกกว่า GPT-5.2 ประมาณครึ่งหนึ่ง
สร้างผลิตภัณฑ์ด้วย AI? Y Build — AI โค้ดดิ้ง, เดพลอยคลิกเดียว, Demo Cut, AI SEO และแอนาลิติกส์ เริ่มต้นฟรี.
แหล่งที่มา:
Early Access
Be first to build with AI
Y Build is the AI-era operating system for startups. Join the waitlist and get early access.