Key takeaway
Make one small request with a dedicated Python environment, then check authentication, balance, and the response before building a larger workflow.
On this page
Want to use DeepSeek inside your own application? Start with one small request before connecting a coding agent or uploading a document. This keeps setup problems separate from questions about answer quality.
Verification note: Based on official documentation checked October 31, 2026. The API example has not been executed against a live account.
What you need
You will need Python 3, a terminal, and an API key from the official DeepSeek platform. Confirm your account can make billable requests before continuing. This guide does not verify country-specific registration or payment availability.
DeepSeek’s current documentation uses https://api.deepseek.com for its OpenAI-compatible endpoint and lists deepseek-flash as a model identifier. Older tutorials may use different names; check the current API reference rather than substituting a product name from a headline.
Prepare a small Python project
In a macOS or Linux terminal:
mkdir deepseek-first-request
cd deepseek-first-request
python3 -m venv .venv
source .venv/bin/activate
python -m pip install openai
For Windows PowerShell, use the environment’s Python directly, without activating a script:
mkdir deepseek-first-request
cd deepseek-first-request
py -3 -m venv .venv
.\.venv\Scripts\python.exe -m pip install openai
If python3 or py is unavailable, install Python 3 before continuing. Save the file below inside deepseek-first-request, not inside .venv.
Send your first request
The script reads DEEPSEEK_API_KEY if already set. Otherwise, it asks for your key without displaying what you type. Keep the real key outside source files and screenshots:
# Save as first_request.py
import getpass
import os
from openai import OpenAI
key = os.environ.get("DEEPSEEK_API_KEY") or getpass.getpass("DeepSeek API key: ")
if not key.strip():
raise SystemExit("No API key provided.")
client = OpenAI(api_key=key, base_url="https://api.deepseek.com")
response = client.chat.completions.create(
model="deepseek-flash",
messages=[{
"role": "user",
"content": "Write a two-sentence welcome email for a pottery class."
}],
stream=False,
)
print(response.choices[0].message.content)
On macOS or Linux, with the environment still activated, run python first_request.py. On Windows PowerShell, run .\.venv\Scripts\python.exe first_request.py.
A successful run should print the model’s answer to the welcome-email request. Wording will vary. Check that it contains two sentences and suits the intended audience; a completed request does not establish writing quality. This example uses your API account and may incur usage charges.
If the request fails
DeepSeek’s error reference distinguishes authentication failures (401), exhausted balance (402), invalid parameters (422), and request-rate limits (429). Check the reported cause before changing your prompt. Server errors such as 500 or 503 call for waiting and retrying, rather than repeatedly replacing credentials.
Before building something larger
Save the model identifier, date, task, and usage information from your own run. Repeat the same task with a few deliberately different inputs. A successful connection shows that authentication works; it does not establish reliability for a customer-facing workflow.
For a different approach, see running Qwen locally on a Mac. That uses local hardware instead of this hosted API.
Sources & references
Written by Modelrovia Editorial. Our standards distinguish official claims from observed results.
How we research and test →

