← Back to Blog
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 openai package 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

  1. System prompt in Vietnamese — tells the model to respond in Vietnamese
  2. Conversation memory — each message appended to array
  3. Streaming output — responses appear word-by-word like ChatGPT
  4. 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

ProviderPer Convo10K Conv/d
GPT-4osh.0020
DeepSeek V4 Prosh.00024.40

Ready to build?

Free sh.10 credit. No credit card. Vietnamese-ready.

Start Building →