***

title: WebSearchSkill
slug: /reference/typescript/agents/skills/web-search
description: Search the web using the Google Custom Search JSON API.
---------------------

For a complete index of all SignalWire documentation pages, fetch https://signalwire.com/docs/llms.txt

[add-skill]: /docs/server-sdks/reference/typescript/agents/agent-base/add-skill

Search the web using the Google Custom Search JSON API. Returns titles, links,
and snippets.

**Class:** `WebSearchSkill`

**Tools:** `web_search`

**Env vars:** `GOOGLE_SEARCH_API_KEY`, `GOOGLE_SEARCH_CX`

<ParamField path="api_key" type="string" required={true} toc={true}>
  Google Custom Search API key. Falls back to the `GOOGLE_SEARCH_API_KEY` environment variable.
</ParamField>

<ParamField path="search_engine_id" type="string" required={true} toc={true}>
  Google Custom Search Engine ID (CX). Falls back to the `GOOGLE_SEARCH_CX` environment variable.
</ParamField>

<ParamField path="max_results" type="number" default="5" toc={true}>
  Maximum number of results to return (1-10).
</ParamField>

<ParamField path="safe_search" type="string" default="medium" toc={true}>
  Safe search level: `"off"`, `"medium"`, or `"high"`.
</ParamField>

```typescript {6-9}
import { AgentBase, WebSearchSkill } from '@signalwire/sdk';

const agent = new AgentBase({ name: 'assistant', route: '/assistant' });
agent.setPromptText('You are a helpful assistant.');

await agent.addSkill(new WebSearchSkill({
  max_results: 3,
  safe_search: 'high',
}));

agent.run();
```