google-web-search

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Google Web Search

Google 网页搜索

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
本Skill可通过Gemini API的
google_search
grounding工具执行实时网页搜索。它旨在获取网络上最新的可用信息,为用户的查询提供基于事实、可引用的答案。
核心特性:
  • 通过Gemini API实现实时网页搜索
  • 提供带有可验证引用的基于事实的响应
  • 可配置模型选择
  • 简洁的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.
本Skill封装了Gemini API的
google_search
工具。当用户询问实时信息近期事件或要求可验证引用时,应使用本Skill。

Execution Context

执行环境

The core logic is in
scripts/example.py
. This script requires the following environment variables:
  • GEMINI_API_KEY (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
  • gemini-3-flash-preview
    - Latest flash model
  • gemini-3-pro-preview
    - More capable, slower
  • gemini-2.5-flash-lite-preview-09-2025
    - Specific version
核心逻辑位于
scripts/example.py
脚本中。该脚本需要以下环境变量:
  • GEMINI_API_KEY(必填):您的Gemini API密钥
  • GEMINI_MODEL(可选):使用的模型(默认值:
    gemini-2.5-flash-lite
支持的模型:
  • gemini-2.5-flash-lite
    (默认)- 快速且经济高效
  • gemini-3-flash-preview
    - 最新的flash模型
  • gemini-3-pro-preview
    - 功能更强,速度稍慢
  • gemini-2.5-flash-lite-preview-09-2025
    - 特定版本

Python Tool Implementation Pattern

Python工具实现模式

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:
python
from skills.google-web-search.scripts.example import get_grounded_response
将本Skill集成到更大的工作流中时,辅助脚本应在已安装
google-genai
库且已配置
GEMINI_API_KEY
的环境中执行。
Python调用示例结构:
python
from skills.google-web-search.scripts.example import get_grounded_response

Basic usage (uses default model):

基础用法(使用默认模型):

prompt = "What is the latest market trend?" response_text = get_grounded_response(prompt) print(response_text)
prompt = "What is the latest market trend?" response_text = get_grounded_response(prompt) print(response_text)

Using a specific model:

使用特定模型:

response_text = get_grounded_response(prompt, model="gemini-3-pro-preview") print(response_text)
response_text = get_grounded_response(prompt, model="gemini-3-pro-preview") print(response_text)

Or set via environment variable:

或通过环境变量设置:

import os os.environ["GEMINI_MODEL"] = "gemini-3-flash-preview" response_text = get_grounded_response(prompt) print(response_text)
undefined
import os os.environ["GEMINI_MODEL"] = "gemini-3-flash-preview" response_text = get_grounded_response(prompt) print(response_text)
undefined

Troubleshooting

故障排除

If the script fails:
  1. Missing API Key: Ensure
    GEMINI_API_KEY
    is set in the execution environment.
  2. Library Missing: Verify that the
    google-genai
    library is installed (
    pip install google-generativeai
    ).
  3. API Limits: Check the API usage limits on the Google AI Studio dashboard.
  4. Invalid Model: If you set
    GEMINI_MODEL
    , ensure it's a valid Gemini model name.
  5. Model Not Supporting Grounding: Some models may not support the
    google_search
    tool. Use flash or pro variants.
如果脚本运行失败:
  1. 缺少API密钥:确保执行环境中已设置
    GEMINI_API_KEY
  2. 缺少依赖库:确认已安装
    google-genai
    库(执行
    pip install google-generativeai
    )。
  3. API限制:在Google AI Studio控制台检查API使用限制。
  4. 无效模型:如果设置了
    GEMINI_MODEL
    ,请确保它是有效的Gemini模型名称。
  5. 模型不支持Grounding:部分模型可能不支持
    google_search
    工具,请使用flash或pro系列模型。