API バージョンの説明

このドキュメントでは、Gemini API の v1 バージョンと v1beta バージョンの違いの概要について説明します。

  • v1: API の安定版。安定版の機能は、メジャー バージョンのライフサイクル全体にわたって完全にサポートされます。互換性を破る変更がある場合は、API の新しいメジャー バージョンが作成され、既存のバージョンは妥当な期間の後に非推奨になります。メジャー バージョンを変更せずに、API に非破壊的変更が導入されることがあります。Interactions API とそのコア機能は、v1 で一般提供されています。
  • v1beta: このバージョンには、開発中の初期の機能が含まれています。v1beta の機能は、フィードバックに基づいて改善されるため、変更される可能性がありますが、安定版に昇格する前に新機能を試すことができます。

機能のサポート

次の表に、v1(GA)と v1beta(ベータ版)の機能の可用性を示します。特に指定がない限り、コア API の機能とツールは Interactions API と generateContent の両方に適用されます。

機能 v1 v1beta
Core API の機能
Interactions API
関数呼び出し
構造化出力
思考 / 推論
システム指示
音声出力(音声構成)
サービスティア(優先 / フレキシブル)
ツール
コード実行ツール
Google 検索グラウンディング
Google マップのグラウンディング
URL コンテキスト ツール
ファイル検索ツール
コンピュータ使用ツール
MCP サーバーツール
リアルタイム API
Live API(WebSocket)
Live Music API
エフェメラル トークン(Live API)
プラットフォーム API
Models API
Files Service Route
ファイル検索でルートを保存
Agents API
Webhooks API
コンテキスト キャッシュ保存
  • - サポート対象

SDK で API バージョンを構成する

Gemini API SDK はデフォルトで v1beta に設定されていますが、次のコードサンプルに示すように API バージョンを設定することで、バージョンを明示的に指定できます。

Python

from google import genai

client = genai.Client(http_options={'api_version': 'v1'})

interaction = client.interactions.create(
    model='gemini-3.8-flash',
    input="Explain how AI works",
)

print(interaction.output_text)

JavaScript

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

const ai = new GoogleGenAI({
  httpOptions: { apiVersion: "v1" },
});

async function main() {
  const interaction = await ai.interactions.create({
    model: "gemini-3.8-flash",
    input: "Explain how AI works",
  });
  console.log(interaction.output_text);
}

await main();

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.types.HttpOptions;

Client client = Client.builder()
    .httpOptions(HttpOptions.builder().apiVersion("v1").build())
    .build();

CreateModelInteraction req = CreateModelInteraction.builder()
    .model(Model.of("gemini-3.6-flash"))
    .input(InteractionsInput.of("Explain how AI works"))
    .build();
var interaction = client.interactions.create(CreateInteractionRequestBody.of(req)).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, &genai.ClientConfig{
        HTTPOptions: genai.HTTPOptions{
            APIVersion: "v1",
        },
    })
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.6-flash"),
            Input: interactions.NewInteractionsInput("Explain how AI works"),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Interaction.OutputText != nil {
        fmt.Println(*res.Interaction.OutputText)
    }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1/interactions" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "gemini-3.8-flash",
    "input": "Explain how AI works",
  }'