> ## 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.

# Lens Processors

**Lens processors** are components within a lens's `model_pipeline` that define how data is processed. They are configured in the `lens_config` when registering or modifying a lens.

### **Types of Lens Processors**

The following processors are available:

| **Processor Name**                | **Purpose**                                                        | **File Types** |
| --------------------------------- | ------------------------------------------------------------------ | -------------- |
| `lens_camera_processor`           | Processes camera/video data for activity monitoring                | .mp4 videos    |
| `lens_timeseries_state_processor` | Processes time-series sensor data for machine state classification | .csv files     |
| `lens_sensor_logs_processor`      | Processes sensor logs                                              | .jsonl files   |

### **Configuration Example**

A processor can be selected by passing in the processor name key within the model pipeline in a lens configuration:

```
model_pipeline:
  - processor_name: lens_camera_processor
```

*Note: The `processor_config` can be skipped if it is empty (it will automatically be added by the backend).*

### **Processor Parameters**

#### *Camera Processor*

| Parameter                 | Description                                       | Default | Notes                                                        |
| ------------------------- | ------------------------------------------------- | ------- | ------------------------------------------------------------ |
| `camera_buffer_size`      | Number of frames kept in buffer before processing | `5`     | Buffer size of 5 means the model sees 5 frames per inference |
| `camera_buffer_step_size` | Step size for frame sampling                      | `5`     | Step of 5 frames means the next window starts 5 frames later |

#### *Timeseries State Processor*

| Parameter      | Description                                 | Default | Notes                                                                                          |
| -------------- | ------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------- |
| `window_size`  | Number of rows analyzed together            | `1024`  | Smaller values (256) give more frequent predictions; larger values (2048) provide more context |
| `step_size`    | Rows to advance between predictions         | `1024`  | Controls prediction frequency                                                                  |
| `input_n_shot` | Labeled CSV examples for each machine state | —       | At least one example required per state; format must match incoming data                       |

#### *Sensor Logs Processor*

| Parameter                | Description                                     | Default | Notes                                                                                                                                                                                   |
| ------------------------ | ----------------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `sensor_buffer_size`     | Number of sensor log entries kept in the buffer | `5`     | The processor waits until the buffer contains this many entries before running inference. When the buffer exceeds this size, older entries are removed.                                 |
| `input_buffer_step_size` | Step size for sampling incoming sensor events   | `1`     | Controls how many incoming events are skipped between samples. A value of 1 means every event is buffered; a value of 3 means only every 3rd event is buffered. Must be greater than 0. |

### **Output Writers**

A lens's `model_pipeline` ends with an **output writer** processor that decides where inference results are sent. Each lens uses exactly one output channel — outputs do not appear on both at once.

| **Writer**                  | **Where outputs go**                    | **How to consume**                                                                                                                                                            |
| --------------------------- | --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `server_sent_events_writer` | The session's Server-Sent Events stream | [`GET /lens/sessions/consumer/{session_id}`](/api-reference/lens/consumer) — used by the [official SDK](https://pypi.org/project/archetypeai/)'s `lens.create_sse_consumer()` |
| Default mailbox writer      | The session's WebSocket message mailbox | [`session.read`](/api-reference/lens/websocket-events#session-read) events on the session WebSocket                                                                           |

The Activity Monitor lens and most cookbook lenses use `server_sent_events_writer` for output. To check which writer a specific lens uses, inspect its `model_pipeline` via [`GET /lens/metadata`](/api-reference/lens/get-metadata).

If you are reading from `session.read` but seeing `event_data: null` while [`GET /lens/sessions/metadata`](/api-reference/lens/get-sessions-metadata) reports non-zero `num_outputs`, the lens is writing to the SSE channel — switch to the [consumer endpoint](/api-reference/lens/consumer).

### **Best Practices**

* Always destroy sessions when done to free resources
* Use appropriate buffer sizes for your data type
* Match input data format to processor requirements

The documentation focuses more on **Lenses** as the primary interface, with processors being internal components. For troubleshooting, check session status via the API and ensure proper authentication.

### Additional Resources:

* [**Lenses Overview**](https://docs.archetypeai.app/core-concepts/lenses/overview)
* [**Lens Parameter Overview**](https://docs.archetypeai.app/core-concepts/lenses/lens-parameter).
* [**Test Lens with Echo Processor**](https://docs.archetypeai.app/core-concepts/lenses/lens-templates/test-lens).
