Gemini Developer API

รับคีย์ Gemini API และส่งคําขอ API รายการแรกได้ในไม่กี่นาที

PythonJavaScriptGoREST
from google import genai

client = genai.Client(api_key="YOUR_API_KEY")

response = client.models.generate_content(
    model="gemini-2.0-flash",
    contents="Explain how AI works in a few words",
)

print(response.text)
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: "YOUR_API_KEY" });

async function main() {
  const response = await ai.models.generateContent({
    model: "gemini-2.0-flash",
    contents: "Explain how AI works in a few words",
  });
  console.log(response.text);
}

await main();
package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, &genai.ClientConfig{
        APIKey:  "YOUR_API_KEY",
        Backend: genai.BackendGeminiAPI,
    })
    if err != nil {
        log.Fatal(err)
    }

    result, err := client.Models.GenerateContent(
        ctx,
        "gemini-2.0-flash",
        genai.Text("Explain how AI works in a few words"),
        nil,
    )
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(result.Text())
}
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent?key=YOUR_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Explain how AI works in a few words"
          }
        ]
      }
    ]
  }'

พบกับโมเดล

ใช้ Gemini ใน Google AI Studio

สำรวจ API

การสร้างรูปภาพเนทีฟ

สร้างและแก้ไขรูปภาพที่อิงตามบริบทสูงได้โดยตรงด้วย Gemini 2.0 Flash

สำรวจบริบทแบบยาว

ป้อนโทเค็นหลายล้านรายการลงในโมเดล Gemini และดึงข้อมูลเชิงลึกจากรูปภาพ วิดีโอ และเอกสารที่ไม่มีโครงสร้าง

สร้างเอาต์พุตที่มีโครงสร้าง

จำกัดให้ Gemini ตอบกลับด้วย JSON ซึ่งเป็นรูปแบบ Structured Data ที่เหมาะสำหรับการประมวลผลอัตโนมัติ

เริ่มสร้างด้วย Gemini API

เริ่มต้นใช้งาน