# Web search

Ask OpenCode for current information and it can search the web, read the results, and include source links in its response.

```text
Find the latest Bun release and summarize the changes.
```

The first search asks you to allow web search and select a provider. OpenCode remembers your choice for later sessions.

## Providers

OpenCode includes five search providers:

| Provider | ID | Environment variable |
| --- | --- | --- |
| Exa | `exa` | `EXA_API_KEY` |
| Firecrawl | `firecrawl` | `FIRECRAWL_API_KEY` |
| Parallel | `parallel` | `PARALLEL_API_KEY` |
| Tavily | `tavily` | `TAVILY_API_KEY` |
| TinyFish | `tinyfish` | `TINYFISH_API_KEY` (optional) |

Connect an account from the TUI with `/connect`, or set the provider's environment variable before starting OpenCode.

```bash
$ TAVILY_API_KEY=your-key opencode
```

### Claude Agent

When [Claude Agent](/claude-agent) is connected, it also offers a search provider with the ID `claude-agent`. It runs Claude Code's WebSearch, so searches count toward your Claude plan and need no search API key. Every model can use it, not just Claude.

Claude Agent is never picked automatically. Select it in `opencode.jsonc`:

```jsonc title="opencode.jsonc"
{
  "$schema": "https://opencode.ai/config.json",
  "websearch": {
    "provider": "claude-agent",
  },
}
```

WebSearch returns page contents encrypted, so a Claude model has to run each search. Haiku runs it, and its short summary of the results comes first, followed by the links. Searches use the Claude Agent provider's connection settings and the account your chats used last.

## Selection

Set a provider in `opencode.jsonc` to skip the selection prompt.

```jsonc title="opencode.jsonc"
{
  "$schema": "https://opencode.ai/config.json",
  "websearch": {
    "provider": "tavily",
  },
}
```

Use `"random"` to choose an available provider automatically. Each session keeps using its selected provider until that provider is rate limited.

```jsonc title="opencode.jsonc"
{
  "$schema": "https://opencode.ai/config.json",
  "websearch": {
    "provider": "random",
  },
}
```

## Limits

When a provider returns HTTP 429, random selection retries the search with another available provider. The rate-limited provider waits for its `Retry-After` period, or 60 seconds when the response does not include a valid period.

```text
Exa returns HTTP 429
→ Exa enters cooldown
→ OpenCode retries with another provider
```

If every provider is cooling down, the search fails immediately. Moving a session or restarting its server clears its remembered provider; cooldowns are shared by sessions in the same workspace.

## Permissions

Web searches use the `websearch` permission action and the search query as the resource. Ask before searches that are not explicitly allowed.

```jsonc title="opencode.jsonc"
{
  "$schema": "https://opencode.ai/config.json",
  "permissions": [
    {
      "action": "websearch",
      "resource": "*",
      "effect": "ask",
    },
  ],
}
```

See [Permissions](/permissions) for rule order and matching.

## Disable

Set `websearch` to `false` to remove the web search tool from model requests.

```jsonc title="opencode.jsonc"
{
  "$schema": "https://opencode.ai/config.json",
  "websearch": false,
}
```