# 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 fails over.

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

## Limits

With random selection, a search that hits a rate limit, a used-up quota or plan limit, or an error reported by the provider's search service is retried with another available provider. A rate-limited provider waits for its `Retry-After` period, or 60 seconds when the response does not include one. A provider with a used-up quota or a reported error waits 15 minutes. The session keeps using the new provider. If every provider fails, the search reports the last provider's error. A provider you chose directly never fails over.

```text
A provider returns HTTP 429
→ that provider 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,
}
```