Gemma 4 E2B Local LLM
FastAPI proxy phục vụ inference qua vLLM backend. Model Google Gemma 4 E2B (Experience-Based), AWQ 4-bit quantized. Chạy trên RTX 3060 12GB, chia sẻ GPU với Qwen service.
Hoạt động
Updated 2026-05
Thờng tin nổi bật:
Gemma 4 E2B (Experience-Based) — thế hệ mới nhất Google Gemma 4. Hỗ trợ Thinking Mode (enable_thinking=true). AWQ 4-bit quantization.
~50
Tốc độ (tokens/s)
4.5B
Parameters (AWQ-4bit)
128K
Context Window
<1s
Latency (first token)
Base URL
https://pnt.badt.vn/gemma4/
Lưu ý: Base URL là
/gemma4/ (có số 4), không phải /gemma hay /gemma4b/.
Authentication
Tất cả request yêu cầu Bearer token:
Authorization: Bearer <API_AI_TOKEN>
Token quản lý qua DB api_ai_main.api_tokens (MySQL 192.168.1.244). Hết hạn/sai token nhận HTTP 403.
API Endpoints
POST
/gemma4/v1/chat/completions
OpenAI Compatible
Recommended
Chat completion tương thích OpenAI format.
Parameters
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
| messages | array | Yes | — | {role, content} với role: system/user/assistant |
| model | string | No | auto | Bỏ qua, proxy tự detect |
| temperature | float | No | 0.7 | 0.0 - 2.0 |
| max_tokens | int | No | 1024 | 1 - 8192, tự động giảm nếu context đầy |
| top_p | float | No | 0.9 | Nucleus sampling 0.0 - 1.0 |
| top_k | int | No | 40 | Top-K (-1 = tắt) |
| stream | bool | No | false | Luôn false, chưa hỗ trợ streaming |
| enable_thinking | bool | No | false | Bật Thinking Mode |
Ví dụ cURL
curl -X POST "https://pnt.badt.vn/gemma4/v1/chat/completions" \
-H "Authorization: Bearer $API_AI_TOKEN" \
-H "Content-Type: application/json" \
-d "{
"messages": [{"role":"user","content":"Hello"}],
"temperature": 0.7,
"max_tokens": 1024
}"
POST
/gemma4/chat
Legacy
Nhận prompt string thay vì messages array.
Parameters
| Param | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | Yes | — | Input text (min 1 ký tự) |
| system_prompt | string | No | null | System instruction |
| temperature | float | No | 0.7 | 0.0 - 2.0 |
| max_tokens | int | No | 1024 | 1 - 8192 |
| enable_thinking | bool | No | false | Bật Thinking Mode |
Response
{"response":"...","model":"google/gemma-4-e2b-it","usage":{...}}
GET
/gemma4/health
Utility
Health check. Cũng có thể gọi tại /health.
ANY
/*
Error
Endpoint không tồn tại trả về hướng dẫn.
Mã lỗi
| Status | Ý nghĩa | Xử lý |
|---|---|---|
| 401 | Unauthorized | Thiếu Authorization header |
| 403 | Forbidden | Token sai/hết hạn/không có quyền gemma4 |
| 422 | Validation Error | Sai schema request body |
| 502 | Bad Gateway | vLLM chưa sẵn sàng |
| 504 | Gateway Timeout | vLLM inference quá lâu |
Thông số kỹ thuật
ModelGoogle Gemma 4 E2B AWQ 4-bit
vLLM name
google/gemma-4-e2b-itParameters~4.5B (AWQ)
Context128K (config 4096)
vLLM Port8092
FastAPI Port8044
GPUCVD=2 RTX 3060 12GB (shared qwen)
AuthBearer token MySQL api_ai_main