Gemini API

借助 Gemini API,您可以快速将提示词转化为生产部署,并使用 Gemini、Veo、Nano Banana 等功能。借助该 SDK,您可以将这些生成式模型集成到应用中,以生成文本和图片、分析多模态输入内容,以及构建对话式代理。

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    model="gemini-3.7-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.7-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.7-flash",
    "input": "Explain how AI works in a few words"
  }'
开始构建

按照我们的入门指南操作,您只需几分钟即可获取 API 密钥并发出第一个 API 调用。


认识这些模型

查看全部

探索功能

Interactions API

自 2026 年 6 月起,Interactions API 已成为我们的默认接口,也是未来使用 Gemini 模型和智能体进行构建的最佳方式。如果您要开始一个新项目,则应使用 Interactions API。虽然 generateContent API 仍受支持,但现在被视为旧版 API。