DEV Community

Cover image for Stream High-Resolution Stock Video Directly Into AI Agent Pipelines with pexels-cli
Dmytro Bilukha
Dmytro Bilukha

Posted on

Stream High-Resolution Stock Video Directly Into AI Agent Pipelines with pexels-cli

Demo Animation

Automated media production pipelines often require sourcing hundreds of relevant B-roll clips and stock images. Traditional SDKs return bloated JSON payloads containing hundreds of metadata keys that waste context windows when fed into LLMs or classifiers.

pexels-cli (px) is an open-source, high-performance CLI tool for Pexels built with uv and Python 3.10+.


Key Innovations for AI Pipelines

  1. Classifier-Ready --state Mode: Emits condensed, single-line JSONL candidates specifically structured for non-generative classification engines (e.g. Laya).
  2. Multi-Query Deduplication: Execute multiple search terms in parallel while automatically discarding duplicate video/photo IDs across result sets.
  3. Payload Pruning (--fields): Whitelist only necessary keys (id, url, duration, width, height) to maximize token efficiency.
  4. Asynchronous Parallel Downloader: Efficient streaming downloader with Rich terminal bars.

Quick Start

uv tool install pexels-ai-cli
# or
pipx install pexels-ai-cli
Enter fullscreen mode Exit fullscreen mode

Example: Pipeline Chaining

# Search, deduplicate, format for decision model, and pipe
px videos --queries "tokyo night,shibuya crossing" --per-page 5 --state --dedupe \
  | laya-cli classify --questions-inline '{"relevant": {"type": "noul", "prompt": "Contains neon lighting?"}}' \
  | jq -r 'select(.predictions.relevant > 0.8) | .state'
Enter fullscreen mode Exit fullscreen mode

Top comments (0)