Complete working examples for common use cases using the Lens Events API.Documentation Index
Fetch the complete documentation index at: https://docs.archetypeai.app/llms.txt
Use this file to discover all available pages before exploring further.
Prerequisites: Set your API key as an environment variable:
CSV File Streaming Example
Stream data from a CSV file through a lens for time-series analysis.Step 1: Download Sample Data
Step 2: Upload CSV File
Step 3: Stream CSV Through Lens
Creating lens sessionâŚthenConnecting to WebSocketâŚâ both succeed in under 1s.Validating sessionâŚâSession is valid!returns{"type": "session.validate.response", "event_data": {"is_valid": true, "error_messages": []}}.Configuring CSV streamâŚâStream configured: {'type': 'input_stream.set.response', 'event_data': {'is_valid': true, 'error_messages': []}}.Reading streaming resultsâŚâ the content depends entirely on the lens you connect the stream to. A lens whose pipeline matches the CSVâs schema (column names, sampling rate) will emitinference.resultmessages over time; an incompatible lens will return{"type": "session.read.response", "event_data": null}on each poll. Confirm the lensâs expected schema fromGET /lens/metadatabefore running.
RTSP Camera Streaming Example
Stream real-time video from an RTSP camera for live analysis.- Session creation, WebSocket connection, and
session.validateall succeed (same envelope shapes as the CSV example above). RTSP stream configured: {'type': 'input_stream.set.response', 'event_data': {'is_valid': true, ...}}.inference.resultpayloads arrive onsession.readpolls â typical content is a short natural-language description of the latest frame batch (noconfidenceorprocessing_time_msfields are guaranteed by the model). Frequency depends on the lensâscamera_buffer_sizeand thetarget_frame_rate_hzyou configured on the stream.- An unreachable RTSP URL surfaces as an error message in subsequent
session.readpolls rather than a synchronous error oninput_stream.set.
Direct Image Analysis Example
Send individual images for immediate analysis without setting up streams.model.query only works against lenses whose pipeline includes a model-query processor (i.e. not the Activity Monitor â which uses lens_camera_processor and expects camera input). If your model.query returns {"type": "model.query.response", "message": "Response timed out for query"}, the lens is not configured to handle direct queries. Register a model-query lens first via POST /lens/register or use a streaming approach with input_stream.set instead.Repository and Additional Examples
Python Client Examples
Complete example repository with more use cases
WebSocket Events API
Detailed WebSocket event documentation
File Upload API
Upload files for CSV streaming
Troubleshooting
Common issues and solutions
Common Use Cases
- Security Monitoring
- Quality Control
- Environmental Monitoring
Application: Real-time security camera analysisSetup: RTSP camera stream with person/vehicle detectionFocus Examples:
- âDetect unauthorized personnelâ
- âMonitor for safety violationsâ
- âCount people in restricted areasâ