Browserbase offers a flexible proxy system, enabling you to control how your automation traffic is routed across the internet. Whether you need anonymity, geolocation control, or improved reliability, Browserbase makes it easy to integrate proxies into your workflows.
Set the geolocation of the proxy to a specific country, state, and city. This is useful if you need to proxy traffic to a specific location. If there is no proxy in the specified location, the closest proxy will be used.
Browserbase supports custom proxy configurations, allowing you to route traffic through your own HTTP or HTTPS proxies. This is useful if you need to enforce specific network routing rules, comply with security policies, or optimize performance with a preferred proxy provider.
To configure a custom proxy, provide the proxy server URL and authentication details when creating a session.
Browserbase validates proxy connections at session creation time. If we are unable to connect to the specified proxy, an error will be thrown. Ensure that your proxy server is accessible and the provided credentials are correct before creating a session.
Combine multiple proxies and define routing rules based on domain patterns. This is particularly useful when different websites require different proxies, such as routing government-related sites through one proxy while using another for general browsing.
Proxies are applied in the order they are listed, meaning the first matching rule is used for each request. If no rule matches a domain pattern, you can use the browserbase proxy type to fall back to Browserbase’s default proxies.
import{ Browserbase }from"@browserbasehq/sdk";const bb =newBrowserbase({ apiKey: process.env.BROWSERBASE_API_KEY!});asyncfunctioncreateSessionWithRouting(){const session =await bb.sessions.create({ projectId: process.env.BROWSERBASE_PROJECT_ID!, proxies:[// Use an external proxy for wikipedia.org{"type":"external","server":"http://...","username":"user","password":"pass","domainPattern":"wikipedia\.org"},// Use an external proxy for all other .gov domains{"type":"external","server":"http://...","username":"user","password":"pass","domainPattern":".*\.gov"},// Use the Browserbase proxies for all other domains// Excluding this line will not use a proxy on any other domains{"type":"browserbase"}]});return session;}const session =createSessionWithRouting()console.log("Session URL: https://browserbase.com/sessions/"+ session.id)
import{ Browserbase }from"@browserbasehq/sdk";const bb =newBrowserbase({ apiKey: process.env.BROWSERBASE_API_KEY!});asyncfunctioncreateSessionWithRouting(){const session =await bb.sessions.create({ projectId: process.env.BROWSERBASE_PROJECT_ID!, proxies:[// Use an external proxy for wikipedia.org{"type":"external","server":"http://...","username":"user","password":"pass","domainPattern":"wikipedia\.org"},// Use an external proxy for all other .gov domains{"type":"external","server":"http://...","username":"user","password":"pass","domainPattern":".*\.gov"},// Use the Browserbase proxies for all other domains// Excluding this line will not use a proxy on any other domains{"type":"browserbase"}]});return session;}const session =createSessionWithRouting()console.log("Session URL: https://browserbase.com/sessions/"+ session.id)
from browserbase import Browserbaseimport osbb = Browserbase(api_key=os.environ["BROWSERBASE_API_KEY"])defcreate_session_with_routing(): session = bb.sessions.create( project_id=os.environ["BROWSERBASE_PROJECT_ID"], proxies=[# Use an external proxy for wikipedia.org{"type":"external","server":"http://...","username":"user","password":"pass","domainPattern":"wikipedia\.org"},# Use an external proxy for all other .gov domains{"type":"external","server":"http://...","username":"user","password":"pass","domainPattern":".*\.gov"},# Use the Browserbase proxies for all other domains# Excluding this line will not use a proxy on any other domains{"type":"browserbase"}])print("Session URL: https://browserbase.com/sessions/"+ session.id)return sessionsession = create_session_with_routing()
Proxy usage is measured by the total amount of data transferred through the proxy. This includes:
Webpage content, downloads, and media files
HTTP headers, authentication data, and encryption overhead
Any requests and responses routed through the proxy
Since all traffic must pass through the proxy server before reaching its final destination, every interaction contributes to your total bandwidth usage.