このガイドでは、Google AI Studio ダッシュボードで Gemini API の使用状況のログを表示して、モデルの動作とユーザーがアプリケーションをどのように操作しているかをより深く理解する方法について説明します。ロギングを使用して、観察、デバッグ、必要に応じて使用状況のフィードバックを Google と共有し、デベロッパーのユースケース全体で Gemini の改善に役立てます。*
すべての GenerateContent、BatchGenerateContent、StreamGenerateContent API 呼び出し、およびマネージド エージェントを除く Interactions API 呼び出しがサポートされています。これには、OpenAI 互換性エンドポイントを介して行われた呼び出しが含まれます。
プロジェクト ロギングを構成する
デフォルトでは、Interactions API と Generate Content API の両方がリクエスト(store=true)を保存します。Interactions API の場合、これによりサーバーサイドの状態管理機能も有効になります。
Google AI Studio では、個々のプロジェクトのストレージを有効または無効にできます。これらの設定は、Gemini API ログ ダッシュボードの [設定] パネルでいつでも変更できます。generateContent API と Interactions API のロギングを個別にオンまたはオフに切り替えて、プロジェクトのデフォルトのストレージ動作を変更できます。
リクエストレベルのロギング
どちらの API も、デフォルトでリクエストを保存します(store=true)。
- Interactions API: デフォルトでリクエストを保存し、サーバーサイドの状態管理を簡素化します。
- Generate Content API(
generateContent、streamGenerateContent、batchGenerateContent): 2026 年 10 月 26 日以降に作成されたプロジェクトのリクエストをデフォルトで保存します。この日付より前に作成されたプロジェクトでは、AI Studio でロギングが有効になっていない限り、デフォルトでリクエストは保存されません(store=false)。
リクエストレベルの store プロパティは、プロジェクト レベルの設定よりも優先されます。Generate Content API リクエストで store を設定するには、Python の場合は google-genai 2.33.0 以降、JavaScript の場合は @google/genai 2.31.0 以降、Java の場合は google-genai 1.79.0 以降、Go の場合は google.golang.org/genai 1.76.0 以降が必要です。store プロパティを設定する方法は次のとおりです。
GenerateContent API
Python
from google import genai
client = genai.Client()
response = client.models.generate_content(
model='gemini-3.8-flash',
contents='Explain quantum entanglement in simple terms.',
config={'store': True} # Set to False to disable logging of this request
)
print(response.text)
JavaScript
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const response = await client.models.generateContent({
model: 'gemini-3.8-flash',
contents: 'Explain quantum entanglement in simple terms.',
config: {
store: true // Set to false to disable logging of this request
}
});
console.log(response.text);
Java
import com.google.genai.Client;
import com.google.genai.types.GenerateContentConfig;
import com.google.genai.types.GenerateContentResponse;
Client client = new Client();
GenerateContentResponse response =
client.models.generateContent(
"gemini-3.8-flash",
"Explain quantum entanglement in simple terms.",
GenerateContentConfig.builder()
.store(true) // Set to false to disable logging of this request
.build());
System.out.println(response.text());
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
response, err := client.Models.GenerateContent(
ctx,
"gemini-3.8-flash",
genai.Text("Explain quantum entanglement in simple terms."),
&genai.GenerateContentConfig{
Store: genai.Ptr(true), // Set to false to disable logging of this request
},
)
if err != nil {
log.Fatal(err)
}
fmt.Println(response.Text())
}
Interactions API
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3.8-flash",
input="Explain quantum entanglement in simple terms.",
store=True # Set to False to disable logging of this request
)
print(interaction.outputs[-1].text)
JavaScript
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
model: 'gemini-3.8-flash',
input: 'Explain quantum entanglement in simple terms.',
store: true // Set to false to disable logging of this request
});
console.log(interaction.outputs[interaction.outputs.length - 1].text);
Java
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model(Model.of("gemini-3.8-flash"))
.input(InteractionsInput.of("Explain quantum entanglement in simple terms."))
.store(true) // Set to false to disable logging of this request
.build();
Interaction interaction =
client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();
System.out.println(interaction.outputText().orElse(""));
Go
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
Model: interactions.Model("gemini-3.8-flash"),
Input: interactions.NewInteractionsInput("Explain quantum entanglement in simple terms."),
Store: genai.Ptr(true), // Set to false to disable logging of this request
}),
})
if err != nil {
log.Fatal(err)
}
if res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
AI Studio でプロジェクト ログを表示する
- AI Studio の [ログ] ページに移動します。
- プルダウンからプロジェクトを選択します。
- ログが存在する場合は、表に新しい順に表示されます。
- 2026 年 10 月 26 日より前に作成されたプロジェクトの場合は、まず設定パネルで Generate Content API ロギングを有効にして、Generate Content API のプロジェクト ログをモニタリングします。
エントリをクリックすると、ペイロードのプレビューが表示されます。Gemini からのプロンプトと回答の全文、および前のターンのコンテキストを検査できます。Interactions API リクエストの場合、ログには previous_interaction_id への直接リンクも含まれます。
プロジェクト ストレージの保持を構成する
ログは、デフォルトの保持期間である 55 日が経過すると期限切れになり、削除対象としてマークされます(データセットに保存されている場合を除く。この場合、期限切れになりません)。プロジェクトのログの保持期間は、最大 7 日、14 日、28 日、55 日に構成できます。
データセットを作成して共有する
ログをデータセットに保存すると、ログをより効果的に整理してエクスポートできます。
- [ログページ] で、上部のフィルタバーを見つけて、フィルタするプロパティを選択します。
- フィルタ表示で、チェックボックスを使用して、すべてのログまたは個々のログを選択します。
- リストの上部に表示される [データセットを作成] ボタンをクリックします。
- 新しいデータセットに名前を付け、必要に応じて説明を入力します。
- 作成したデータセットと、キュレートされたログセットが表示されます。
- データセットを CSV、JSONL ファイル、または Google スプレッドシートにエクスポートして、さらに分析します。
データセットは、さまざまなユースケースに役立ちます。
- 課題セットをキュレートする: AI の改善が必要な領域をターゲットにして、今後の改善を推進します。
- サンプルセットをキュレートする: たとえば、実際の使用状況からサンプルを抽出して別のモデルから回答を生成したり、デプロイ前の定期的なチェックのためにエッジケースのコレクションをキュレートしたりします。
- 評価セット: 重要な機能全体にわたる実際の使用状況を代表するセット。他のモデルやシステム指示のイテレーションとの比較に使用されます。
データセットをデモの例として Google と共有することで、Gemini の研究開発に貢献できます。
制限事項
現在、次のロギングはサポートされていません。
- Imagen モデルと Veo モデル
- Gemini のエンベディング モデル
- Gemini Robotics モデル
- 動画、GIF、PDF を含む入力
- Gemini API のパブリック プレビュー エージェント
次のステップ
- セッション履歴を使用したプロトタイプ作成: AI Studio Build を使用してアプリをバイブ コーディングし、API キーを追加して、AI 機能の Gemini API ログの履歴を有効にします。
- Gemini Batch API を使用してログを再実行する: Gemini Batch API を使用してログを再実行し、レスポンスのサンプリングとモデルまたはアプリケーション ロジックの評価にデータセットを使用します。