Example code for the Trio API - turn any YouTube Live stream into a programmable data source with AI vision.
Trio monitors live video streams using vision AI and sends webhook notifications when conditions are met. Use it for:
- Weather monitoring (rain, snow, fog detection)
- Traffic analysis (accidents, congestion)
- Security alerts (person detection, motion)
- Event monitoring (crowd size, activity changes)
Sign up at console.machinefi.com to get your API key.
Check a condition on a live stream right now:
import requests
response = requests.post(
"https://trio.machinefi.com/api/check-once",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"stream_url": "https://www.youtube.com/watch?v=jfKfPfyJRdk",
"condition": "Is there an animated character visible?"
}
)
result = response.json()
print(f"Triggered: {result['triggered']}")
print(f"Explanation: {result['explanation']}")Monitor a stream and get notified when something happens:
import requests
response = requests.post(
"https://trio.machinefi.com/api/live-monitor",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"stream_url": "https://www.youtube.com/watch?v=jfKfPfyJRdk",
"condition": "Is there a cat visible?",
"webhook_url": "https://your-server.com/webhook"
}
)
job = response.json()
print(f"Job started: {job['job_id']}")| Example | Description |
|---|---|
| quickstart/check_once.py | Single condition check |
| quickstart/live_monitor.py | Continuous monitoring with webhooks |
| quickstart/live_digest.py | Stream summarization |
| webhook-server/ | FastAPI webhook receiver |
| mcp/ | AI agent integration (Claude, GPT) |
pip install requestsFor the webhook server:
cd webhook-server
pip install -r requirements.txt| Endpoint | Method | Description |
|---|---|---|
/api/check-once |
POST | Single synchronous check |
/api/live-monitor |
POST | Start continuous monitoring |
/api/live-digest |
POST | Generate stream summary |
/api/jobs |
GET | List all jobs |
/api/jobs/{id} |
DELETE | Cancel a job |
Full documentation: docs.machinefi.com
Apache 2.0