Gemini APIのURLコンテキストツールが一般公開、PDFや画像のサポートを追加
Gemini APIのURLコンテキストツールが一般公開された。このツールにより、開発者はコンテンツを手動でアップロードする代わりに、URL形式でモデルに追加のコンテキストを提供できるようになる。
またURLコンテキストツールがWebページや構造化データ、テキストファイルに加えて、PDFや画像にも対応した。
URLコンテキストツールは、Gemini CLIのweb_fetchコマンドでも利用されている。
Gemini APIで利用する場合は次のようにtoolsを設定する。
python
from google import genai
from google.genai.types import Tool, GenerateContentConfig
client = genai.Client()
model_id = "gemini-2.5-flash"
tools = [
{"url_context": {}},
]
response = client.models.generate_content(
model=model_id,
contents="What are the top 3 recent announcements from the Gemini API according to https://ai.google.dev/gemini-api/docs/changelog",
config=GenerateContentConfig(
tools=tools,
)
)