To run an AI chatbot, Telegram or Discord AI bot, or an app that calls an AI API from Japan or Korea, set up a Python virtual environment on a Tokyo or Seoul VPS, keep the API key in a protected environment file, and run the app as a systemd service. This guide shows each step with a minimal example.
Step 1: Choose a server
JUSTG cloud VPS in Tokyo and Seoul come with a native Japanese or Korean IPv4, free IPv6, Asia-optimized routes and a 500 Mbps port. They are deployed automatically after payment.
These are CPU servers with no GPU. They are a good fit for calling hosted AI APIs, chatbots, AI agents, automation jobs and RAG backends that use a hosted model, but not for training models. A bot that mostly waits for API replies needs little CPU, so plan 01 (2 cores, 1 GB RAM, $29.99/mo) or 02 (3 cores, 2 GB RAM, $39.99/mo) is a common starting point; choose more RAM if you also run a database or vector search on the same server.
Step 2: Install Python and create a virtual environment
On Debian or Ubuntu, create a dedicated user and a virtual environment in /opt/aibot, then install your provider's official SDK. This example uses the openai Python package; other providers' SDKs install the same way.
apt update && apt install -y python3 python3-venv
useradd -r -m -d /opt/aibot -s /usr/sbin/nologin aibot
python3 -m venv /opt/aibot/venv
/opt/aibot/venv/bin/pip install --upgrade pip
/opt/aibot/venv/bin/pip install openai
Step 3: Store the API key in an environment file
Never put the API key in your code or in a Git repository. Create /etc/aibot.env:
AI_API_KEY=your-api-key
AI_MODEL=your-model-name
Replace the values with your real key and the model name from your provider's documentation. Then make the file readable by root only:
chown root:root /etc/aibot.env
chmod 600 /etc/aibot.env
ls -l /etc/aibot.env
The output should start with -rw-------. systemd reads the file as root when it starts the service, so the bot user does not need to read it directly.
Step 4: Write a minimal test app
Create /opt/aibot/app.py. It sends one message and prints the reply:
import logging
import os
from openai import OpenAI
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")
log = logging.getLogger("aibot")
client = OpenAI(api_key=os.environ["AI_API_KEY"], max_retries=3, timeout=30)
resp = client.chat.completions.create(
model=os.environ["AI_MODEL"],
messages=[{"role": "user", "content": "Hello from Tokyo"}],
)
log.info("reply received")
print(resp.choices[0].message.content)
Other SDKs follow the same pattern: create a client with the key from the environment, then call the provider's chat or messages method (for example client.messages.create(...)). Run the test once as root:
chown -R aibot:aibot /opt/aibot
set -a; . /etc/aibot.env; set +a
/opt/aibot/venv/bin/python /opt/aibot/app.py
If you see a reply, the key, the SDK and the network path all work.
Step 5: Run your bot as a systemd service
Put your real bot or API app in /opt/aibot/bot.py (a long-running program, for example a Telegram bot or a small web API), then create /etc/systemd/system/aibot.service:
[Unit]
Description=AI bot
After=network-online.target
Wants=network-online.target
[Service]
User=aibot
WorkingDirectory=/opt/aibot
EnvironmentFile=/etc/aibot.env
ExecStart=/opt/aibot/venv/bin/python /opt/aibot/bot.py
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable --now aibot
systemctl status aibot
The service starts on boot and restarts automatically after a crash. If your app receives webhooks or serves a web API, open only the ports it needs:
apt install -y ufw
ufw allow OpenSSH
ufw allow 443/tcp
ufw enable
Step 6: Logging
Anything your app writes to standard output or through Python logging goes to the systemd journal:
journalctl -u aibot -f
journalctl -u aibot --since "1 hour ago"
Log request status, errors and timings, but do not log API keys, and avoid logging full user messages unless you really need them and your privacy policy allows it.
Step 7: Handle rate limits and costs
- Retry with backoff: when the API returns a rate-limit error (HTTP 429) or a temporary error, wait and retry with increasing delays. The official SDKs can do this for you (
max_retriesin the example above). - Set timeouts: a timeout keeps one slow request from blocking your bot.
- Limit your own users: cap requests per user per minute in your bot, so one user cannot use up your quota.
- Set spending limits: use the usage and budget settings in your AI provider's dashboard.
FAQ
Can I run a large AI model locally on this VPS?
These are CPU servers without GPUs, so they are not suited to training or to running large models locally. They work well for apps, bots and agents that call hosted AI APIs.
Is Japan or Korea a supported region for AI APIs?
Japan and Korea are supported regions for major AI providers such as OpenAI, Anthropic and Google Gemini, but each provider decides its own rules. Always check the provider's current supported-regions list and terms.
Can I try the server before buying?
Yes. Open a ticket to request a test server and run the test app from Step 4 on it.