Spectacles Documentation
Spectacles indexes your Craft CMS asset library with a computer-vision model and stores a similarity vector for each image. Visitors upload an image and Spectacles returns the closest matches — or you can query by free-form text from Twig.
How it works
- When an image asset is saved, Spectacles queues an analysis job.
- The job calls your configured vision provider (OpenAI, Claude, Gemini, or Ollama) for description, tags, objects, and colors.
- Then your configured embedding provider (OpenAI, Gemini, Voyage multimodal, or Ollama) produces a vector.
- Description and vector are stored in
spectacles_imagemetadata. If pgvector is available, the vector is also indexed inspectacles_imagevectorsfor fast cosine lookups. - At search time, Spectacles computes cosine similarity (in PHP or via pgvector) and returns ranked results.
Getting Started
Installation
Install via Composer and run the migration.
Configuration
Settings, environment variables, and quick-start presets.
AI Providers
OpenAI, Claude, Gemini, Voyage, and Ollama side-by-side.
Usage
Twig helpers, endpoints, and the CP sidebar panel.
Vector Backends
PHP scan vs pgvector — when to switch and how.
Troubleshooting
Common issues and how to fix them.