> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brightdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenCode plugin integration

> Install the Bright Data plugin for OpenCode to give your coding agent live web search, scraping and structured data, with 5,000 free credits per month.

> [card] [Building an AI startup?](https://brightdata.com/ai/ai-startups-program)
>
> You might be eligible for our Startup Program. Get fully funded access to the infrastructure you're reading about right now (up to \$20K value).

Install the Bright Data plugin for [OpenCode](https://opencode.ai) so your coding agent can search, scrape and extract structured data from the live web without getting blocked. The plugin adds Bright Data skills to OpenCode, and the agent runs them through the [Bright Data CLI](https://docs.brightdata.com/products/cli/overview.md).

## Prerequisites

* [OpenCode](https://opencode.ai/docs/) is installed. The plugin works with OpenCode 2 and OpenCode 1
* [Node.js](https://nodejs.org/en/download) 20 or later is installed (required for the Bright Data CLI)
* [A Bright Data account](https://brightdata.com/?hs_signup=1\&utm_source=docs). New accounts get [5,000 free credits every month](https://docs.brightdata.com/general/account/billing-and-pricing/free-tier.md), no credit card required

## How to install the Bright Data plugin for OpenCode

**1. Install the Bright Data CLI**

Install the Bright Data CLI globally so the agent can call `bdata` from its shell:

```bash theme={null}
npm install -g @brightdata/cli
```

For other install methods, see [Install the Bright Data CLI](https://docs.brightdata.com/products/cli/installation.md).

**2. Log in to Bright Data**

Connect your Bright Data account:

```bash theme={null}
bdata login
```

`bdata login` opens a browser to authorize, saves your credentials and creates the `cli_unlocker` and `cli_browser` zones if they do not exist. Over SSH or in a headless environment, run `bdata login --device` instead. In CI, run `bdata login --api-key YOUR_API_KEY`.

**3. Add the plugin to OpenCode**

Run the command for your OpenCode version. Check the version with `opencode --version`.

> [tab] OpenCode 2
>
> ```bash theme={null}
> opencode plugin add @brightdata/opencode-brightdata@latest
> ```
>
> The command adds the plugin to your global `~/.config/opencode/opencode.json`. To add the plugin to a single project instead, put the following in the project's `opencode.json`:
>
> ```json theme={null}
> {
>   "$schema": "https://opencode.ai/config.json",
>   "plugins": ["@brightdata/opencode-brightdata@latest"]
> }
> ```
>
> Keep the `@latest` tag. With `@latest`, OpenCode checks for a new version on startup and every 24 hours. Without a tag, OpenCode stays on the version you first installed.

> [tab] OpenCode 1
>
> ```bash theme={null}
> opencode plugin @brightdata/opencode-brightdata -g
> ```
>
> The `-g` flag installs the plugin for every project. Leave out `-g` to install the plugin for the current project only.
>
> You can also edit `opencode.json` directly. OpenCode 1 uses the `plugin` key, not `plugins`:
>
> ```json theme={null}
> {
>   "$schema": "https://opencode.ai/config.json",
>   "plugin": ["@brightdata/opencode-brightdata"]
> }
> ```
>
> Start a new OpenCode session to load the plugin.

**4. Check that the plugin is loaded**

On OpenCode 2, list the installed plugins:

```bash theme={null}
opencode plugin list
```

You should see `brightdata` in the output:

```text theme={null}
ID          VERSION  SOURCE
brightdata  1.1.3    @brightdata/opencode-brightdata@latest
```

On OpenCode 1, start a session and ask `Which Bright Data skills do you have?`.

**5. Run your first prompt**

Start OpenCode with `opencode` and paste a prompt:

```text Prompt theme={null}
Use Bright Data to search Google for "opencode plugins" and list the top 3 results with their URLs.
```

The agent loads a Bright Data skill, runs the search in its shell and answers with the live results.

## What can OpenCode do with the Bright Data plugin?

OpenCode loads a Bright Data skill when your prompt needs one. Describe the task in plain language, or name the skill in the prompt.

| Skill | What it gives the agent |
| - | - |
| `brightdata-cli` | Search, scraping, pre-built scrapers, zones and account balance through the Bright Data CLI |
| `search` | Google results as structured JSON |
| `scrape` | Any webpage as clean markdown, with CAPTCHA solving |
| `data-feeds` | Structured data from Amazon, LinkedIn, Instagram, TikTok, YouTube and more |
| `scraper-builder` | A guided workflow for building a production scraper |
| `design-mirror` | The visual style of a website, applied to your codebase |
| `bright-data-mcp` | Guidance for using the Bright Data MCP server tools |
| `bright-data-best-practices` | API selection, authentication and code patterns for Bright Data products |
| `python-sdk-best-practices` | Guidance for writing code with the Bright Data Python SDK |

The plugin also gives the agent the CLI install and login instructions, and passes your [Bright Data environment variables](#which-environment-variables-does-the-plugin-use) to shell commands.

### Which prompts can I try?

The prompts below cover search, scraping and pre-built scrapers:

```text Search the web theme={null}
Use Bright Data to search Google for "best vector databases" as a user in
Germany, and return the title and URL of each organic result as a table.
```

```text Scrape a page theme={null}
Use Bright Data to scrape https://opencode.ai/docs/plugins/ and list
every plugin command with a one-line description.
```

```text Get structured data theme={null}
Use Bright Data to get the title, price and rating for
https://www.amazon.com/dp/B0FQFB8FMG as JSON.
```

```text Find a scraper theme={null}
Use the Bright Data CLI to find a pre-built scraper for LinkedIn profiles,
then show me its input fields and a ready-to-run command.
```

The agent can find a scraper among thousands of pre-built scrapers with `bdata pipelines search`, and use `bdata scrape` for a page that has no pre-built scraper.

## Which environment variables does the plugin use?

None are required after `bdata login`. Every skill uses your saved API key and zone. To use environment variables instead of a saved login, set an API key and a Web Unlocker API zone:

```bash theme={null}
export BRIGHTDATA_API_KEY=YOUR_API_KEY
export BRIGHTDATA_UNLOCKER_ZONE=cli_unlocker
```

Get an API key from the [user settings page](https://brightdata.com/cp/setting/users). Set the variables in the environment that starts OpenCode. Environment variables override the saved login.

| Variable | Purpose |
| - | - |
| `BRIGHTDATA_API_KEY` | API key for the Bright Data CLI and the skill scripts |
| `BRIGHTDATA_UNLOCKER_ZONE` | Web Unlocker API zone for scraping. Also used for search when no SERP API zone is set |
| `BRIGHTDATA_SERP_ZONE` | SERP API zone for search through the Bright Data CLI |
| `BRIGHTDATA_POLLING_TIMEOUT` | Seconds to wait for async jobs. Default: 600 |

## How do I connect the Bright Data MCP server to OpenCode?

The plugin does not need the [Bright Data MCP server](https://docs.brightdata.com/products/mcp-server/overview.md). Add the Bright Data MCP server when you want web tools inside the agent's tool loop, or browser automation without shell commands.

> [tab] OpenCode 2
>
> ```bash theme={null}
> opencode mcp add brightdata --global --url https://mcp.brightdata.com/mcp
> opencode mcp auth brightdata
> ```
>
> Leave out `--global` to add the server to the current project only.

> [tab] OpenCode 1
>
> ```bash theme={null}
> opencode mcp add brightdata --url https://mcp.brightdata.com/mcp
> opencode mcp auth brightdata
> ```

`opencode mcp auth` starts the [OAuth 2.1](https://docs.brightdata.com/products/mcp-server/remote/oauth) sign-in, so no API key is stored in the config file.

In an environment with no browser, connect with an API key instead. Replace the URL in the `opencode mcp add` command with the following, and keep the quotes:

```text theme={null}
"https://mcp.brightdata.com/mcp?token={env:BRIGHTDATA_API_KEY}"
```

OpenCode reads `BRIGHTDATA_API_KEY` from the environment when it connects, so the API key itself is not written to `opencode.json`. Verify the connection:

```bash theme={null}
opencode mcp list
```

You should see `brightdata` marked as `connected`.

## How to update or remove the plugin

OpenCode 2 manages the plugin from the terminal:

```bash theme={null}
opencode plugin check     # see if an update is available
opencode plugin update    # install available updates
opencode plugin remove @brightdata/opencode-brightdata@latest
```

Use the same package name and tag in `remove` that you used in `add`. On OpenCode 1, remove the plugin by deleting its entry from the `plugin` list in `opencode.json`.

## How to fix common OpenCode plugin errors

### Why does OpenCode report "BRIGHTDATA\_API\_KEY is not set"?

The plugin is older than version 1.1.3, which added support for the saved login in the `search`, `scrape`, `data-feeds` and `design-mirror` skills. On OpenCode 2, run `opencode plugin update`. On version 1.1.3 or later, a "No Bright Data API key found" error means you are not logged in. Run `bdata login`.

### Why do I see "No Web Unlocker zone specified" or "No Web Unlocker zone found"?

`BRIGHTDATA_API_KEY` is set, but no zone is configured. An API key alone does not select a zone, so scraping fails with one of these errors and `bdata search` fails with "No zone specified". Run `bdata login --api-key "$BRIGHTDATA_API_KEY"` once to create and save a zone, or set the zone:

```bash theme={null}
export BRIGHTDATA_UNLOCKER_ZONE=cli_unlocker
```

The `cli_unlocker` zone exists after your first `bdata login`. You can use any other Web Unlocker API zone in your account.

### Why does `opencode plugin list` show "No plugins found"?

OpenCode 2 loads plugins in the background after its service starts. Wait a few seconds and run `opencode plugin list` again.

### Why does the agent report "bdata: command not found"?

The Bright Data CLI is not installed, or the npm global folder is not on your `PATH`. Run `npm install -g @brightdata/cli`, then confirm the install with `bdata --version`.

## Next steps

> [card] [Bright Data CLI commands](https://docs.brightdata.com/products/cli/commands.md)
>
> Look up every command, flag and option the agent can run.

> [card] [Bright Data for your coding agent](https://docs.brightdata.com/quickstart-coding-agent.md)
>
> Combine llms.txt, agent skills, the CLI and the MCP server.

> [card] [Plugin source code](https://github.com/brightdata/opencode-brightdata)
>
> Read the plugin source, report an issue or check releases.
