# How to Configure Proxy Settings in GPT Academic: A Complete Guide

> Learn to configure proxy settings in GPT Academic easily. Update config.py or use environment variables for seamless proxy integration.

- Repository: [binary-husky/gpt_academic](https://github.com/binary-husky/gpt_academic)
- Tags: how-to-guide
- Published: 2026-03-02

---

**Set `USE_PROXY = True` in [`config.py`](https://github.com/binary-husky/gpt_academic/blob/main/config.py) and define your proxy URLs in the `proxies` dictionary, or override via environment variables `HTTP_PROXY` and `HTTPS_PROXY` before launching the application.**

GPT Academic (binary-husky/gpt_academic) routes all LLM API traffic through configurable proxy servers to ensure connectivity behind corporate firewalls or in restricted networks. This guide explains how to configure proxy settings in GPT Academic using the configuration file, environment variables, and runtime overrides while referencing the actual source implementation.

## Understanding Proxy Configuration Priority

GPT Academic reads proxy settings through three mechanisms in order of priority:

1. **Environment variables** (`HTTP_PROXY`, `HTTPS_PROXY`, `ALL_PROXY`, `no_proxy`) — highest priority
2. **[`config_private.py`](https://github.com/binary-husky/gpt_academic/blob/main/config_private.py)** — overrides defaults if present  
3. **Static values in [`config.py`](https://github.com/binary-husky/gpt_academic/blob/main/config.py)** — default configuration location

The `toolbox.ProxyManager` class (lines 842-865 in [`toolbox.py`](https://github.com/binary-husky/gpt_academic/blob/main/toolbox.py)) manages these settings at runtime, cleaning up stray environment variables to prevent proxy leakage to subprocesses.

## Step-by-Step: Configure Proxy in config.py

### Enable Proxy Usage

Locate [`config.py`](https://github.com/binary-husky/gpt_academic/blob/main/config.py) in the repository root and set the enable flag:

```python

# config.py lines 20-22

USE_PROXY = True

```

If `USE_PROXY` remains `False`, the application ignores any proxy definitions and issues a warning during startup, as handled by [`shared_utils/config_loader.py`](https://github.com/binary-husky/gpt_academic/blob/main/shared_utils/config_loader.py) (lines 93-97).

### Define Proxy URLs

Configure the `proxies` dictionary with your specific proxy protocol and address:

```python

# config.py lines 30-34

proxies = {
    "http": "socks5h://127.0.0.1:1080",
    "https": "socks5h://127.0.0.1:1080",
}

```

Supported protocols include `http`, `https`, and `socks5h`. The `socks5h` variant ensures DNS resolution occurs through the proxy rather than locally.

## Override Proxy Settings via Environment Variables

For temporary configurations or containerized deployments, set environment variables before launching GPT Academic:

```bash
export HTTP_PROXY="http://127.0.0.1:7890"
export HTTPS_PROXY="http://127.0.0.1:7890"
export no_proxy="*"
python main.py

```

The `no_proxy="*"` setting prevents local addresses from routing through the proxy, protecting internal API calls. Note that [`main.py`](https://github.com/binary-husky/gpt_academic/blob/main/main.py) explicitly sets `no_proxy='*'` early in execution to safeguard internal communications.

## Verifying Your Proxy Configuration

### Using the Built-in Checker

GPT Academic includes [`check_proxy.py`](https://github.com/binary-husky/gpt_academic/blob/main/check_proxy.py) to validate connectivity:

```python
from check_proxy import check_proxy

proxies = {"http": "socks5h://localhost:11284", "https": "socks5h://localhost:11284"}
ip = check_proxy(proxies, return_ip=True)
print(f"Proxy active. External IP: {ip}")

```

This function (lines 3-9 and 296-299 in [`check_proxy.py`](https://github.com/binary-husky/gpt_academic/blob/main/check_proxy.py)) returns the public IP address as seen by the proxy server, confirming successful routing.

### Runtime Verification

Upon startup, GPT Academic logs the effective proxy configuration with the tag `[PROXY]`. Check the console output or logs to confirm the system recognizes your settings.

## How Proxy Settings Are Applied in the Source Code

Understanding the internal flow helps troubleshoot configuration issues:

1. **Configuration Loading**: [`shared_utils/config_loader.py`](https://github.com/binary-husky/gpt_academic/blob/main/shared_utils/config_loader.py) caches the `USE_PROXY` flag and `proxies` dictionary (lines 93-97). If disabled, it logs a warning and ignores proxy definitions.

2. **Request Routing**: LLM bridge modules like [`request_llms/bridge_chatgpt.py`](https://github.com/binary-husky/gpt_academic/blob/main/request_llms/bridge_chatgpt.py) (lines 26-31) consume the `proxies` dict when initializing HTTP clients, unless `disable_proxy=True` is passed.

3. **Environment Management**: `toolbox.ProxyManager` (lines 842-865 in [`toolbox.py`](https://github.com/binary-husky/gpt_academic/blob/main/toolbox.py)) sets and removes `HTTP_PROXY`/`HTTPS_PROXY` environment variables around each request to prevent subprocess pollution.

4. **Special Adapters**: Some modules like [`edge_gpt_free.py`](https://github.com/binary-husky/gpt_academic/blob/main/edge_gpt_free.py) (lines 313-321) check additional variables including `ALL_PROXY` and `BING_PROXY_URL` for specific service requirements.

## Summary

- **Enable proxies** by setting `USE_PROXY = True` in [`config.py`](https://github.com/binary-husky/gpt_academic/blob/main/config.py) (lines 20-22).
- **Define endpoints** in the `proxies` dictionary with protocol-specific URLs (lines 30-34).
- **Override temporarily** using `HTTP_PROXY` and `HTTPS_PROXY` environment variables.
- **Verify functionality** with [`check_proxy.py`](https://github.com/binary-husky/gpt_academic/blob/main/check_proxy.py) or by checking startup logs for `[PROXY]` entries.
- **Understand internals**: [`config_loader.py`](https://github.com/binary-husky/gpt_academic/blob/main/config_loader.py) handles caching, `toolbox.ProxyManager` manages environment variables, and bridge modules apply settings per-request.

## Frequently Asked Questions

### How do I disable the proxy after enabling it?

Set `USE_PROXY = False` in [`config.py`](https://github.com/binary-husky/gpt_academic/blob/main/config.py) and restart the application. Alternatively, set the environment variable `no_proxy="*"` before launching to disable proxy routing for that session without modifying configuration files.

### Why is GPT Academic ignoring my proxy settings?

Check that `USE_PROXY` is set to `True` in [`config.py`](https://github.com/binary-husky/gpt_academic/blob/main/config.py) (not [`config_private.py`](https://github.com/binary-husky/gpt_academic/blob/main/config_private.py) unless you intend to override). Also verify that environment variables like `HTTP_PROXY` aren't set to conflicting values, as these take precedence over file-based configuration according to the priority rules in [`toolbox.py`](https://github.com/binary-husky/gpt_academic/blob/main/toolbox.py).

### Can I use different proxies for HTTP and HTTPS traffic?

Yes. The `proxies` dictionary in [`config.py`](https://github.com/binary-husky/gpt_academic/blob/main/config.py) supports separate entries for `"http"` and `"https"` keys. You can route HTTP requests through one proxy and HTTPS requests through another by specifying different URLs for each key.

### What proxy protocols are supported?

GPT Academic supports standard `http` and `https` proxies, as well as `socks5` and `socks5h` (the latter routes DNS queries through the proxy). Some specialized modules like [`edge_gpt_free.py`](https://github.com/binary-husky/gpt_academic/blob/main/edge_gpt_free.py) also respect `ALL_PROXY` and `BING_PROXY_URL` environment variables for specific service integrations.