Giao diện
4. Kiểm tra
Chạy lần lượt từng bước trong một terminal mới. Nếu một bước không đạt, xem 6. Xử lý sự cố trước khi làm bước tiếp theo.
4.1. 9router trả về danh sách model
bash
curl -s http://127.0.0.1:20128/v1/models -H "Authorization: Bearer $NINE_ROUTER_KEY" | grep -oE '"id":"[^"]+"' | head -5powershell
(Invoke-RestMethod http://127.0.0.1:20128/v1/models -Headers @{ Authorization = "Bearer $env:NINE_ROUTER_KEY" }).data | Select-Object -First 5 -ExpandProperty idKết quả mong đợi: tối đa 5 id model, ví dụ oc/deepseek-v4.1-flash-free. Nếu Git Bash không in gì hoặc PowerShell báo lỗi kết nối, 9router chưa chạy.
4.2. Plugin đã được nạp
bash
opencode api plugin.list | grep -oE '"(id|status)":"[^"]*"' | grep -A1 'opencode.models-discovery'powershell
(opencode api plugin.list | ConvertFrom-Json).data | Where-Object id -eq 'opencode.models-discovery' | ForEach-Object { "{0}: {1}" -f $_.id, $_.state.status }Kết quả mong đợi:
- Git Bash: dòng
"id":"opencode.models-discovery", ngay sau đó là dòng"status":"active". - PowerShell:
opencode.models-discovery: active.
4.3. opencode thấy model của 9router
bash
opencode models | grep -c '^9router/'powershell
(opencode models | Select-String '^9router/').CountKết quả mong đợi: một số lớn hơn 0. Lần đầu mở opencode trong một thư mục mới, model của 9router có thể mất vài giây mới hiện.
Đối chiếu với số model 9router trả về (tuỳ chọn):
bash
curl -s http://127.0.0.1:20128/v1/models -H "Authorization: Bearer $NINE_ROUTER_KEY" | grep -o '"id":"' | wc -lpowershell
(Invoke-RestMethod http://127.0.0.1:20128/v1/models -Headers @{ Authorization = "Bearer $env:NINE_ROUTER_KEY" }).data.CountHai số có thể khác nhau do filterNonChat và bộ lọc ở 3.5.
4.4. Chat thử
bash
opencode run -m 9router/oc/deepseek-v4.1-flash-free "Reply with exactly: OK"Kết quả mong đợi: OK.
Chọn model khác
Model trong ví dụ có thể không có trên 9router của bạn. Liệt kê model bằng opencode models | grep '^9router/', hoặc opencode models | Select-String '^9router/' trong PowerShell. Nên dùng model miễn phí để kiểm thử.
4.5. Bảng nghiệm thu
| Hạng mục | Tiêu chí đạt | Mục |
|---|---|---|
| 9router | Trả về danh sách id model | 4.1 |
| Plugin | Trạng thái active | 4.2 |
| Model | opencode liệt kê ít nhất một model 9router/... | 4.3 |
| Chat | Model trả lời OK | 4.4 |
| Bảo mật | opencode.json không chứa key. Key nằm trong biến môi trường | 2.4 |
| Mạng | 9router chỉ lắng nghe trên 127.0.0.1, hoặc được giới hạn bằng tường lửa | 8.5 |