Gemini API

建議您為所有新專案使用 Interactions API。這項服務已針對代理工作流程、狀態管理和最新模型進行最佳化調整。詳情請參閱「Interactions API 總覽」。

透過 Gemini、Veo、Nano Banana 等工具,快速將提示轉換為可供製作的內容。

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.5-flash",
    input="Explain how AI works in a few words"
)

print(interaction.output_text)

JavaScript

import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({});

const interaction = await ai.interactions.create({
  model: "gemini-3.5-flash",
  input: "Explain how AI works in a few words",
});

console.log(interaction.output_text);

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3.5-flash",
    "input": "Explain how AI works in a few words"
  }'
開始建構

按照快速入門指南操作,幾分鐘內即可取得 API 金鑰並發出第一個 API 呼叫。


認識各款機型

查看全部

探索各種功能