1. Install the small helper program
Install Python 3.11 or newer, then make an empty folder. Open a terminal in that folder
(PowerShell on Windows). Use the commands for your computer below. They install the tools that talk to the model;
the model itself stays on the provider’s servers.
Windows — PowerShell commands
py -m venv .venv
.venv\Scripts\python -m pip install --upgrade openai
Mac or Linux — terminal commands
python3 -m venv .venv
.venv/bin/python -m pip install --upgrade openai
2. Save this as hello.py
Use a plain-text editor. Save it in the same folder, with .py at the end, not .txt.
from getpass import getpass
from openai import OpenAI
client = OpenAI(api_key=getpass("Paste your API key (hidden): "), base_url="https://api.deepseek.com")
reply = client.chat.completions.create(
model="deepseek-flash",
messages=[{"role": "user", "content": "Say hello in one short sentence."}],
)
print(reply.choices[0].message.content)
3. Run it and look for a reply
On Windows:
.venv\Scripts\python hello.py
On Mac or Linux:
.venv/bin/python hello.py
Paste your provider’s API key when asked and press Enter. It stays hidden as you type.
A short greeting means the connection works. Keep the key private; it lets programs use your account.
If it fails, check your account’s credit and model access, then use the provider’s setup guide below.
The example is adapted from their documentation.