Hướng dẫn nhanh để bắt đầu sử dụng các AI services trong vài phút
Chỉ với 3 bước đơn giản, bạn có thể bắt đầu sử dụng API ngay lập tức:
Truy cập trang chủ và kiểm tra phần "Real-time Service Status" để đảm bảo các services bạn cần đang online.
Xem StatusChọn service phù hợp với nhu cầu của bạn và đọc tài liệu API:
Sử dụng code example trong documentation để gửi request thử nghiệm.
Cài đặt các thư viện cần thiết cho ngôn ngữ lập trình bạn sử dụng:
pip install requests
npm install axios form-data
PHP có sẵn cURL, không cần cài đặt thêm. Đảm bảo extension curl được enable:
php -m | grep curl
Ví dụ request đầu tiên với Medical Transcribe API:
📌 LƯU Ý: Services CẦN API token! Liên hệ admin hoặc xem Authentication Guide
import requests
import os
# ===== BƯỚC 0: LẤY API TOKEN =====
# QUAN TRỌNG: Hầu hết services CẦN token!
API_TOKEN = os.getenv('API_AI_TOKEN')
# Hoặc: API_TOKEN = "demo_token_12345_for_testing_only"
if not API_TOKEN:
print("⚠️ Cảnh báo: Chưa set API_TOKEN! Một số services sẽ trả về 401.")
print("👉 Liên hệ admin để lấy token hoặc xem: authentication.php")
# ===== BƯỚC 1: KIỂM TRA SERVICE HEALTH =====
# Health endpoint thường KHÔNG cần token
health_url = "https://pnt.badt.vn/medical_transcribe/health"
health_response = requests.get(health_url)
print(f"✅ Service status: {health_response.json()['status']}")
# ===== BƯỚC 2: TRANSCRIBE AUDIO VỚI TOKEN =====
transcribe_url = "https://pnt.badt.vn/medical_transcribe/transcribe"
# Token PHẢI đi kèm trong header
headers = {'Authorization': f'Bearer {API_TOKEN}'} if API_TOKEN else {}
with open("audio.wav", "rb") as f:
files = {"audio_file": f}
data = {"language": "vi", "task": "transcribe"}
response = requests.post(
transcribe_url,
headers=headers, # ← Token ở đây!
files=files,
data=data
)
if response.status_code == 401:
print("❌ Error 401: Token không hợp lệ hoặc chưa cung cấp!")
print("👉 Lấy token tại: admin/tokens.php")
elif response.status_code == 403:
print("❌ Error 403: Token hết hạn hoặc không có quyền!")
elif response.status_code == 200:
result = response.json()
if result["success"]:
print(f"✅ Transcription: {result['transcription']}")
print(f"⏱️ Processing time: {result['processing_time']:.2f}s")
else:
print(f"⚠️ Error: {result['error']}")
else:
print(f"⚠️ HTTP {response.status_code}: {response.text}")
# Output với token hợp lệ:
# ✅ Service status: healthy
# ✅ Transcription: Bệnh nhân có triệu chứng đau đầu và sốt cao
# ⏱️ Processing time: 1.23s
⚠️ QUAN TRỌNG: Hầu hết các services CẦN API token! Xem Authentication Guide
# 1. Kiểm tra health (không cần token) curl https://pnt.badt.vn/medical_transcribe/health # 2. Set API token (Liên hệ admin để lấy token) export API_TOKEN="your_api_token_here" # 3. Transcribe audio VỚI TOKEN curl -X POST "https://pnt.badt.vn/medical_transcribe/transcribe" \ -H "Authorization: Bearer $API_TOKEN" \ -F "audio_file=@audio.wav" \ -F "language=vi" \ -F "task=transcribe" # Ví dụ với demo token (chỉ dùng testing): curl -X POST "https://pnt.badt.vn/medical_transcribe/transcribe" \ -H "Authorization: Bearer demo_token_12345_for_testing_only" \ -F "audio_file=@audio.wav" \ -F "language=vi" \ -F "task=transcribe"
| Service | Base URL | FastAPI Docs |
|---|---|---|
| Medical Transcribe | https://pnt.badt.vn/medical_transcribe |
docs |
| Face Recognition | https://pnt.badt.vn/face_recognition |
docs |
| Vistral Vietnamese | https://pnt.badt.vn/vistral |
docs |
| DeepSeek OCR | http://localhost:8040 |
docs |
| Dashboard | https://pnt.badt.vn/dashboard |
docs |
| Medical Patient Simulator | https://pnt.badt.vn/virtualpatient |
docs |
| MCP Backend | https://pnt.badt.vn/mcp |
docs |
Giải pháp: Kiểm tra service status ở trang chủ, xem logs tại /path/to/service/logs/