Guides
Using Routstr via Tor
How to use Routstr using our Tor endpoint instead of api.routstr.com
To use Routstr’s API securely and anonymously via Tor, you need to first ensure that you have a Tor client running on your local machine. This will allow you to route your network traffic through the Tor network.
Once your Tor client is running (typically on localhost:9050
for SOCKS5 proxy), you can configure your API client to use Routstr’s onion service endpoint and route requests through your local Tor proxy.
Here’s an example using the Python OpenAI client:
Explanation of the Code
import httpx
: Thehttpx
library is used as the underlying HTTP client foropenai-python
. It allows for advanced configurations like proxy settings.base_url
: This is set to Routstr’s onion service address (http://mcfftxiqtpwvrsly4ue6fgc6nvo637emrofmnftitn3frmf55frcleid.onion/v1
). Ensure you use the correct and current onion address.http_client=httpx.Client(...)
: Anhttpx.Client
instance is passed to theOpenAI
client.proxies={"http://": "socks5://localhost:9050"}
: This crucial line configureshttpx
to route all HTTP traffic through the SOCKS5 proxy running onlocalhost:9050
, which is the default for many Tor clients.
Prerequisites
- Install Tor: Download and install the Tor Browser or a standalone Tor client for your operating system. For detailed installation instructions on Linux, refer to this guide.
- Run Tor: Ensure your Tor client is running and configured to provide a SOCKS5 proxy on
localhost:9050
.
By following these steps, you can leverage the anonymity and security benefits of the Tor network when interacting with Routstr’s API.