Tài liệu
Hướng dẫn dùng API
Gateway nói chuẩn OpenAI, nên mọi app/tool hỗ trợ OpenAI đều dùng được. Chỉ cần 3 thứ: Base URL, API key, tên model.
Bắt đầu
- Base URL
- API key
- Key riêng của bạn, dạng
sk-gw-…. Vào trang đăng nhập để xem và copy key cùng danh sách model được cấp. - Xác thực
- Gửi kèm header
Authorization: Bearer sk-gw-… - Model
Không chắc có model nào? Gọi GET /v1/models bằng key của bạn, hoặc xem ở trang tài khoản.
Endpoints
1. Danh sách model được phép
GET https://paktolamhocit.axiph.xyz/v1/models
Authorization: Bearer sk-gw-…
Trả về các model key của bạn được dùng, kèm thông tin: family, kind, caps (vision/tools/json), context_length, speed.tok_s, latency.p50_ms, latency.p95_ms, free.
2. Chat
POST https://paktolamhocit.axiph.xyz/v1/chat/completions
Authorization: Bearer sk-gw-…
Content-Type: application/json
- model
- Bắt buộc. Phải nằm trong danh sách model key của bạn.
- messages
- Bắt buộc. Mảng
[{"role": "user", "content": "..."}], role có thể làsystem/user/assistant. - stream
trueđể nhận dần từng chữ (SSE),falseđể nhận một lần. Mặc địnhfalse.- temperature, top_p, max_tokens
- Tuỳ chọn, giống OpenAI.
Ví dụ
cURL — chat thường
curl https://paktolamhocit.axiph.xyz/v1/chat/completions \
-H "Authorization: Bearer sk-gw-…" \
-H "Content-Type: application/json" \
-d '{
"model": "dungcsnd113/hy4-flash",
"messages": [{"role": "user", "content": "Xin chào"}],
"stream": false
}'
cURL — chat stream
curl -N https://paktolamhocit.axiph.xyz/v1/chat/completions \
-H "Authorization: Bearer sk-gw-…" \
-H "Content-Type: application/json" \
-d '{"model":"dungcsnd113/hy4-flash","messages":[{"role":"user","content":"Xin chào"}],"stream":true}'
Python (SDK OpenAI)
from openai import OpenAI
client = OpenAI(
base_url="https://paktolamhocit.axiph.xyz/v1",
api_key="sk-gw-…",
)
resp = client.chat.completions.create(
model="dungcsnd113/hy4-flash",
messages=[{"role": "user", "content": "Xin chào"}],
)
print(resp.choices[0].message.content)
JavaScript
const res = await fetch("https://paktolamhocit.axiph.xyz/v1/chat/completions", {
method: "POST",
headers: {
"Authorization": "Bearer sk-gw-…",
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "dungcsnd113/hy4-flash",
messages: [{ role: "user", content: "Xin chào" }],
}),
});
const data = await res.json();
console.log(data.choices[0].message.content);
Không muốn viết code?
Dùng bất kỳ app chat nào hỗ trợ OpenAI-compatible, điền 3 ô: Base URL https://paktolamhocit.axiph.xyz/v1, API key sk-gw-…, model là ID ở trên.
Nối vào app phổ biến
| App | Base URL / Endpoint | API key | Model |
|---|---|---|---|
| Cline / Roo (VS Code) | OpenAI Compatible → https://paktolamhocit.axiph.xyz/v1 | sk-gw-… | ID trong danh sách |
| Continue (VS Code) | https://paktolamhocit.axiph.xyz/v1 | sk-gw-… | ID trong danh sách |
| Cursor | Override OpenAI Base URL → https://paktolamhocit.axiph.xyz/v1 | sk-gw-… | ID trong danh sách |
| Open WebUI / LibreChat | https://paktolamhocit.axiph.xyz/v1 | sk-gw-… | ID trong danh sách |
| SillyTavern | Chat Completion → Custom OpenAI → https://paktolamhocit.axiph.xyz/v1 | sk-gw-… | ID trong danh sách |
Mọi app khác: cứ tìm ô "Base URL / API endpoint / Custom OpenAI" rồi điền như trên. App chỉ cần hỗ trợ chuẩn OpenAI là chạy.
Lỗi thường gặp
| Mã | Nghĩa | Cách xử |
|---|---|---|
| 401 | Thiếu hoặc sai API key | Kiểm tra key, phải có tiền tố Bearer |
| 403 | Key bị tắt, model không được cấp, hoặc model đang tắt | Xem lại danh sách model ở trang tài khoản |
| 429 | Hết hạn mức token hoặc gọi quá nhanh (vượt RPM) | Chờ một chút, hoặc xin admin nâng hạn mức |
| 502 / 503 | Lỗi phía nhà cung cấp model | Thử lại, đổi model khác, hoặc báo admin |
Lưu ý
- Không chia sẻ key. Ai có key là dùng hết hạn mức của bạn.
- Tên model phải khớp chính xác, kể cả phần trước dấu
/. - Model free không tính tiền; model khác tính theo giá ghi ở trang tài khoản.
- Danh sách model có thể thay đổi khi admin cập nhật — gọi lại
/v1/modelsđể lấy bản mới. - Với stream, nhớ đọc theo từng dòng
data:và dừng khi gặp[DONE].
Model miễn phí hiện có: dungcsnd113/hy4-flash, dungcsnd113/nemotron-3-ultra-550b, dungcsnd113/nemotron-3.5-super-vl, dungcsnd113/qwen4-35b-a3b-uncensored, dungcsnd113/subq-savant-1.4, pandaka/deepseek-v4.1-flash-free