Yes — you can absolutely interact with ChatGPT (or GPT-5 in this case) from a remote server via the command line, but you’ll need to go through the OpenAI API (or an API-compatible service) rather than the web chat UI.
Here’s the high-level process:
1. Get API Access
- Sign up at OpenAI (if you don’t have an API key yet).
- Go to View API keys in your account settings.
- Copy your API key — you’ll use it for authentication.
2. Install Required Tools
On your remote server (Linux, macOS, or WSL), you can install the OpenAI Python package or just use curl
.
Option A — Python (Recommended)
pip install openai
Option B — Using curl
(no extra install needed, just basic shell)
3. Example — Command Line via curl
curl https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "gpt-5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello from my remote server!"}
]
}'
4. Example — Python Script
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY")
response = client.chat.completions.create(
model="gpt-5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello from my remote server!"}
]
)
print(response.choices[0].message["content"])
5. Bonus — Make It an Interactive CLI Chat
You could create a small script like:
from openai import OpenAI
import os
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
while True:
prompt = input("You: ")
if prompt.lower() in ["exit", "quit"]:
break
response = client.chat.completions.create(
model="gpt-5",
messages=[{"role": "user", "content": prompt}]
)
print("GPT:", response.choices[0].message["content"])
Run it:
export OPENAI_API_KEY="your_api_key_here"
python cli_chat.py
You’ll get an interactive terminal chat with GPT-5 from your remote server.
If you want, I can also give you a ready-to-use Bash-only one-liner that lets you talk to ChatGPT in the terminal without Python at all. That’s handy for quick server interactions.
Do you want me to prepare that one-liner version?