tutorialdeepseekchatbotvietnamese
Build a Vietnamese Chatbot with DeepSeek V4 Pro in 10 Lines
June 8, 2026 · 6 min read
DeepSeek V4 Pro handles Vietnamese natively — better than most Western models. Build a Vietnamese chatbot in 10 lines of Python that streams responses, remembers context, and costs sh.28 per million tokens.
Prerequisites
- A NexAPI account (register free, sh.10 bonus)
- An API key from your Dashboard
- Python 3.8+ with
openaipackage installed
Step 1: Install and Configure
$ pip install openai
Step 2: The 10-Line Chatbot
from openai import OpenAI
client = OpenAI(
base_url="https://nex-api.tech/v1",
api_key="napi-YOUR_KEY"
)
messages = [{"role":"system","content":"Bạn là trợ lý AI, trả lời bằng tiếng Việt."}]
while True:
msg = input("👤 ")
messages.append({"role":"user","content":msg})
stream = client.chat.completions.create(
model="deepseek-v4-pro", messages=messages, stream=True
)
print("🤖 ", end="")
reply = ""
for chunk in stream:
token = chunk.choices[0].delta.content or ""
print(token, end="", flush=True)
reply += token
print()
messages.append({"role":"assistant","content":reply})How It Works
- System prompt in Vietnamese — tells the model to respond in Vietnamese
- Conversation memory — each message appended to array
- Streaming output — responses appear word-by-word like ChatGPT
- Zero code changes — identical to OpenAI SDK, just different base_url
Vietnamese Language Quality
DeepSeek V4 Pro handles Vietnamese surprisingly well — better than GPT-4o-mini on many benchmarks. It understands natural conversation with proper tones, code-switching (Vietnamese + English), cultural context, and nuanced sentiment.
Cost Comparison
| Provider | Per Convo | 10K Conv/d |
|---|---|---|
| GPT-4o | sh.002 | 0 |
| DeepSeek V4 Pro | sh.00024 | .40 |