Gemini Developer API

取得 Gemini API 金鑰,幾分鐘內就能發出第一個 API 要求。

PythonNode.jsREST
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",
)

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",
  });
  console.log(response.text);
}

await main();
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"
          }
        ]
      }
    ]
  }'

探索 API

原生圖片產生

使用 Gemini 2.0 Flash 原生生成及編輯高度符合情境的圖片。

探索長脈絡

將數百萬個符號輸入 Gemini 模型,從非結構化圖片、影片和文件中擷取理解資訊。

產生結構化輸出內容

限制 Gemini 以 JSON 回應,這是適合自動處理的結構化資料格式。

開始使用 Gemini API 建構

踏出第一步