Skip to main content

Overview

Web search tool using the BoCha AI-powered search API. Returns structured results with titles, URLs, summaries, and metadata.
Required: A BoCha API key. Get one at bochaai.com. Install the extra: pip install aiohttp.

Quick Start — No Attributes

Call the factory function with only the required API key.
from upsonic import Agent, Task
from upsonic.tools.common_tools import bocha_search_tool

agent = Agent(
    model="anthropic/claude-sonnet-4-5",
    name="BoCha Search Agent",
    tools=[bocha_search_tool(api_key="your_bocha_api_key")],
)
task = Task(description="Search for 'latest AI agent frameworks 2025'.")
result = agent.print_do(task)
print(result)

Parameters

Function Parameters:
ParameterTypeDefaultDescription
api_keystrYour BoCha API key (required).
Tool Parameters:
ParameterTypeDefaultDescription
querystrSearch keywords.
freshnessstr"noLimit"Time range — "noLimit", "oneDay", "oneWeek", "oneMonth", "oneYear", "YYYY-MM-DD", or "YYYY-MM-DD..YYYY-MM-DD".
summaryboolTrueWhether to include text summaries.
countint10Number of results to return (1–50).
includestrNoneDomains to include, separated by | or ,.
excludestrNoneDomains to exclude, separated by | or ,.

Result Format

Search results are returned as a list of dictionaries:
[
    {
        "title": "Page Title",
        "url": "https://example.com/page",
        "summary": "Text summary of the page content",
        "site_name": "Example",
        "site_icon": "https://example.com/favicon.ico",
        "date_last_crawled": "2025-01-15T00:00:00"
    },
    # ... more results
]

Installation

pip install aiohttp