AIニュース最前線
最新ニュースAI日報Hacker日報週報動画AIツールトレンド企業

AIニュース最前線

世界中のAI最新情報を日本語で毎時更新

最新ニュース日報トレンド企業プレミアムRSS
© 2026 ainew.jp特定商取引法に基づく表記
ニュース一覧元記事を開く
AWS Machine Learning Blog·2026年6月16日 05:24·約17分で読める

Amazon Bedrock に Google DeepMind の「Gemma 4」モデルシリーズが追加

#LLM#Gemma#Amazon Bedrock#Google DeepMind#オープンウェイトモデル#マルチモーダル
TL;DR

AWS は Google DeepMind が開発した高性能オープンウェイトモデル「Gemma 4」ファミリーを Amazon Bedrock で正式に提供開始し、セキュリティと管理性を保ちながら多様なユースケースでの導入を可能にした。

AI深層分析2026年6月16日 06:02
4
重要/ 5段階
深度40%
5
関連度30%
5
実用性20%
4
革新性10%
3

キーポイント

1

Gemma 4 ファミリーの構成とアーキテクチャ

31B の密集型モデルから MoE(Expert)型の 26B-A4B、軽量な E2B までを含む 3 バリアントが提供され、パラメータあたりの知能性を重視した設計となっている。

2

高度な機能とマルチモーダル対応

組み込み推論モード(reasoning mode)、ネイティブ関数呼び出し、テキストと画像を統合したマルチモーダル入力に対応し、35 以上の言語をサポートしている。

3

AWS Bedrock を介した安全な運用

オープンウェイトモデルの透明性を保ちつつ、AWS のインフラ上で完全に管理・実行されるため、データ保護や規制遵守を損なうことなく生産環境での利用が可能となる。

4

ベンチマークにおける高い性能評価

Artificial Analysis による独立したベンチマークでは、Gemma 4 31B のインテリジェンス指数が 39 と記録され、同クラスのオープンウェイトモデルの中央値(15)を大きく上回っている。

5

OpenAI SDK を使用した移行の簡便性

既存の OpenAI SDK フォーマットを使用するアプリケーションを Gemma 4 に移行する場合、Base URL とモデル ID の更新のみで対応可能です。

6

マルチモーダル入力(画像)のサポート

Gemma 4 は全バリアントで画像入力をサポートしており、Chat Completions API を通じてビジョンタスクを実行できます。

7

画像入力の最適化と S3 連携

大きな画像をリクエスト本文に埋め込む代わりに、S3 の URL を使用して参照可能であり、最適な結果を得るには画像コンテンツをテキストの前に配置することが推奨されています。

影響分析・編集コメントを表示

影響分析

この発表は、企業がオープンソースモデルの透明性と柔軟性を享受しつつ、クラウドプロバイダーの堅牢なセキュリティ基盤を同時に利用することを可能にする重要な転換点です。特に、高性能かつ軽量なバリアントを揃えたことで、コストとレイテンシのバランスを最適化しながら大規模な AI エージェントやマルチモーダルアプリケーションの実装が加速すると予想されます。

編集コメント

Google の最新オープンウェイトモデルが AWS の堅牢なインフラ上で利用可能になったことは、セキュリティ要件の厳しい企業にとって大きな追い風となります。特に「パラメータあたりの知能性」を重視した設計は、コスト効率の高い AI 導入戦略において重要な選択肢を提供しています。

本日、Amazon Bedrock 上で Gemma 4 ファミリーの利用可能を発表いたします。Google DeepMind によって構築され、Apache 2.0 ライセンスの下でリリースされた Gemma 4 は、広範なデプロイメントシナリオにわたってパラメータあたりの知能(intelligence-per-parameter)に焦点を当てて設計されたオープンウェイトモデルのファミリーです。このファミリーには、3 つの指示微調整済みバリアントが含まれています:Gemma 4 31B、Gemma 4 26B-A4B、および Gemma 4 E2B です。これらは、各リクエストごとにモデルのパラメータの一部のみが活性化される、密な(dense)アーキテクチャと混合専門家(MoE: mixture-of-experts)アーキテクチャの両方をカバーしています。これらのバリアントは、組み込み推論機能、ネイティブ関数呼び出し、およびテキストと画像にわたるマルチモーダル入力を提供します。

独立したベンチマークは、Gemma 4 のパラメータあたりの知能への焦点を反映しています:Artificial Analysis は、Gemma 4 31B のインテリジェンス指数(Intelligence Index)が 39 であると報告しており、これは 4B~40B オープンウェイトクラスにおける中央値である 15 を大きく上回っています。

生産環境でオープンウェイト基盤モデル(FMs: foundation models)を採用する組織は、常にトレードオフに直面しています:最先端のモデルへのアクセスを得る一方で、データ保護、規制適合性、または運用制御を損なうことなくです。Amazon Bedrock はこのトレードオフを解消します。これは、AWS が運営するインフラストラクチャ上で推論が完全に実行される完全管理型サービスを通じて、最先端のオープンウェイト FMs を提供し、Amazon Bedrock から期待されるセキュリティおよびプライバシーコントロールを備えています。

本記事では、Amazon Bedrock で Gemma 4 モデルの使い方を解説します。これらのモデルがサポートする機能、利用可能なサービスティア、オンデマンド推論がワークロードをどのようにスケーリングするか、そしてアクセスに使用できるさまざまな API について取り上げます。これらのモデルを使用すれば、Amazon Bedrock 上でマルチモーダルエージェント、軽量アプリケーション、ドキュメント理解パイプライン、ソフトウェアエンジニアリングのワークフローを構築できます。プロンプトと生成結果は他のモデルの学習には使用されず、コンテンツも第三者とは共有されません。

Gemma 4 の主要機能

Amazon Bedrock 上のGemma 4ファミリーは、2.3B(有効パラメータ)のコンパクトなモデルから30.7Bのパラメータを持つ密結合モデルまで幅広く、コストとレイテンシのプロファイルに応じて異なるバリアントを選択できます。すべてのバリアントには、組み込みの推論モード、エージェントワークフローのためのネイティブ関数呼び出し機能、テキストと画像を組み合わせたマルチモーダル入力、そして140以上の言語にわたる事前学習に基づく35以上の言語へのアウトオブザボックス対応が備わっています。モデルはオープンウェイトであるため、モデルアーキテクチャやトレーニング手法を独自に評価したり、独自のワークロードでベンチマークを行ったり、カスタマイズが必要な場合にproprietaryデータ(独自データ)上でファインチューニングを行ったりすることが可能です。これらのモデルは、インフラストラクチャのプロビジョニング、モデルウェイトのホスティング、推論スタックの自己運用を必要とせず、完全にマネージドされたAWSサービスを通じてアクセスできます。

最新のサポート対象モデル一覧については、Amazon Bedrock モデルカタログをご参照ください。

Amazon Bedrock 上の Gemma 4 ファミリー概観

このファミリーには、異なるコストとレイテンシプロファイルに最適化された 3 つの指令微調整済みバリアントが含まれています。以下の表は、Amazon Bedrock 上の各モデルの主要仕様を要約したものです:

Gemma 4 31BGemma 4 26B-A4BGemma 4 E2B
モデル IDgoogle.gemma-4-31bgoogle.gemma-4-26b-a4bgoogle.gemma-4-e2b
アーキテクチャ (Architecture)Dense(密結合)Mixture-of-Experts(専門家混合モデル)Dense (PLE)
総パラメータ数 / アクティブパラメータ数30.7B25.2B / アクティブ 3.8B総計 5.1B / 実効 2.3B
コンテキストウィンドウ (Context window)256K トークン256K トークン128K トークン
モダリティ (Modalities)テキスト、画像テキスト、画像テキスト、画像
リーゾニングモード (Reasoning mode)ありありあり
関数呼び出し (Function calling)ネイティブネイティブネイティブ
サービスティア (Service tiers)Standard, Priority, FlexStandard, Priority, FlexStandard, Priority, Flex

バリアントの選択

ワークロードのパフォーマンスとコスト要件に最も適合するバリアントを選択してください。以下の表は、ユースケースに基づいてどのモデルを選ぶべきかのガイダンスを提供しています:

| ワークロードが… | 選択 | 理由 |

推論重視またはコーディング重視の単一密着型モデル

Gemma 4 31B

ファミリー内で最大の密着型バリアント;256K のコンテキストウィンドウを備えた強力な推論およびコーディングパフォーマンス。

高スループットにおけるコスト感度や知識の広範性を必要とする用途向け

Gemma 4 26B-A4B

MoE(Mixture of Experts)設計により、推論コストとレイテンシは 4B の密着型モデルに近づきつつ、より大規模なモデルに匹敵する知識容量を維持します。

レイテンシ感度が高い、オンデバイススタイル、またはマルチモーダル分類用途向け

Gemma 4 E2B

最小かつ最速のバリアント;最低コストまたは最速レスポンスが必要なマルチモーダルワークロードに適しています。このバリアントでは reasoning_effort=high を設定してください(*推論モードの有効化*を参照)。

ファミリー全体を通じて、Gemma 4 モデルは共通のインターフェースを共有します:システムプロンプト、構造化されたツール呼び出し、画像入力、そしてリクエストごとに切り替え可能な思考モードです。API サーフェスに対して一度アプリケーションを開発すれば、ワークロードに適合するコストとレイテンシのプロファイルに基づいてバリアントを切り替えることができます。

アーキテクチャのハイライト

すべてのGemma 4バリアントは、ローカルアテンションとグローバルアテンションをインターリーブするハイブリッドアテンション設計を採用しており、31Bおよび26B-A4Bモデルにおいて最大256Kトークンの長いコンテキストをサポートしながら、小さなメモリフットプリントを維持しています。26B-A4Bバリアントはエキスパートの混合(Mixture-of-Experts)モデルであり、総パラメータ数は25.2Bですが、トークンごとにアクティブになるのは3.8Bのみです。これにより、より大きなモデルの知識容量を持ちながら、約4Bクラスの計算コストとレイテンシを実現します。E2Bバリアントは、パーレイヤー埋め込み(Per-Layer Embeddings: PLE)を採用し、有効なパラメータ数(総計5.1Bのうち2.3B)を小さく保つことで、メモリおよび計算コストを低減しています。アーキテクチャの詳細については、Gemma 4モデルカードをご参照ください。

注: Gemma 4モデルにはbedrock-mantleエンドポイントを使用してください。

推論モード

Gemma 4には組み込みの推論モードが備わっています。有効にすると、モデルは最終回答を生成する前に内部の思考プロセスを出力します。bedrock-mantleエンドポイントでは、Responses APIのreasoningパラメータを通じて推論を有効化でき、思考プロセスは最終回答とは別に「reasoning item」として返されます(ウォークスルー内の*推論モードの有効化*を参照)。

多回会話においては、過去のターンからの最終回答のみを送り返し、その推論項目は含めないでください。過去の推論をモデルに再入力すると、回答の質が低下する可能性があります。推論内容は独自のログや監査証跡に保持しておくことはできますが、次のターンで送信する履歴からは削除してください。

Amazon Bedrock 上の Gemma 4 モデルへのアクセス

Amazon Bedrock 上の Gemma 4 モデルは、Amazon Bedrock の次世代推論エンジン向けに特別に設計された OpenAI 互換 API を通じて、bedrock-mantle エンドポイントを使用してアクセスします。そのエンドポイント URL は https://bedrock-mantle.{region}.api.aws/openai/v1 であり、Chat Completions および Responses API を公開しています。

エンドポイントとエンジンを区別して理解しておくことが有益です:*エンジン*とは、モデルデプロイメントアカウントの分離とゼロオペレーターアクセスを設計思想として備えた基盤となるサービングインフラストラクチャ(推論エンジン)であり、*エンドポイント*とは呼び出す HTTPS API サーフェスです。bedrock-mantle エンドポイントは、この次世代推論エンジンのための公開 API であり、その機能セット全体を公開しています。基盤となる推論エンジンについてさらに詳しく知りたい場合は、Amazon Bedrock の次世代推論エンジンのゼロオペレーターアクセス設計の探求 を参照してください。

bedrock-mantle エンドポイントは、OpenAI Python および TypeScript SDK と同じインターフェースを使用するため、すでにこれらの SDK を利用しているチームは、ベース URL とモデル ID のみを更新するだけで、Amazon Bedrock 上の Gemma 4 モデルへ切り替えることができます。また、Amazon Bedrock API キー、プロジェクト、およびクライアントサイドのツール呼び出しもサポートしています。

Amazon Bedrock で Gemma 4 ファミリーモデルの使用を開始する

Gemma 4 を Amazon Bedrock で使用開始するには、以下の手順を実行してください。

前提条件

Gemma 4 モデルを使用するには、bedrock-mantle エンドポイント上で推論を実行する権限を持つ AWS アカウントが必要です。これらの権限を付与する最も簡単な方法は、AWS Identity and Access Management (IAM) プリンシパルに AWS マネージドポリシー「AmazonBedrockMantleInferenceAccess」をアタッチすることです。これにより、Mantle 上で読み取りおよび推論作成へのアクセス権が付与され、本記事の例で必要な権限となります。具体的には、Chat Completions および Responses の推論呼び出しを許可する「bedrock-mantle:CreateInference」と、Amazon Bedrock API キーを使用してエンドポイントを呼び出すことを許可する「bedrock-mantle:CallWithBearerToken」が含まれます。API キーの作成および管理の詳細については、Amazon Bedrock API キー を参照してください。

また、プロジェクト、ファインチューニング、カスタムモデルなどの管理が必要な場合は、「AmazonBedrockMantleFullAccess」をアタッチしてください。これにより、すべての bedrock-mantle アクションセットが許可されます。

コンソールプレイグラウンド

Amazon Bedrock コンソール には、コードを書かずにモデルをすばやくテストできるチャット/テキストプレイグラウンドが含まれています。Gemma 4 モデルを読み込んで対話の準備をするには、以下の手順に従ってください:

  • Amazon Bedrock コンソールへ移動します。
  • 左側のメニューから「テストプレイグラウンド」を選択します。
  • 「チャット/テキスト」プレイグラウンドを選択します。
  • プレイグラウンドの左上隅にある「モデルを選択」をクリックします。
  • カテゴリリストから「Google」を選択します。
  • Gemma 4 モデルのいずれかを選択します。
  • 「適用」を選択してモデルを読み込みます。
  • モデルが正常に読み込まれたことを確認します:プレイグラウンドのヘッダーにモデル名が表示され、チャットインターフェースが入力待ち状態になっているはずです。

Gemma 4 31B の推論およびコード生成能力を実演するために、以下のプロンプトをプレイグラウンドで試してください:*「タスクキューを管理するための REST API を公開する Python マイクロサービスを作成してください。エラーハンドリングと入力検証を含め、ユニットテストも記述してください。設計上の判断理由についても説明してください。」*

OpenAI SDK から bedrock-mantle エンドポイントを呼び出す

以下の例では、クライアントライブラリとして OpenAI Python SDK を使用して bedrock-mantle エンドポイントを呼び出します。OpenAI SDK を使用する際は、Amazon Bedrock API キーが必要です。本番環境のワークロードでは、短期間の API キーを使用してください。これらは自動的に期限切れになります(最大 12 時間)し、生成した IAM ロールの権限を継承します。すでにネイティブな AWS 認証情報を使用しており API キーをお持ちでない場合は、aws-bedrock-token-generator パッケージがその認証情報から短期間のベアータークンを生成します。

python
from openai import OpenAI

client = OpenAI(

api_key="",

base_url="https://bedrock-mantle.us-east-1.api.aws/openai/v1",

)

response = client.chat.completions.create(

model="google.gemma-4-31b",

messages=[

{"role": "user", "content": "Explain the benefits of mixture-of-experts architectures for production inference."}

],

max_tokens=512,

)

print(response.choices[0].message.content)

もし、すでに OpenAI SDK 形式を使用している既存のアプリケーションを異なるモデルへ移行する場合、通常はベース URL とモデル ID のみを更新すれば十分です。API キーの生成および使用に関する権限を制御するには、Amazon Bedrock API キーの生成と使用のための権限管理 を参照してください。

**

注:** この記事のコード例では、デモンストレーションのために環境変数から API キーを読み込んでいます。本番環境では、環境変数ではなく、AWS Secrets Manager や AWS Systems Manager Parameter Store などの管理されたシークレットサービスから認証情報を保存・取得してください。

マルチモーダル入力(画像)

Gemma 4 はすべてのバリアントで画像入力をサポートしているため、ビジョンタスクにも同じ Chat Completions API が使用可能です。bedrock-mantle エンドポイントでは、画像をインラインの base64 符号化データ URL または Amazon Simple Storage Service (Amazon S3) の URL (s3://) として受け付けます。任意の公開 https:// 形式の画像 URL はサポートされていません。以下の例では、ローカルの画像ファイルを読み込んで base64 データ URL に符号化し、テキストプロンプトと共にメッセージコンテンツに含めています:

python
import base64

# ローカル画像ファイルを読み込み、base64 データ URL として符号化する。
with open("chart.png", "rb") as image_file:
    image_b64 = base64.b64encode(image_file.read()).decode("utf-8")
data_url = f"data:image/png;base64,{image_b64}"

response = client.chat.completions.create(
    model="google.gemma-4-31b",
    messages=[{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {"url": data_url}},
            {"type": "text", "text": "Describe the trend shown in this chart."}
        ]
    }],
)
print(response.choices[0].message.content)

また、Amazon S3 に保存された画像を参照するには、データ URL の代わりに s3:// URL を渡すことで対応できます(例:{"url": "s3://my-bucket/chart.png"})。これにより、リクエスト本文に大規模な画像をインラインで埋め込む必要がなくなります。より良い結果を得るためには、プロンプト内で画像コンテンツをテキストの前に配置してください。これは Google DeepMind が Gemma 4 のマルチモーダル入力に対して推奨する順序と一致しています。

ストリーミングレスポンス

トークンを生成するたびにユーザーに表示したいチャットやエージェントユースケースでは、stream=True を設定してください。レスポンスは、逐次的なデルタイベントのイテレータになります:

stream = client.chat.completions.create(

model="google.gemma-4-31b",

messages=[

{"role": "user", "content": "分散システムについて短い詩を書いてください。"}

],

stream=True,

)

for chunk in stream:

delta = chunk.choices[0].delta.content

if delta:

print(delta, end="", flush=True)

print()

ストリーミングは、非ストリーミング呼び出しと同じく bedrock-mantle:CreateInference 権限を使用します。前述の IAM ポリシーですでにこれをカバーしています。

ツール呼び出し

Gemma 4 は、エージェントワークフローのためのネイティブ関数呼び出しをサポートしています。以下の例は、ツールの定義、モデルからのツール呼び出しの受信、関数の実行、結果の返却を含む完全なツール呼び出しループを示しています:

import json

from openai import OpenAI

client = OpenAI(

api_key="",

base_url="https://bedrock-mantle.us-east-1.api.aws/openai/v1",

)

tools = [

{

"type": "function",

"function": {

"name": "get_weather",

"description": "指定された場所の現在の天気を取得する",

"parameters": {

"type": "object",

"properties": {

"location": {

"type": "string",

"description": "都市と国(例:Seattle, US)"

},

"unit": {

"type": "string",

"enum": ["celsius", "fahrenheit"],

"description": "温度の単位"

}

},

"required": ["location"]

}

}

}

]

ステップ 1: ツール定義と共にユーザーのリクエストを送信する

messages = [

{"role": "user", "content": "シアトルの天気はどうですか?"}

]

response = client.chat.completions.create(

model="google.gemma-4-31b",

messages=messages,

tools=tools,

tool_choice="auto",

)

assistant_message = response.choices[0].message

ステップ 2: モデルがツールを呼び出そうとしているか確認する

if assistant_message.tool_calls:

messages.append(assistant_message)

for tool_call in assistant_message.tool_calls:

function_name = tool_call.function.name

arguments = json.loads(tool_call.function.arguments)

ステップ 3:関数名を検証して実行する(実装側)

if function_name == "get_weather":

location = arguments.get("location", "Unknown")

unit = arguments.get("unit", "fahrenheit")

result = {

"location": location,

"temperature": 18 if unit == "celsius" else 64,

"unit": unit,

"condition": "Partly cloudy",

"humidity": 72,

}

else:

result = {"error": f"Unknown function: {function_name}"}

# ステップ 4:関数の結果をモデルに返す

messages.append({

"role": "tool",

"tool_call_id": tool_call.id,

"content": json.dumps(result),

})

# ステップ 5:ツールの結果を組み込んだ最終応答を取得する

final_response = client.chat.completions.create(

model="google.gemma-4-31b",

messages=messages,

tools=tools,

)

print(final_response.choices[0].message.content)

else:

print(assistant_message.content)

Responses API

Chat Completions に加え、bedrock-mantle エンドポイントは OpenAI の Responses API(応答 API)もサポートしており、これは単一の入力を使用します

原文を表示

Today, we are announcing the availability of the Gemma 4 family on Amazon Bedrock. Built by Google DeepMind and released under the Apache 2.0 license, Gemma 4 is a family of open-weight models designed with a focus on intelligence-per-parameter across a broad range of deployment scenarios. The family includes three instruction-tuned variants: Gemma 4 31B, Gemma 4 26B-A4B, and Gemma 4 E2B. These cover dense and mixture-of-experts (MoE) architectures, where only a fraction of the model’s parameters activate per request. The variants offer built-in reasoning, native function calling, and multimodal input across text and image.

Independent benchmarks reflect Gemma 4’s intelligence-per-parameter focus: Artificial Analysis reports an Intelligence Index of 39 for Gemma 4 31B, well above the median of 15 in the 4B–40B open-weights class.

Organizations adopting open-weight foundation models (FMs) for production face a constant trade-off: access the leading models, but without compromising on data protection, regulatory alignment, or operational control. Amazon Bedrock removes that trade-off. It gives you leading open-weight FMs through a fully managed service, with inference running entirely on infrastructure operated by AWS and the security and privacy controls you expect from Amazon Bedrock.

In this post, we walk through how to get started with Gemma 4 models on Amazon Bedrock. We cover the capabilities supported by these models, the service tiers available, how on-demand inference scales to handle your workloads, and the different APIs you can use to access them. With these models, you can build multimodal agents, lightweight applications, document understanding pipelines, and software engineering workflows on Amazon Bedrock. Your prompts and completions are not used to train any models, and your content is not shared with third parties.

Key capabilities of Gemma 4

The Gemma 4 family on Amazon Bedrock spans a 2.3B-effective-parameter compact model up to a 30.7B-parameter dense model, giving you a choice of variants to match different cost and latency profiles. All variants support a built-in reasoning mode, native function calling for agentic workflows, multimodal input that combines text and image, and out-of-the-box support for over 35 languages with pre-training across 140+. Because the models are open-weight, you can independently evaluate the model architecture and training methodology, benchmark on your own workloads, and fine-tune on proprietary data when customization is required. You can access the models through a fully managed AWS service without provisioning infrastructure, hosting model weights, or operating inference stacks yourself.anno

For the latest list of supported models, refer to the Amazon Bedrock model catalog.

The Gemma 4 family on Amazon Bedrock at a glance

The family includes three instruction-tuned variants optimized for different cost and latency profiles. The following table summarizes the key specifications for each model on Amazon Bedrock:

Gemma 4 31B

Gemma 4 26B-A4B

Gemma 4 E2B

Model ID

google.gemma-4-31b

google.gemma-4-26b-a4b

google.gemma-4-e2b

Architecture

Dense

Mixture-of-Experts

Dense (PLE)

Total / Active parameters

30.7B

25.2B / 3.8B active

5.1B total / 2.3B effective

Context window

256K tokens

256K tokens

128K tokens

Modalities

Text, image

Text, image

Text, image

Reasoning mode

Yes

Yes

Yes

Function calling

Native

Native

Native

Service tiers

Standard, Priority, Flex

Standard, Priority, Flex

Standard, Priority, Flex

Choosing a variant

Select the variant that best matches your workload’s performance and cost requirements. The following table provides guidance on which model to choose based on your use case:

If your workload is…

Choose

Why

Reasoning-heavy or coding-heavy with a single dense model

Gemma 4 31B

Largest dense variant in the family; strong reasoning and coding performance with a 256K context window.

Cost-sensitive at high throughput, with knowledge breadth requirements

Gemma 4 26B-A4B

MoE design means inference cost and latency closer to a 4B dense model while retaining the knowledge capacity of a much larger one.

Latency-sensitive, on-device-style, or multimodal classification

Gemma 4 E2B

Smallest, fastest variant; suited for lowest-cost or fastest-response multimodal workloads. Set reasoning_effort=high for this variant (see *Enable reasoning mode*).

Across the family, Gemma 4 models share a common interface: system prompts, structured tool calling, image input, and a thinking mode that can be toggled per request. You can develop an application against the API surface once and switch between variants based on the cost and latency profile that fits the workload.

Architecture highlights

All Gemma 4 variants use a hybrid attention design that interleaves local and global attention, supporting long contexts up to 256K tokens on 31B and 26B-A4B while keeping a small memory footprint. The 26B-A4B variant is a mixture-of-experts model: 25.2B total parameters but only 3.8B active per token, giving roughly 4B-class cost and latency with the knowledge capacity of a larger model. The E2B variant uses Per-Layer Embeddings (PLE) to keep its effective parameter count (2.3B of 5.1B total) small, lowering memory and compute cost. For architecture details, refer to the Gemma 4 model card.

Note: Use the bedrock-mantle endpoint for Gemma 4 models.

Reasoning mode

Gemma 4 includes a built-in reasoning mode. When enabled, the model emits its internal thought process before producing the final answer. On the bedrock-mantle endpoint, you enable reasoning through the Responses API reasoning parameter, and the thought process is returned as a separate reasoning item alongside the final answer (see *Enable reasoning mode* in the walkthrough).

In multi-turn conversations, send back only the final answers from previous turns, not their reasoning items. Replaying prior reasoning back to the model can degrade its responses. You can still keep the reasoning in your own logs or audit trail. Strip it from the history you send on the next turn.

Accessing Gemma 4 models on Amazon Bedrock

You access Gemma 4 models on Amazon Bedrock through the bedrock-mantle endpoint, the OpenAI-compatible API purpose-built for the next-generation inference engine for Amazon Bedrock. Its endpoint URL is https://bedrock-mantle.{region}.api.aws/openai/v1, and it exposes the Chat Completions and Responses APIs.

It’s helpful to keep the endpoint and the engine distinct: the *engine* is the underlying serving infrastructure—designed with Model Deployment Account isolation and zero operator access—and the *endpoint* is the HTTPS API surface you call. The bedrock-mantle endpoint is the public API for that next-generation inference engine and exposes its full feature set. For a deeper look at the underlying inference engine, refer to Exploring the zero operator access design of Amazon Bedrock’s next-generation inference engine.

The bedrock-mantle endpoint uses the same interface as the OpenAI Python and TypeScript SDKs, so teams already on those SDKs can switch to Gemma 4 models on Amazon Bedrock by updating only the base URL and model ID. It also supports Amazon Bedrock API keys, projects, and client-side tool calling.

Get started with Gemma 4 family models on Amazon Bedrock

Complete the following steps to start using Gemma 4 on Amazon Bedrock.

Prerequisites

To use Gemma 4 models, you need an AWS account with permissions to run inference on the bedrock-mantle endpoint. The simplest way to grant these is to attach the AWS managed policy AmazonBedrockMantleInferenceAccess to your AWS Identity and Access Management (IAM) principal. It grants read and inference-creation access on Mantle—the permissions the examples in this post need. These include bedrock-mantle:CreateInference (which authorizes the Chat Completions and Responses inference calls) and bedrock-mantle:CallWithBearerToken (which authorizes calling the endpoint with an Amazon Bedrock API key). For details on creating and managing API keys, refer to Amazon Bedrock API keys.

If you also need to manage projects, fine-tuning, custom models, and more, attach AmazonBedrockMantleFullAccess instead, which grants the full bedrock-mantle action set.

Console playground

The Amazon Bedrock console includes a chat/text playground where you can quickly test models without writing any code. Follow these steps to load a Gemma 4 model and prepare it for interaction:

  • Navigate to the Amazon Bedrock console.
  • From the left menu, choose Test playgrounds.
  • Choose the Chat/Text playground.
  • Choose Select model in the upper-left corner of the playground.
  • From the category list, choose Google.
  • Choose a Gemma 4 model.
  • Choose Apply to load the model.
  • Verify that the model loaded successfully: the model name appears in the playground header, and the chat interface is ready for input.

To demonstrate Gemma 4 31B’s reasoning and code generation capabilities, try the following prompt in the playground: *“Design a Python microservice that exposes a REST API for managing a task queue. Include error handling, input validation, and write unit tests. Explain your design decisions.”*

Call the bedrock-mantle endpoint from the OpenAI SDK

The following example uses the OpenAI Python SDK as a client library to call the bedrock-mantle endpoint. When using the OpenAI SDK, you need an Amazon Bedrock API key. For production workloads, use short-term API keys. They expire automatically (maximum 12 hours) and inherit the permissions of the IAM role that generated them. If you are already using native AWS credentials and don’t have an API key, the aws-bedrock-token-generator package generates a short-term bearer token from those credentials.

code
from openai import OpenAI

client = OpenAI(
    api_key="",
    base_url="https://bedrock-mantle.us-east-1.api.aws/openai/v1",
)

response = client.chat.completions.create(
    model="google.gemma-4-31b",
    messages=[
        {"role": "user", "content": "Explain the benefits of mixture-of-experts architectures for production inference."}
    ],
    max_tokens=512,
)
print(response.choices[0].message.content)

If you are migrating an existing application that already uses the OpenAI SDK format with a different model, the migration typically requires updating only the base URL and the model ID. To control permissions for generating and using API keys, refer to Control permissions for generating and using Amazon Bedrock API keys.

Note: The code examples in this post read the API key from an environment variable for demonstration only. In production, store and retrieve credentials from a managed secrets service such as AWS Secrets Manager or AWS Systems Manager Parameter Store rather than environment variables.

Multimodal input (image)

Because Gemma 4 supports image input across all variants, the same Chat Completions API works for vision tasks. The bedrock-mantle endpoint accepts images as inline base64-encoded data URLs or as Amazon Simple Storage Service (Amazon S3) URLs (s3://); arbitrary public https:// image URLs are not supported. The following example reads a local image file, encodes it as a base64 data URL, and includes it in the message content alongside the text prompt:

code
import base64

# Read a local image file and encode it as a base64 data URL.
with open("chart.png", "rb") as image_file:
    image_b64 = base64.b64encode(image_file.read()).decode("utf-8")
data_url = f"data:image/png;base64,{image_b64}"

response = client.chat.completions.create(
    model="google.gemma-4-31b",
    messages=[{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {"url": data_url}},
            {"type": "text", "text": "Describe the trend shown in this chart."}
        ]
    }],
)
print(response.choices[0].message.content)

Alternatively, you can reference an image stored in Amazon S3 by passing an s3:// URL in place of the data URL (for example, {"url": "s3://my-bucket/chart.png"}). This avoids inlining large images in the request body. For best results, place image content before the text in the prompt, which matches Google DeepMind’s recommended ordering for Gemma 4 multimodal inputs.

Streaming responses

For chat and agent use cases where you want to surface tokens to the user as they are generated, set stream=True. The response becomes an iterator of incremental delta events:

code
stream = client.chat.completions.create(
    model="google.gemma-4-31b",
    messages=[
        {"role": "user", "content": "Write a short poem about distributed systems."}
    ],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content
    if delta:
        print(delta, end="", flush=True)
print()

Streaming uses the same bedrock-mantle:CreateInference permission as a non-streaming call—the IAM policy shown earlier already covers it.

Tool calling

Gemma 4 supports native function calling for agentic workflows. The following example shows a complete tool-calling loop: defining a tool, receiving a tool call from the model, executing the function, and passing the result back.

code
import json
from openai import OpenAI

client = OpenAI(
    api_key="",
    base_url="https://bedrock-mantle.us-east-1.api.aws/openai/v1",
)

tools = [
    {
        "type": "function",
        "function": {
            "name": "get_weather",
            "description": "Get the current weather for a given location",
            "parameters": {
                "type": "object",
                "properties": {
                    "location": {
                        "type": "string",
                        "description": "City and country (e.g., Seattle, US)"
                    },
                    "unit": {
                        "type": "string",
                        "enum": ["celsius", "fahrenheit"],
                        "description": "Temperature unit"
                    }
                },
                "required": ["location"]
            }
        }
    }
]

# Step 1: Send the user request with tool definitions
messages = [
    {"role": "user", "content": "What's the weather like in Seattle?"}
]

response = client.chat.completions.create(
    model="google.gemma-4-31b",
    messages=messages,
    tools=tools,
    tool_choice="auto",
)

assistant_message = response.choices[0].message

# Step 2: Check if the model wants to call a tool
if assistant_message.tool_calls:
    messages.append(assistant_message)

    for tool_call in assistant_message.tool_calls:
        function_name = tool_call.function.name
        arguments = json.loads(tool_call.function.arguments)

        # Step 3: Validate the function name and run it (your implementation)
        if function_name == "get_weather":
            location = arguments.get("location", "Unknown")
            unit = arguments.get("unit", "fahrenheit")
            result = {
                "location": location,
                "temperature": 18 if unit == "celsius" else 64,
                "unit": unit,
                "condition": "Partly cloudy",
                "humidity": 72,
            }
        else:
            result = {"error": f"Unknown function: {function_name}"}

        # Step 4: Return the function result to the model
        messages.append({
            "role": "tool",
            "tool_call_id": tool_call.id,
            "content": json.dumps(result),
        })

    # Step 5: Get the final response incorporating tool results
    final_response = client.chat.completions.create(
        model="google.gemma-4-31b",
        messages=messages,
        tools=tools,
    )

    print(final_response.choices[0].message.content)
else:
    print(assistant_message.content)

Responses API

In addition to Chat Completions, the bedrock-mantle endpoint supports the OpenAI Responses API, which uses a single inpu

この記事をシェア

関連記事

Latent Space2026年6月20日 17:06

[AINews] 今日特に大きな出来事はありませんでした

Latent Space は、GLM 5.2 が依然として注目されていると指摘しつつ、AIE WF 2026 の通常チケットが月曜日に完売すると発表しました。同サイト購読者向けに限定割引を提供し、参加者には Warp や Datadog などからのスポンサークレジットも付与されます。

TechCrunch AI★42026年6月20日 01:01

米国がアンソロピックの「Fable 5」発売を禁止、しかし市場は動じず

米国政府は国家安全保障上の懸念から、アマゾンの研究者らがガードレール回避手法を発見したとして、アンソロピックに対し最新モデル「Fable 5」と「Mythos 5」の販売差し止めを命じた。サイバーセキュリティ研究者らはこの措置が危険だとする公開書簡に署名し、同社も他モデルでも同様の抜け道が存在すると指摘している。

GitHub Blog★42026年6月20日 01:00

社内データ分析エージェントの構築方法について

GitHub は、大規模なデータ組織が直面する自己完結型のデータアクセスと洞察提供の課題に対し、AI を活用した信頼性の高い解決策として、社内でデータ分析エージェントを構築したことを発表した。

今日のまとめ

AI日報で今日の重要ニュースをまとめ読み

ニュース一覧に戻る元記事を読む