Gemini 3 シリーズと 2.5 シリーズのモデルは 「思考プロセス」を使用しており、推論能力とマルチステップ プランニング能力が大幅に向上しているため、コーディング、高度な数学、データ分析などの複雑なタスクに非常に効果的です。
思考モデルを使用する場合、Gemini はレスポンスを返す前に内部で推論を行います。Interactions API は、この推論を thought ステップとして公開します。これは、steps 配列内の関数呼び出し、ユーザー入力、モデル出力とともに時系列で表示される専用のステップです。
すべての思考ステップには、次の 2 つのフィールドが含まれています。
| フィールド | 必須 | 説明 |
|---|---|---|
signature |
✅ はい | モデルの内部推論状態を暗号化したもの。モデルが最小限の推論を行う場合でも常に存在します。 |
summary |
❌ いいえ | 推論を要約するコンテンツ(テキストや画像)の配列。thinking_summaries 構成、モデルが十分な推論を行ったかどうか、コンテンツ タイプ(画像レイテンシにテキストの要約がない場合など)によって空になることがあります。 |
思考とのインタラクション
思考モデルとのインタラクションを開始する手順は、他のインタラクション リクエストと同様です。model フィールドで、思考をサポートするモデルのいずれかを指定します。
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.6-flash",
input="Explain the concept of Occam's Razor and provide a simple, everyday example."
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: "gemini-3.6-flash",
input: "Explain the concept of Occam's Razor and provide a simple, everyday example."
});
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.6-flash",
"input": "Explain the concept of Occam'\''s Razor and provide a simple example."
}'
思考の要約
思考の要約は、モデルの内部推論プロセスに関する分析情報を提供します。
デフォルトでは、最終出力のみが返されます。thinking_summaries を使用して思考の要約を有効にできます。
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.6-flash",
input="What is the sum of the first 50 prime numbers?",
generation_config={
"thinking_summaries": "auto"
}
)
for step in interaction.steps:
if step.type == "thought":
print("Thought summary:")
if step.summary:
for content_block in step.summary:
if content_block.type == "text":
print(content_block.text)
print()
elif step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print("Answer:")
print(content_block.text)
print()
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: "gemini-3.6-flash",
input: "What is the sum of the first 50 prime numbers?",
generation_config: {
thinking_summaries: "auto"
}
});
for (const step of interaction.steps) {
if (step.type === "thought") {
console.log("Thought summary:");
if (step.summary) {
for (const contentBlock of step.summary) {
if (contentBlock