How to Configure a Residential Proxy for Bilibili Access in Agent Reach

Configure a residential proxy for Bilibili in Agent Reach by setting the bilibili_proxy key via the CLI --proxy install flag, editing ~/.config/agent_reach/config.yaml, or exporting the BILIBILI_PROXY environment variable, which the channel in agent_reach/channels/bilibili.py passes directly to yt-dlp.

Agent Reach relies on yt-dlp to fetch and process Bilibili video content. When regional restrictions or network policies block direct access, the tool lets you route Bilibili traffic through a residential proxy using a single dedicated configuration key. The source code implements three equivalent injection paths that all resolve inside the Bilibili channel before any download begins.

How the Proxy Is Read in the Source Code

The resolution logic is defined in agent_reach/channels/bilibili.py between lines 42 and 51. The channel attempts to retrieve the bilibili_proxy value from the global Config object, then falls back to the BILIBILI_PROXY environment variable:

proxy = (config.get("bilibili_proxy") if config else None) or os.environ.get("BILIBILI_PROXY")

If the resulting proxy string is truthy, the channel’s health check appends the status 视频读取:yt-dlp(代理已配置). Otherwise it reports 视频读取:yt-dlp. This distinction lets you confirm at a glance whether yt-dlp will tunnel through your proxy endpoint.

Three Ways to Configure the Bilibili Proxy

1. CLI Install Flag

During setup, pass the --proxy argument to the install command. The CLI parser in agent_reach/cli.py (lines 210–230) captures this flag and persists it via config.set under the key bilibili_proxy:

python -m agent_reach.cli install --proxy http://user:pass@proxy-host:port

This is the most direct way to store credentials permanently in Agent Reach.

2. Configuration File

For manual edits, add the key to ~/.config/agent_reach/config.yaml. The Config class in agent_reach/config.py loads this file at startup and exposes the value to every channel:

bilibili_proxy: http://user:pass@proxy-host:port

After saving the YAML file, the next Agent Reach invocation will pick up the new proxy automatically.

3. Environment Variable

For temporary or scripted usage, export BILIBILI_PROXY in your shell. Because the channel treats this as a fallback, it is especially useful in Docker containers or CI runners where editing a config file is impractical:

export BILIBILI_PROXY=http://user:pass@proxy-host:port
python -m agent_reach.cli doctor

Verify the Proxy with the Health Check

The doctor command surfaces proxy status through the output handled by agent_reach/doctor.py. Run:

python -m agent_reach.cli doctor

Look for the Bilibili line. If it reads 视频读取:yt-dlp(代理已配置), the proxy is recognized. If you see only 视频读取:yt-dlp, neither the config key nor the environment variable is set, and yt-dlp will attempt a direct connection.

Complete Configuration Example

Combine the steps above to install, verify, and use the proxy in one session:


# 1. Persist the proxy through the CLI

python -m agent_reach.cli install --proxy http://myproxy.example.com:1080

# 2. Confirm the channel reports it as active

python -m agent_reach.cli doctor

# 3. Read a Bilibili URL through the proxied yt-dlp backend

agent_reach read <url>

If you need to rotate credentials later, overwrite the bilibili_proxy entry in ~/.config/agent_reach/config.yaml or rerun the install command with the updated --proxy value.

Summary

  • Agent Reach routes Bilibili requests through yt-dlp, and you can proxy those requests by setting bilibili_proxy.
  • The channel defined in agent_reach/channels/bilibili.py checks the config key first, then falls back to the BILIBILI_PROXY environment variable.
  • Use the CLI --proxy flag during installation, edit the YAML config directly, or export the environment variable to inject the proxy.
  • Run python -m agent_reach.cli doctor to confirm the channel sees 视频读取:yt-dlp(代理已配置).

Frequently Asked Questions

Is the proxy setting shared across all Agent Reach channels?

No. The bilibili_proxy config key and BILIBILI_PROXY environment variable are consumed exclusively in agent_reach/channels/bilibili.py. Other channels may implement separate proxy logic.

What URL format does the proxy value require?

Provide a full URI that yt-dlp recognizes, typically http://user:pass@host:port. The string is passed directly to yt-dlp by the Bilibili channel without transformation.

Can I override the config file proxy with an environment variable?

Only when the config key is absent. Because the channel uses config.get("bilibili_proxy") or os.environ.get("BILIBILI_PROXY"), a saved config value takes precedence. Unset the config key if you want the environment variable to control the proxy.

Where does the CLI store the --proxy value?

The install command in agent_reach/cli.py writes the flag value to the centralized config object via config.set, which agent_reach/config.py persists into the local YAML store at ~/.config/agent_reach/config.yaml.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →