-
Notifications
You must be signed in to change notification settings - Fork 0
Vision Providers
Screenwright's vision layer is fully optional and provider-swappable — describe() returns the
same ScreenshotMetadata shape regardless of provider, so downstream output never changes.
Each provider's SDK is a separate pip extra, not a hard dependency of the base package — see
Getting Started.
pip install "screenwright[anthropic]"
export ANTHROPIC_API_KEY=your-api-key[vision]
provider = "anthropic"
model = "claude-haiku-4-5"
structured_metadata = trueCost: ~$0.25/M input tokens — a fraction of a cent per screenshot.
pip install "screenwright[openai]"
export OPENAI_API_KEY=your-api-key[vision]
provider = "openai"
model = "gpt-4o-mini"
structured_metadata = trueUseful when the rest of your workflow — e.g. driving Screenwright from Codex CLI — is already on OpenAI.
pip install "screenwright[ollama]"
# Install Ollama: https://ollama.com
ollama pull moondream[vision]
provider = "ollama"
model = "moondream"
structured_metadata = trueRecommended default for air-gapped environments or UIs with sensitive data that shouldn't leave
your network. Other Ollama vision models (llava, qwen2-vl) also work — set model
accordingly.
Note: Moondream2 is small (~1.6B) and can return an empty response when asked to follow the structured JSON prompt. Screenwright falls back gracefully to an empty description rather than failing the run — but for reliable structured metadata with Moondream, either set
structured_metadata = falseor use a larger local model such asllavaorqwen2-vl.
Every provider sends a built-in generic prompt ("Describe this UI screenshot for documentation purposes.") unless you override it — useful for steering descriptions toward accessibility review, a non-English language, or a specific documentation style:
[vision]
provider = "anthropic"
prompt = "Focus on accessibility issues: missing labels, low contrast, unclear focus states."Works with any provider, and with describe_screenshot's own prompt argument when calling it
directly via MCP instead of through a flow's [vision] config. When structured_metadata = true
(the default), the JSON-structure instruction is still appended after your prompt — you're
overriding what the model is asked to look for, not the requirement that it respond as JSON.
[screenwright]
vision_describe = falsePure capture mode — no API calls, no metadata JSON, just PNGs (and video, if record = true).