Gemini API

我们建议在所有新项目中使用 Interactions API。它针对智能体工作流、状态管理和最新模型进行了优化。如需了解详情,请参阅互动 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 调用。


认识这些模型

查看全部

探索功能