Gemini 3 デベロッパー ガイド

Gemini 3 は、最先端の推論を基盤として構築された、Google 史上最もインテリジェントなモデル ファミリーです。エージェント ワークフロー、自律型コーディング、複雑なマルチモーダル タスクをマスターして、あらゆるアイデアを実現できるように設計されています。このガイドでは、Gemini 3 モデル ファミリーの主な機能と、その機能を最大限に活用する方法について説明します。

Gemini 3 アプリのコレクションで、高度な推論、自律的なコーディング、複雑なマルチモーダル タスクをモデルがどのように処理するかをご確認ください。

数行のコードで開始できます。

Python

from google import genai

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3-pro-preview",
    contents="Find the race condition in this multi-threaded C++ snippet: [code here]",
)

print(response.text)

JavaScript

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

const ai = new GoogleGenAI({});

async function run() {
  const response = await ai.models.generateContent({
    model: "gemini-3-pro-preview",
    contents: "Find the race condition in this multi-threaded C++ snippet: [code here]",
  });

  console.log(response.text);
}

run();

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [{"text": "Find the race condition in this multi-threaded C++ snippet: [code here]"}]
    }]
  }'

Gemini 3 シリーズのご紹介

新しいシリーズの最初のモデルである Gemini 3 Pro は、幅広い世界中の知識と高度な推論を必要とする複雑なタスクに最適です。

Gemini 3 Flash は、最新の 3 シリーズ モデルです。Flash のスピードと料金で Pro レベルのインテリジェンスを実現します。

Nano Banana Pro(別名 Gemini 3 Pro Image)は、Google が提供する最高品質の画像生成モデルです。

Gemini 3 モデルはすべて現在プレビュー版です。

モデル ID コンテキスト ウィンドウ(入力 / 出力) ナレッジ カットオフ 料金(入力 / 出力)*
gemini-3-pro-preview 1M / 64k 2025 年 1 月 $2 / $12(<200k トークン)
$4 / $18(>200k トークン)
gemini-3-flash-preview 1M / 64k 2025 年 1 月 $0.50 / $3
gemini-3-pro-image-preview 65k / 32k 2025 年 1 月 $2(テキスト入力) / $0.134(画像出力)**

* 特に記載のない限り、料金は 100 万トークンあたりです。** 画像の価格は解像度によって異なります。詳細については、料金のページをご覧ください。

上限、料金、その他の詳細については、モデルのページをご覧ください。

Gemini 3 の新しい API 機能

Gemini 3 では、デベロッパーがレイテンシ、費用、マルチモーダルの忠実度をより詳細に制御できるように設計された新しいパラメータが導入されています。

思考レベル

Gemini 3 シリーズのモデルは、デフォルトで動的思考を使用してプロンプトを推論します。thinking_level パラメータを使用できます。このパラメータは、モデルがレスポンスを生成する前に実行する内部推論プロセスの最大の深さを制御します。Gemini 3 は、これらのレベルを厳密なトークン保証ではなく、思考のための相対的な許容値として扱います。

thinking_level が指定されていない場合、Gemini 3 はデフォルトで high になります。複雑な推論が必要ない場合に、より高速で低レイテンシのレスポンスを得るには、モデルの思考レベルを low に制約します。

Gemini 3 Pro と Flash の思考レベル:

Gemini 3 Pro と Flash の両方でサポートされている思考レベルは次のとおりです。

  • low: レイテンシと費用を最小限に抑えます。シンプルな指示の実行、チャット、高スループット アプリケーションに最適
  • high(デフォルト、動的): 推論の深さを最大化します。最初のトークンに到達するまでに時間がかかることがありますが、出力はより慎重に推論されます。

Gemini 3 Flash の思考レベル

上記のレベルに加えて、Gemini 3 Flash は、Gemini 3 Pro では現在サポートされていない次の思考レベルもサポートしています。

  • minimal: ほとんどのクエリで「思考なし」の設定と一致します。複雑なコーディング タスクでは、モデルの思考が最小限になることがあります。チャット アプリケーションや高スループット アプリケーションのレイテンシを最小限に抑えます。

  • medium: ほとんどのタスクでバランスの取れた思考。

Python

from google import genai
from google.genai import types

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3-pro-preview",
    contents="How does AI work?",
    config=types.GenerateContentConfig(
        thinking_config=types.ThinkingConfig(thinking_level="low")
    ),
)

print(response.text)

JavaScript

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

const ai = new GoogleGenAI({});

const response = await ai.models.generateContent({
    model: "gemini-3-pro-preview",
    contents: "How does AI work?",
    config: {
      thinkingConfig: {
        thinkingLevel: "low",
      }
    },
  });

console.log(response.text);

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [{"text": "How does AI work?"}]
    }],
    "generationConfig": {
      "thinkingConfig": {
        "thinkingLevel": "low"
      }
    }
  }'

メディアの解像度

Gemini 3 では、media_resolution パラメータを使用して、マルチモーダル ビジョン処理をきめ細かく制御できます。解像度が高いほど、モデルが細かいテキストを読み取ったり、小さな詳細を識別する能力が向上しますが、トークンの使用量とレイテンシが増加します。media_resolution パラメータは、入力画像または動画フレームごとに割り当てられるトークンの最大数を決定します。

解像度は、個々のメディアパートごとに media_resolution_lowmedia_resolution_mediummedia_resolution_highmedia_resolution_ultra_high のいずれかに設定できます。また、グローバルに設定することもできます(generation_config を使用。ウルトラハイはグローバルに設定できません)。指定しない場合、モデルはメディアタイプに基づいて最適なデフォルトを使用します。

推奨設定

メディアタイプ 推奨される設定 最大トークン数 使用ガイダンス
画像 media_resolution_high 1120 品質を最大限に高めるため、ほとんどの画像分析タスクにおすすめします。
PDF media_resolution_medium 560 ドキュメントの理解に最適です。通常、品質は medium で飽和します。high に増やしても、標準的なドキュメントの OCR 結果が改善されることはほとんどありません。
動画(一般) media_resolution_low(または media_resolution_medium 70(フレームあたり) 注: 動画の場合、コンテキストの使用を最適化するために、lowmedium の設定は同じ(70 個のトークン)として扱われます。ほとんどのアクション認識と説明のタスクでは、この対応で十分です。
動画(テキストが多い) media_resolution_high 280(フレームあたり) ユースケースで密度の高いテキスト(OCR)や動画フレーム内の細部を読み取る場合にのみ必要です。

Python

from google import genai
from google.genai import types
import base64

# The media_resolution parameter is currently only available in the v1alpha API version.
client = genai.Client(http_options={'api_version': 'v1alpha'})

response = client.models.generate_content(
    model="gemini-3-pro-preview",
    contents=[
        types.Content(
            parts=[
                types.Part(text="What is in this image?"),
                types.Part(
                    inline_data=types.Blob(
                        mime_type="image/jpeg",
                        data=base64.b64decode("..."),
                    ),
                    media_resolution={"level": "media_resolution_high"}
                )
            ]
        )
    ]
)

print(response.text)

JavaScript

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

// The media_resolution parameter is currently only available in the v1alpha API version.
const ai = new GoogleGenAI({ apiVersion: "v1alpha" });

async function run() {
  const response = await ai.models.generateContent({
    model: "gemini-3-pro-preview",
    contents: [
      {
        parts: [
          { text: "What is in this image?" },
          {
            inlineData: {
              mimeType: "image/jpeg",
              data: "...",
            },
            mediaResolution: {
              level: "media_resolution_high"
            }
          }
        ]
      }
    ]
  });

  console.log(response.text);
}

run();

REST

curl "https://generativelanguage.googleapis.com/v1alpha/models/gemini-3-pro-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [
        { "text": "What is in this image?" },
        {
          "inlineData": {
            "mimeType": "image/jpeg",
            "data": "..."
          },
          "mediaResolution": {
            "level": "media_resolution_high"
          }
        }
      ]
    }]
  }'

温度

Gemini 3 では、温度パラメータをデフォルト値の 1.0 に維持することを強くおすすめします。

以前のモデルでは、多くの場合、温度をチューニングして創造性と決定論を制御することでメリットが得られました。しかし、Gemini 3 の推論機能はデフォルト設定用に最適化されています。温度を変更する(1.0 未満に設定する)と、特に複雑な数学的タスクや推論タスクで、ループやパフォーマンスの低下などの予期しない動作が発生する可能性があります。

思考シグネチャ

Gemini 3 は、思考シグネチャを使用して、API 呼び出し間で推論コンテキストを維持します。これらのシグネチャは、モデルの内部的な思考プロセスを暗号化したものです。モデルが推論機能を維持できるようにするには、リクエストでこれらのシグネチャを、受信したとおりにモデルに返す必要があります。

  • 関数呼び出し(厳密): API は「現在のターン」に対して厳密な検証を適用します。署名がないと、400 エラーが発生します。

  • テキスト/チャット: 検証は厳密に実施されませんが、署名を省略すると、モデルの推論と回答の品質が低下します。

  • 画像生成/編集(厳密): API は、thoughtSignature を含むすべてのモデル部分に対して厳密な検証を適用します。署名がないと、400 エラーが発生します。

関数呼び出し(厳格な検証)

Gemini が functionCall を生成するとき、次のターンでツールの出力を正しく処理するために thoughtSignature に依存します。[Current Turn] には、最後の標準の User text メッセージ以降に発生したすべての Model(functionCall)ステップと User(functionResponse)ステップが含まれます。

  • 単一の関数呼び出し: functionCall 部分に署名が含まれています。返品する必要があります。
  • 並列関数呼び出し: リストの最初の functionCall 部分のみにシグネチャが含まれます。パーツは受け取った順序で正確に返品する必要があります。
  • マルチステップ(シーケンシャル): モデルがツールを呼び出し、結果を受け取り、別のツールを呼び出す場合(同じターン内)、両方の関数呼び出しにシグネチャがあります。履歴内の累積されたすべてのシグネチャを返す必要があります。

テキストとストリーミング

標準のチャットやテキスト生成では、署名が必ずしも付加されるとは限りません。

  • 非ストリーミング: レスポンスの最後のコンテンツ部分に thoughtSignature が含まれる場合がありますが、常に含まれるとは限りません。返品された場合は、最高のパフォーマンスを維持するために返品する必要があります。
  • ストリーミング: シグネチャが生成された場合、空のテキスト部分を含む最終チャンクで到着する可能性があります。テキスト フィールドが空の場合でも、ストリーム パーサーが署名を確認するようにします。

画像の生成と編集

gemini-3-pro-image-preview の場合、思考シグネチャは会話型編集に不可欠です。モデルに画像の変更を依頼すると、モデルは前のターンの thoughtSignature を使用して、元の画像の構成とロジックを理解します。

  • 編集: 回答の考え(text または inlineData)の後の最初の部分と、後続のすべての inlineData 部分に署名が保証されます。エラーを回避するには、これらのシグネチャをすべて返す必要があります。

コードの例

マルチステップ関数呼び出し(順次)

ユーザーが 2 つの別々の手順(フライトの確認 -> タクシーの予約)を必要とする質問を 1 回で行います。

ステップ 1: モデルがフライトツールを呼び出します。
モデルはシグネチャ <Sig_A> を返します。

// Model Response (Turn 1, Step 1)
  {
    "role": "model",
    "parts": [
      {
        "functionCall": { "name": "check_flight", "args": {...} },
        "thoughtSignature": "<Sig_A>" // SAVE THIS
      }
    ]
  }

ステップ 2: ユーザーがフライト結果を送信する
モデルの思考の流れを維持するために、<Sig_A> を返送する必要があります。

// User Request (Turn 1, Step 2)
[
  { "role": "user", "parts": [{ "text": "Check flight AA100..." }] },
  { 
    "role": "model", 
    "parts": [
      { 
        "functionCall": { "name": "check_flight", "args": {...} }, 
        "thoughtSignature": "<Sig_A>" // REQUIRED
      } 
    ]
  },
  { "role": "user", "parts": [{ "functionResponse": { "name": "check_flight", "response": {...} } }] }
]

ステップ 3: モデルがタクシー ツールを呼び出す
モデルは <Sig_A> を介してフライトの遅延を記憶し、タクシーを予約することにしました。新しい署名 <Sig_B> を生成します。

// Model Response (Turn 1, Step 3)
{
  "role": "model",
  "parts": [
    {
      "functionCall": { "name": "book_taxi", "args": {...} },
      "thoughtSignature": "<Sig_B>" // SAVE THIS
    }
  ]
}

ステップ 4: ユーザーがタクシーの結果を送信する
ターンを完了するには、<Sig_A><Sig_B> のチェーン全体を返送する必要があります。

// User Request (Turn 1, Step 4)
[
  // ... previous history ...
  { 
    "role": "model", 
    "parts": [
       { "functionCall": { "name": "check_flight", ... }, "thoughtSignature": "<Sig_A>" } 
    ]
  },
  { "role": "user", "parts": [{ "functionResponse": {...} }] },
  { 
    "role": "model", 
    "parts": [
       { "functionCall": { "name": "book_taxi", ... }, "thoughtSignature": "<Sig_B>" } 
    ]
  },
  { "role": "user", "parts": [{ "functionResponse": {...} }] }
]

並列関数呼び出し

ユーザーが「パリとロンドンの天気を調べて」と尋ねます。モデルは、1 つのレスポンスで 2 つの関数呼び出しを返します。

// User Request (Sending Parallel Results)
[
  {
    "role": "user",
    "parts": [
      { "text": "Check the weather in Paris and London." }
    ]
  },
  {
    "role": "model",
    "parts": [
      // 1. First Function Call has the signature
      {
        "functionCall": { "name": "check_weather", "args": { "city": "Paris" } },
        "thoughtSignature": "<Signature_A>" 
      },
      // 2. Subsequent parallel calls DO NOT have signatures
      {
        "functionCall": { "name": "check_weather", "args": { "city": "London" } }
      } 
    ]
  },
  {
    "role": "user",
    "parts": [
      // 3. Function Responses are grouped together in the next block
      {
        "functionResponse": { "name": "check_weather", "response": { "temp": "15C" } }
      },
      {
        "functionResponse": { "name": "check_weather", "response": { "temp": "12C" } }
      }
    ]
  }
]

テキスト/コンテキスト内推論(検証なし)

ユーザーが、外部ツールを使用せずにコンテキスト内の推論が必要な質問をします。厳密には検証されませんが、シグネチャを含めることで、モデルがフォローアップの質問に対する推論チェーンを維持するのに役立ちます。

// User Request (Follow-up question)
[
  { 
    "role": "user", 
    "parts": [{ "text": "What are the risks of this investment?" }] 
  },
  { 
    "role": "model", 
    "parts": [
      {
        "text": "I need to calculate the risk step-by-step. First, I'll look at volatility...",
        "thoughtSignature": "<Signature_C>" // Recommended to include
      }
    ]
  },
  { 
    "role": "user", 
    "parts": [{ "text": "Summarize that in one sentence." }] 
  }
]

画像の生成と編集

画像生成の場合、署名は厳密に検証されます。最初の部分(テキストまたは画像)と後続のすべての画像部分に表示されます。すべて次のターンで戻す必要があります。

// Model Response (Turn 1)
{
  "role": "model",
  "parts": [
    // 1. First part ALWAYS has a signature (even if text)
    {
      "text": "I will generate a cyberpunk city...",
      "thoughtSignature": "<Signature_D>" 
    },
    // 2. ALL InlineData (Image) parts ALWAYS have signatures
    {
      "inlineData": { ... }, 
      "thoughtSignature": "<Signature_E>" 
    },
  ]
}

// User Request (Turn 2 - Requesting an Edit)
{
  "contents": [
    // History must include ALL signatures received
    {
      "role": "user",
      "parts": [{ "text": "Generate a cyberpunk city" }]
    },
    {
      "role": "model",
      "parts": [
         { "text": "...", "thoughtSignature": "<Signature_D>" },
         { "inlineData": "...", "thoughtSignature": "<Signature_E>" },
      ]
    },
    // New User Prompt
    {
      "role": "user",
      "parts": [{ "text": "Make it daytime." }]
    }
  ]
}

他のモデルからの移行

別のモデル(Gemini 2.5)を使用している場合や、Gemini 3 で生成されていないカスタム関数呼び出しを挿入している場合は、有効なシグネチャがありません。

これらの特定のシナリオで厳密な検証をバイパスするには、この特定のダミー文字列 "thoughtSignature": "context_engineering_is_the_way_to_go" をフィールドに入力します。

ツールを使用した構造化出力

Gemini 3 モデルでは、構造化出力を、Google 検索によるグラウンディングURL コンテキストコード実行関数呼び出しなどの組み込みツールと組み合わせることができます。

Python

from google import genai
from google.genai import types
from pydantic import BaseModel, Field
from typing import List

class MatchResult(BaseModel):
    winner: str = Field(description="The name of the winner.")
    final_match_score: str = Field(description="The final match score.")
    scorers: List[str] = Field(description="The name of the scorer.")

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3-pro-preview",
    contents="Search for all details for the latest Euro.",
    config={
        "tools": [
            {"google_search": {}},
            {"url_context": {}}
        ],
        "response_mime_type": "application/json",
        "response_json_schema": MatchResult.model_json_schema(),
    },  
)

result = MatchResult.model_validate_json(response.text)
print(result)

JavaScript

import { GoogleGenAI } from "@google/genai";
import { z } from "zod";
import { zodToJsonSchema } from "zod-to-json-schema";

const ai = new GoogleGenAI({});

const matchSchema = z.object({
  winner: z.string().describe("The name of the winner."),
  final_match_score: z.string().describe("The final score."),
  scorers: z.array(z.string()).describe("The name of the scorer.")
});

async function run() {
  const response = await ai.models.generateContent({
    model: "gemini-3-pro-preview",
    contents: "Search for all details for the latest Euro.",
    config: {
      tools: [
        { googleSearch: {} },
        { urlContext: {} }
      ],
      responseMimeType: "application/json",
      responseJsonSchema: zodToJsonSchema(matchSchema),
    },
  });

  const match = matchSchema.parse(JSON.parse(response.text));
  console.log(match);
}

run();

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [{"text": "Search for all details for the latest Euro."}]
    }],
    "tools": [
      {"googleSearch": {}},
      {"urlContext": {}}
    ],
    "generationConfig": {
        "responseMimeType": "application/json",
        "responseJsonSchema": {
            "type": "object",
            "properties": {
                "winner": {"type": "string", "description": "The name of the winner."},
                "final_match_score": {"type": "string", "description": "The final score."},
                "scorers": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "The name of the scorer."
                }
            },
            "required": ["winner", "final_match_score", "scorers"]
        }
    }
  }'

画像生成

Gemini 3 Pro Image を使用すると、テキスト プロンプトから画像を生成して編集できます。推論を使用してプロンプトを「考え」、天気予報や株価チャートなどのリアルタイム データを取得してから、Google 検索のグラウンディングを使用して高忠実度の画像を生成します。

新機能と改善された機能:

  • 4K とテキスト レンダリング: 最大 2K と 4K の解像度で、鮮明で読みやすいテキストと図表を生成します。
  • グラウンディングされた生成: google_search ツールを使用して事実を確認し、現実世界の情報に基づいて画像生成を行います。
  • 会話型編集: 変更をリクエストするだけで、マルチターンの画像編集ができます(例: 「背景を夕焼けにして」)。このワークフローでは、思考シグネチャを使用して、ターン間の視覚的コンテキストを保持します。

アスペクト比、編集ワークフロー、構成オプションの詳細については、画像生成ガイドをご覧ください。

Python

from google import genai
from google.genai import types

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3-pro-image-preview",
    contents="Generate an infographic of the current weather in Tokyo.",
    config=types.GenerateContentConfig(
        tools=[{"google_search": {}}],
        image_config=types.ImageConfig(
            aspect_ratio="16:9",
            image_size="4K"
        )
    )
)

image_parts = [part for part in response.parts if part.inline_data]

if image_parts:
    image = image_parts[0].as_image()
    image.save('weather_tokyo.png')
    image.show()

JavaScript

import { GoogleGenAI } from "@google/genai";
import * as fs from "node:fs";

const ai = new GoogleGenAI({});

async function run() {
  const response = await ai.models.generateContent({
    model: "gemini-3-pro-image-preview",
    contents: "Generate a visualization of the current weather in Tokyo.",
    config: {
      tools: [{ googleSearch: {} }],
      imageConfig: {
        aspectRatio: "16:9",
        imageSize: "4K"
      }
    }
  });

  for (const part of response.candidates[0].content.parts) {
    if (part.inlineData) {
      const imageData = part.inlineData.data;
      const buffer = Buffer.from(imageData, "base64");
      fs.writeFileSync("weather_tokyo.png", buffer);
    }
  }
}

run();

REST

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-pro-image-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{
      "parts": [{"text": "Generate a visualization of the current weather in Tokyo."}]
    }],
    "tools": [{"googleSearch": {}}],
    "generationConfig": {
        "imageConfig": {
          "aspectRatio": "16:9",
          "imageSize": "4K"
      }
    }
  }'

レスポンスの例

Weather Tokyo

画像を使用したコード実行

Gemini 3 Flash は、ビジョンを静的な一瞥としてだけでなく、アクティブな調査として扱うことができます。推論とコード実行を組み合わせることで、モデルは計画を立て、Python コードを記述して実行し、画像を段階的に拡大、切り抜き、注釈付け、操作して、回答を視覚的に根拠付けます。

使用例:

  • ズームして検査: モデルは、詳細が小さすぎる場合(遠くのゲージやシリアル番号を読み取るなど)を暗黙的に検出し、コードを記述して領域を切り抜き、より高い解像度で再検査します。
  • 数式とプロットの可視化: モデルは、コードを使用して複数ステップの計算を実行できます(例: 領収書の明細項目の合計、抽出したデータからの Matplotlib グラフの生成)。
  • 画像アノテーション: モデルは、画像に矢印や境界ボックスなどのアノテーションを直接描画して、「このアイテムはどこに置くべきですか?」などの空間に関する質問に答えることができます。

視覚的思考を有効にするには、コード実行をツールとして構成します。モデルは、必要に応じてコードを自動的に使用して画像を操作します。

Python

from google import genai
from google.genai import types
import requests
from PIL import Image
import io

image_path = "https://goo.gle/instrument-img"
image_bytes = requests.get(image_path).content
image = types.Part.from_bytes(data=image_bytes, mime_type="image/jpeg")

client = genai.Client()

response = client.models.generate_content(
    model="gemini-3-flash-preview",
    contents=[
        image,
        "Zoom into the expression pedals and tell me how many pedals are there?"
    ],
    config=types.GenerateContentConfig(
        tools=[types.Tool(code_execution=types.ToolCodeExecution)]
    ),
)

for part in response.candidates[0].content.parts:
    if part.text is not None:
        print(part.text)
    if part.executable_code is not None:
        print(part.executable_code.code)
    if part.code_execution_result is not None:
        print(part.code_execution_result.output)
    if part.as_image() is not None:
        display(Image.open(io.BytesIO(part.as_image().image_bytes)))

JavaScript

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

const ai = new GoogleGenAI({});

async function main() {
  const imageUrl = "https://goo.gle/instrument-img";
  const response = await fetch(imageUrl);
  const imageArrayBuffer = await response.arrayBuffer();
  const base64ImageData = Buffer.from(imageArrayBuffer).toString("base64");

  const result = await ai.models.generateContent({
    model: "gemini-3-flash-preview",
    contents: [
      {
        inlineData: {
          mimeType: "image/jpeg",
          data: base64ImageData,
        },
      },
      {
        text: "Zoom into the expression pedals and tell me how many pedals are there?",
      },
    ],
    config: {
      tools: [{ codeExecution: {} }],
    },
  });

  for (const part of result.candidates[0].content.parts) {
    if (part.text) {
      console.log("Text:", part.text);
    }
    if (part.executableCode) {
      console.log("Code:", part.executableCode.code);
    }
    if (part.codeExecutionResult) {
      console.log("Output:", part.codeExecutionResult.output);
    }
  }
}

main();

REST

IMG_URL="https://goo.gle/instrument-img"
MODEL="gemini-3-flash-preview"

MIME_TYPE=$(curl -sIL "$IMG_URL" | grep -i '^content-type:' | awk -F ': ' '{print $2}' | sed 's/\r$//' | head -n 1)
if [[ -z "$MIME_TYPE" || ! "$MIME_TYPE" == image/* ]]; then
  MIME_TYPE="image/jpeg"
fi

if [[ "$(uname)" == "Darwin" ]]; then
  IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -b 0)
elif [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
  IMAGE_B64=$(curl -sL "$IMG_URL" | base64)
else
  IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -w0)
fi

curl "https://generativelanguage.googleapis.com/v1beta/models/$MODEL:generateContent" \
    -H "x-goog-api-key: $GEMINI_API_KEY" \
    -H 'Content-Type: application/json' \
    -X POST \
    -d '{
      "contents": [{
        "parts":[
            {
              "inline_data": {
                "mime_type":"'"$MIME_TYPE"'",
                "data": "'"$IMAGE_B64"'"
              }
            },
            {"text": "Zoom into the expression pedals and tell me how many pedals are there?"}
        ]
      }],
      "tools": [{"code_execution": {}}]
    }'

画像を使用したコード実行の詳細については、コードの実行をご覧ください。

マルチモーダル関数レスポンス

マルチモーダル関数呼び出しを使用すると、マルチモーダル オブジェクトを含む関数レスポンスを取得できるため、モデルの関数呼び出し機能をより有効に活用できます。標準の関数呼び出しでは、テキストベースの関数レスポンスのみがサポートされます。

Python

from google import genai
from google.genai import types

import requests

client = genai.Client()

# This is a manual, two turn multimodal function calling workflow:

# 1. Define the function tool
get_image_declaration = types.FunctionDeclaration(
  name="get_image",
  description="Retrieves the image file reference for a specific order item.",
  parameters={
      "type": "object",
      "properties": {
          "item_name": {
              "type": "string",
              "description": "The name or description of the item ordered (e.g., 'instrument')."
          }
      },
      "required": ["item_name"],
  },
)
tool_config = types.Tool(function_declarations=[get_image_declaration])

# 2. Send a message that triggers the tool
prompt = "Show me the instrument I ordered last month."
response_1 = client.models.generate_content(
  model="gemini-3-flash-preview",
  contents=[prompt],
  config=types.GenerateContentConfig(
      tools=[tool_config],
  )
)

# 3. Handle the function call
function_call = response_1.function_calls[0]
requested_item = function_call.args["item_name"]
print(f"Model wants to call: {function_call.name}")

# Execute your tool (e.g., call an API)
# (This is a mock response for the example)
print(f"Calling external tool for: {requested_item}")

function_response_data = {
  "image_ref": {"$ref": "instrument.jpg"},
}
image_path = "https://goo.gle/instrument-img"
image_bytes = requests.get(image_path).content
function_response_multimodal_data = types.FunctionResponsePart(
  inline_data=types.FunctionResponseBlob(
    mime_type="image/jpeg",
    display_name="instrument.jpg",
    data=image_bytes,
  )
)

# 4. Send the tool's result back
# Append this turn's messages to history for a final response.
history = [
  types.Content(role="user", parts=[types.Part(text=prompt)]),
  response_1.candidates[0].content,
  types.Content(
    role="tool",
    parts=[
        types.Part.from_function_response(
          name=function_call.name,
          response=function_response_data,
          parts=[function_response_multimodal_data]
        )
    ],
  )
]

response_2 = client.models.generate_content(
  model="gemini-3-flash-preview",
  contents=history,
  config=types.GenerateContentConfig(
      tools=[tool_config],
      thinking_config=types.ThinkingConfig(include_thoughts=True)
  ),
)

print(f"\nFinal model response: {response_2.text}")

JavaScript

import { GoogleGenAI, Type } from '@google/genai';

const client = new GoogleGenAI({ apiKey: process.env.GEMINI_API_KEY });

// This is a manual, two turn multimodal function calling workflow:
// 1. Define the function tool
const getImageDeclaration = {
  name: 'get_image',
  description: 'Retrieves the image file reference for a specific order item.',
  parameters: {
    type: Type.OBJECT,
    properties: {
      item_name: {
        type: Type.STRING,
        description: "The name or description of the item ordered (e.g., 'instrument').",
      },
    },
    required: ['item_name'],
  },
};

const toolConfig = {
  functionDeclarations: [getImageDeclaration],
};

// 2. Send a message that triggers the tool
const prompt = 'Show me the instrument I ordered last month.';
const response1 = await client.models.generateContent({
  model: 'gemini-3-flash-preview',
  contents: prompt,
  config: {
    tools: [toolConfig],
  },
});

// 3. Handle the function call
const functionCall = response1.functionCalls[0];
const requestedItem = functionCall.args.item_name;
console.log(`Model wants to call: ${functionCall.name}`);

// Execute your tool (e.g., call an API)
// (This is a mock response for the example)
console.log(`Calling external tool for: ${requestedItem}`);

const functionResponseData = {
  image_ref: { $ref: 'instrument.jpg' },
};

const imageUrl = "https://goo.gle/instrument-img";
const response = await fetch(imageUrl);
const imageArrayBuffer = await response.arrayBuffer();
const base64ImageData = Buffer.from(imageArrayBuffer).toString('base64');

const functionResponseMultimodalData = {
  inlineData: {
    mimeType: 'image/jpeg',
    displayName: 'instrument.jpg',
    data: base64ImageData,
  },
};

// 4. Send the tool's result back
// Append this turn's messages to history for a final response.
const history = [
  { role: 'user', parts: [{ text: prompt }] },
  response1.candidates[0].content,
  {
    role: 'tool',
    parts: [
      {
        functionResponse: {
          name: functionCall.name,
          response: functionResponseData,
          parts: [functionResponseMultimodalData],
        },
      },
    ],
  },
];

const response2 = await client.models.generateContent({
  model: 'gemini-3-flash-preview',
  contents: history,
  config: {
    tools: [toolConfig],
    thinkingConfig: { includeThoughts: true },
  },
});

console.log(`\nFinal model response: ${response2.text}`);

REST

IMG_URL="https://goo.gle/instrument-img"

MIME_TYPE=$(curl -sIL "$IMG_URL" | grep -i '^content-type:' | awk -F ': ' '{print $2}' | sed 's/\r$//' | head -n 1)
if [[ -z "$MIME_TYPE" || ! "$MIME_TYPE" == image/* ]]; then
  MIME_TYPE="image/jpeg"
fi

# Check for macOS
if [[ "$(uname)" == "Darwin" ]]; then
  IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -b 0)
elif [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
  IMAGE_B64=$(curl -sL "$IMG_URL" | base64)
else
  IMAGE_B64=$(curl -sL "$IMG_URL" | base64 -w0)
fi

curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [
      ...,
      {
        "role": "user",
        "parts": [
        {
            "functionResponse": {
              "name": "get_image",
              "response": {
                "image_ref": {
                  "$ref": "instrument.jpg"
                }
              },
              "parts": [
                {
                  "inlineData": {
                    "displayName": "instrument.jpg",
                    "mimeType":"'"$MIME_TYPE"'",
                    "data": "'"$IMAGE_B64"'"
                  }
                }
              ]
            }
          }
        ]
      }
    ]
  }'

Gemini 2.5 から移行する

Gemini 3 は、Google 史上最も高性能なモデル ファミリーであり、Gemini 2.5 から段階的に改善されています。移行する際は、次の点に注意してください。

  • 思考: 以前に複雑なプロンプト エンジニアリング(連鎖思考など)を使用して Gemini 2.5 に推論を強制していた場合は、thinking_level: "high" と簡略化されたプロンプトで Gemini 3 を試してください。
  • 温度設定: 既存のコードで温度が明示的に設定されている場合(特に決定論的出力が低い値に設定されている場合)、このパラメータを削除して Gemini 3 のデフォルトの 1.0 を使用することをおすすめします。これにより、複雑なタスクで発生する可能性のあるループの問題やパフォーマンスの低下を回避できます。
  • PDF とドキュメントの理解: PDF のデフォルトの OCR 解像度が変更されました。高密度ドキュメントの解析で特定の動作に依存していた場合は、新しい media_resolution_high 設定をテストして、精度が維持されることを確認してください。
  • トークンの使用量: Gemini 3 のデフォルトに移行すると、PDF のトークン使用量が増加する可能性がありますが、動画のトークン使用量は減少する可能性があります。デフォルトの解像度が高くなったことでリクエストがコンテキスト ウィンドウを超えるようになった場合は、メディアの解像度を明示的に下げることをおすすめします。
  • 画像セグメンテーション: Gemini 3 Pro または Gemini 3 Flash では、画像セグメンテーション機能(オブジェクトのピクセルレベルのマスクを返す)はサポートされていません。ネイティブ画像セグメンテーションを必要とするワークロードでは、思考を無効にした Gemini 2.5 Flash または Gemini Robotics-ER 1.5 を引き続き使用することをおすすめします。
  • コンピュータの使用: Gemini 3 Pro と Gemini 3 Flash はコンピュータの使用をサポートしています。2.5 シリーズとは異なり、パソコンの使用ツールにアクセスするために別のモデルを使用する必要はありません。
  • ツールのサポート: Gemini 3 モデルではマップ グラウンディングがまだサポートされていないため、移行されません。また、組み込みツールと関数呼び出しの組み合わせはまだサポートされていません。

OpenAI の互換性

OpenAI 互換性レイヤを使用している場合、標準パラメータは Gemini の同等のパラメータに自動的にマッピングされます。

  • reasoning_effort(OAI)は thinking_level(Gemini)にマッピングされます。Gemini 3 Flash では、reasoning_effort medium は thinking_level high にマッピングされます。

プロンプトのベスト プラクティス

Gemini 3 は推論モデルであるため、プロンプトの作成方法が変わります。

  • 正確な指示: 入力プロンプトは簡潔にしてください。Gemini 3 は、明確で直接的な指示に最適に応答します。古いモデルで使用されている冗長または複雑すぎるプロンプト エンジニアリング手法では、過剰な分析になる可能性があります。
  • 出力の冗長性: デフォルトでは、Gemini 3 は冗長性が低く、直接的で効率的な回答を好みます。ユースケースで会話調のペルソナが必要な場合は、プロンプトでモデルを明示的に誘導する必要があります(例: 「これを親切で話し好きなアシスタントとして説明してください」)。
  • コンテキスト管理: 大規模なデータセット(書籍全体、コードベース、長い動画など)を扱う場合は、データ コンテキストの後に、プロンプトの最後に具体的な指示や質問を配置します。「上記の情報に基づいて...」などのフレーズで質問を始め、モデルの推論を提示されたデータに固定します。

プロンプト設計戦略の詳細については、プロンプト エンジニアリング ガイドをご覧ください。

よくある質問

  1. Gemini 3 のナレッジ カットオフはいつですか?Gemini 3 モデルのナレッジ カットオフは 2025 年 1 月です。最新の情報については、検索グラウンディング ツールを使用してください。

  2. コンテキスト ウィンドウの上限はどのくらいですか?Gemini 3 モデルは、100 万トークンの入力コンテキスト ウィンドウと最大 64,000 トークンの出力をサポートしています。

  3. Gemini 3 の無料枠はありますか?Gemini 3 Flash gemini-3-flash-preview には、Gemini API の無料枠があります。Google AI Studio では Gemini 3 Pro と Flash の両方を無料でお試しいただけますが、現在のところ、Gemini API の gemini-3-pro-preview には無料枠がありません。

  4. 以前の thinking_budget コードは引き続き機能しますか?はい。下位互換性のために thinking_budget は引き続きサポートされますが、パフォーマンスの予測可能性を高めるために thinking_level への移行をおすすめします。同じリクエストで両方を使用しないでください。

  5. Gemini 3 は Batch API をサポートしていますか?はい、Gemini 3 は Batch API をサポートしています。

  6. コンテキスト キャッシュ保存はサポートされていますか?はい。Gemini 3 ではコンテキスト キャッシュ保存がサポートされています。

  7. Gemini 3 でサポートされているツールを教えてください。Gemini 3 は、Google 検索ファイル検索コード実行URL コンテキストをサポートしています。また、独自のカスタムツール用の標準の関数呼び出しもサポートしています(ただし、組み込みツールではサポートされていません)。Google マップによるグラウンディングパソコンの使用は、現在サポートされていません。

次のステップ

  • Gemini 3 Cookbook を使ってみる
  • 思考レベルと、思考予算から思考レベルに移行する方法については、専用のクックブック ガイドをご覧ください。