← All tools

Web & HTTP

Web Search

Search the web for news, market analysis, and reference information.

web_search

Overview

Looks things up on the web, the way you'd Google a topic. Give it a question, company name, or ticker, and it brings back a short list of the most relevant news and articles — so the agent can work from what's happening right now instead of only what it already knew.

How it works

Routes each query across any configured search providers — AlphaVantage, NewsAPI, Polygon, Finnhub, Google Programmable Search, Bing — and falls back to the next one if the first returns nothing. Results come back ranked with a title, snippet, and source URL per entry, so agents can quote and cite them directly.

Example

When a user asks:

Find recent news about Tesla's earnings.

the agent calls the tool:

web_search(query="Tesla earnings")

and gets back: a ranked list of the latest articles — title, snippet, and source URL for each.

Configuration

Set these before calling the tool. Values marked required must be present or the tool call will fail.

stock.search.alphavantage.api-key optional

AlphaVantage key (defaults to 'demo'); also reads ALPHA_VANTAGE_API_KEY env.

stock.search.newsapi.api-key optional

NewsAPI.org key for headline search.

stock.search.polygon.api-key optional

Polygon.io key for market data.

stock.search.finnhub.api-key optional

Finnhub key for financial news search.

stock.search.google.api-key optional

Google Custom Search API key.

stock.search.google.search-engine-id optional

Google Programmable Search Engine ID (cx).

stock.search.bing.api-key optional

Bing Web Search API key.

Use it in a workflow

Wire this tool into a SwarmAI crew. Use the YAML DSL for declarative workflows, or the Java builder API when you want full programmatic control.

YAML DSL

# market-research.yaml
name: market-research-crew
process: SEQUENTIAL

agents:
  - id: researcher
    role: Market Research Analyst
    goal: Surface fresh news on target tickers
    tools:
      - web_search

tasks:
  - id: market-research-task
    agent: researcher
    description: Find recent news on Tesla's Q4 earnings and summarize the top 3 stories with citations.

Java

import ai.intelliswarm.swarmai.agent.Agent;
import ai.intelliswarm.swarmai.task.Task;
import ai.intelliswarm.swarmai.swarm.Swarm;
import ai.intelliswarm.swarmai.swarm.SwarmOutput;
import ai.intelliswarm.swarmai.process.ProcessType;
import ai.intelliswarm.swarmai.tool.common.WebSearchTool;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.beans.factory.annotation.Autowired;

@Autowired ChatClient chatClient;
@Autowired WebSearchTool webSearchTool;

Agent researcher = Agent.builder()
    .role("Market Research Analyst")
    .goal("Surface fresh news on target tickers")
    .chatClient(chatClient)
    .tool(webSearchTool)
    .build();

Task researcherTask = Task.builder()
    .description("Find recent news on Tesla's Q4 earnings and summarize the top 3 stories with citations.")
    .agent(researcher)
    .build();

SwarmOutput result = Swarm.builder()
    .agent(researcher)
    .task(researcherTask)
    .process(ProcessType.SEQUENTIAL)
    .build()
    .kickoff();

What it's good for

Real scenarios where agents put this tool to work.

Stock news and market sentiment in finance crews
Real-time headline gathering for analyst agents
Competitive intel and company news scans
Multi-provider fallback for high reliability

Source

Implementation lives at swarmai-tools/src/main/java/ai/intelliswarm/swarmai/tool/common/WebSearchTool.java in the swarm-ai repository.

Open web_search on GitHub →