Cài đặt, vận hành và API
Một site · một Named Tunnel · một hostname · SaaS auth · signed live token.
Mô hình triển khai
Mỗi địa điểm có một máy luôn bật cùng LAN với camera. go2rtc và AI chỉ nghe trên localhost; Cloudflare Tunnel chỉ đưa relay đã xác thực ra ngoài. Khách đăng nhập SaaS và nhận URL WebRTC ký ngắn hạn, không dùng Google Cloudflare Access.
1 viewer/camera
5 viewers/camera
R2; live qua WebRTC
1. Chuẩn bị máy tại site
- macOS hoặc Linux 64-bit, chạy 24/7, ưu tiên Ethernet.
- Node.js 20+, Git, Python 3.10+ với
venv,curl; Linux cầnsudo. - Camera đã bật RTSP + ONVIF, có IP cố định/DHCP reservation và tài khoản riêng.
- Outbound HTTPS/WSS tới Cloudflare, GitHub và dashboard; không mở port router.
- Sau khi site online, dùng “Quét camera” để khám phá camera ONVIF trong LAN hoặc nhập IP thủ công.
2. Cài đặt
Đăng nhập dashboard → Cấu hình → Cài relay lên VPS → Tạo lệnh cài. Sao chép lệnh và chạy trên máy macOS/Linux cùng mạng với camera.
Dashboard → Settings · CameraAIWork setup guide (VI)
Installer hỏi tên site và thông tin camera, rồi cài go2rtc, relay và AI thành service. Nhập mật khẩu camera tại máy site; không gửi vào chat.
3. Kiểm tra
launchctl list | grep cameraaiwork
tail -n 100 /tmp/cameraaiwork-relay.log
curl -fsS http://127.0.0.1:1984/api/streams
curl -fsS http://127.0.0.1:4000/health
systemctl --no-pager --full status cameraaiwork-go2rtc cameraaiwork-relay cameraaiwork-ai
journalctl -u cameraaiwork-relay -n 100 --no-pager
curl -fsS http://127.0.0.1:1984/api/streams
curl -fsS http://127.0.0.1:4000/health
Trên dashboard, test theo chuỗi: camera xuất hiện → live → PTZ rồi stop → motion event → AI → clip R2 → Telegram.
API cho AI agent
Nạp /openapi.yaml làm tool schema. Token phải nằm trong secret store và gửi qua Authorization: Bearer.
export CAMERAAI_API='https://cameraaiwork.pages.dev'
export CAMERAAI_TOKEN='account-session-key'
curl -fsS "$CAMERAAI_API/api/cameras" \
-H "Authorization: Bearer $CAMERAAI_TOKEN"
x-agent-risk destructive, financial hoặc secret-write. Không tự retry POST tạo site/tunnel/job.