Google Web Search
Overview
This skill provides the capability to perform real-time web searches via the Gemini API's google_search grounding tool. It is designed to fetch the most current information available on the web to provide grounded, citable answers to user queries.
Key Features:
- - Real-time web search via Gemini API
- Grounded responses with verifiable citations
- Configurable model selection
- Simple Python API
Usage
This skill exposes the Gemini API's google_search tool. It should be used when the user asks for real-time information, recent events, or requests verifiable citations.
Execution Context
The core logic is in scripts/example.py. This script requires the following environment variables:
- - GEMINIAPIKEY (required): Your Gemini API key
- GEMINI_MODEL (optional): Model to use (default:
gemini-2.5-flash-lite)
Supported Models:
- -
gemini-2.5-flash-lite (default) - Fast and cost-effective - INLINECODE5 - Latest flash model
- INLINECODE6 - More capable, slower
- INLINECODE7 - Specific version
Python Tool Implementation Pattern
When integrating this skill into a larger workflow, the helper script should be executed in an environment where the google-genai library is available and the GEMINI_API_KEY is exposed.
Example Python invocation structure:
CODEBLOCK0
Troubleshooting
If the script fails:
- 1. Missing API Key: Ensure
GEMINI_API_KEY is set in the execution environment. - Library Missing: Verify that the
google-genai library is installed (pip install google-generativeai). - API Limits: Check the API usage limits on the Google AI Studio dashboard.
- Invalid Model: If you set
GEMINI_MODEL, ensure it's a valid Gemini model name. - Model Not Supporting Grounding: Some models may not support the
google_search tool. Use flash or pro variants.
Google 网页搜索
概述
该技能提供了通过 Gemini API 的 google_search 基础工具执行实时网页搜索的能力。它旨在获取网络上最新的可用信息,为用户查询提供有据可查、可引用的答案。
主要特点:
- - 通过 Gemini API 进行实时网页搜索
- 带有可验证引用的有据可查的回复
- 可配置的模型选择
- 简单的 Python API
使用方法
该技能暴露了 Gemini API 的 google_search 工具。当用户询问实时信息、近期事件或请求可验证的引用时,应使用此技能。
执行环境
核心逻辑位于 scripts/example.py 中。此脚本需要以下环境变量:
- - GEMINIAPIKEY(必需):您的 Gemini API 密钥
- GEMINI_MODEL(可选):要使用的模型(默认值:gemini-2.5-flash-lite)
支持的模型:
- - gemini-2.5-flash-lite(默认)— 快速且经济高效
- gemini-3-flash-preview — 最新的闪存模型
- gemini-3-pro-preview — 能力更强,速度较慢
- gemini-2.5-flash-lite-preview-09-2025 — 特定版本
Python 工具实现模式
在将此技能集成到更大的工作流中时,应在安装了 google-genai 库并暴露了 GEMINIAPIKEY 的环境中执行辅助脚本。
Python 调用结构示例:
python
from skills.google-web-search.scripts.example import getgroundedresponse
基本用法(使用默认模型):
prompt = 最新的市场趋势是什么?
response
text = getgrounded_response(prompt)
print(response_text)
使用特定模型:
response
text = getgrounded_response(prompt, model=gemini-3-pro-preview)
print(response_text)
或通过环境变量设置:
import os
os.environ[GEMINI_MODEL] = gemini-3-flash-preview
response
text = getgrounded_response(prompt)
print(response_text)
故障排除
如果脚本失败:
- 1. 缺少 API 密钥:确保在执行环境中设置了 GEMINIAPIKEY。
- 缺少库:验证是否已安装 google-genai 库(pip install google-generativeai)。
- API 限制:在 Google AI Studio 仪表板上检查 API 使用限制。
- 无效模型:如果您设置了 GEMINIMODEL,请确保它是有效的 Gemini 模型名称。
- 模型不支持基础功能:某些模型可能不支持 googlesearch 工具。请使用闪存或专业变体。