If you are used to using AI Agents, you might be familiar with 9Router, an AI proxy router with auto-fallback from expensive providers to free ones. By installing 9Router on a VPS, you can use or access this proxy router from anywhere, on any device.
How to Install 9Router on a VPS with Docker
For installation, you can actually use NPM+PM2 or you can also use Docker. In this tutorial, we will use Docker.
1. Install Docker
First, check whether Docker is already installed or not
docker --versionIf it is not installed, you can install it first
curl -fsSL https://get.docker.com | shor if you are using RHEL and its derivatives, you can install it with this command
dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repodnf install -y docker-ce docker-ce-cli containerd.iosystemctl enable --now docker2. Run 9Router in Docker
If Docker is already installed, you can download and run 9Router with Docker
docker run -d \ --name 9router \ -p 20128:20128 \ -v "$HOME/.9router:/app/data" \ -e DATA_DIR=/app/data \ -e JWT_SECRET="ganti-dengan-secret-random-panjang" \ -e INITIAL_PASSWORD="password-dashboard-kamu" \ decolua/9router:latestMake sure to change replace-with-a-long-random-secret and your-dashboard-password with the key or password you will use later. You must remember this password, as it will be used to log in to the 9Router dashboard.
3. Check Container
Make sure the Docker container is running before you access the 9Router dashboard
docker logs -f 9routerIf you are also using a firewall like UFW, make sure to allow the port 20128
ufw allow 20128For auto-start when the server restarts, you can run this command
docker update --restart unless-stopped 9router4. Access the 9Router Dashboard
Now you can access the 9Router dashboard. For example, if your server IP is 45.76.180.111, then you can access http://45.76.180.111:20128. If you want to set up access via a domain, you can configure a reverse proxy with Nginx by following this tutorial: How to Configure a Reverse Proxy with Nginx
5. Add an AI Provider
If you have successfully logged in, you can add an AI Provider, for example OpenRouter which provides an API Key with several free models.
To add an AI Provider, you can open the menu Providers > OpenRouter > Add
Also, make sure to add an Available model so that the available models can be used
6. Create a Combo
To make model selection easier, for example if you have many models, you can create a new Combo, for example with the name wpgan-ai from the menu Combos > Create Combo and add the models you have already added
7. Create an API Key
You can create an API Key from the menu Endpoint > Create Key, where this Key will be used later when you connect 9Router to your application
8. Use 9Router for Coding
Now you can use 9Router for coding. For example, if you use applications like VSCode, Antigravity, JetBrains, Cursor, and the like, you can install the extension cline.
Configure the AI by selecting the option Bring my own API key or BYOK, then configure it like this:
- API Provider: OpenAI Compatible
- Base URL: http://45.76.180.111:20128/v1 (change 45.76.180.111 with your server IP address, or domain name if you have already set up a reverse proxy)
- OpenAI Compatible API Key: The API Key you created in Endpoint
- Model ID: The name of the combo you created, for example wpgan-ai
Once connected, you can try running commands to continue your coding session, or it can also be connected to your applications that require an AI API.
That is how to install 9Router on a VPS and how to use it, so that you can later combine various types of AI into one API Key.
COMMENTS
Loading...