Learn how to configure and use proxies with the G4F library
G4F_PROXY
environment variable. This can be useful if you want to hide or change your IP address for the providers.To set the proxy environment variable, run the following command in your terminal:http://host:port
with the actual proxy URL and port you want to use.Client
instance, you can pass the proxies
parameter to specify the proxy settings.proxies
parameter accepts a dictionary with the following keys:"all"
: Specifies the proxy URL for all requests."https"
: Specifies the proxy URL for HTTPS requests only."all"
and "https"
are provided, the "https"
proxy will be used for HTTPS requests, and the "all"
proxy will be used for other requests.get_proxy()
method of the Client
instance.proxies
parameter or the G4F_PROXY
environment variable. If no proxy is configured, it will return None
.client.chat.completions.create()
, and the requests will be routed through the specified proxy.