Automated visual QA with AI vision
Ask OpenAI or Claude whether a page looks broken, in the same request as the screenshot, and catch layout bugs humans miss.
7 min read
Pixel-diff tools are good at telling you that something changed, and bad at telling you whether it’s broken. A moved button and a broken layout look the same to them. Vision models are the other way round: ask “is anything overlapping or cut off?” and you get an answer a person can act on.
shotsmith can ask that question for you, about the screenshot it just took, in the same request.
How it works
Add vision_prompt to a screenshot request, with vision_provider set to openai or anthropic and your own API key for that provider. The screenshot is sent to the model with your question, and the answer comes back in the vision field of the JSON response. Your provider key is used for that one request and never stored.
import { Shotsmith } from '@shotsmith/sdk';
const shotsmith = new Shotsmith({ accessKey: 'YOUR_ACCESS_KEY' });
const result = await shotsmith.takeJson({
url: 'https://shotsmith.dev/sample',
viewport_device: 'iphone_15_pro',
vision_provider: 'anthropic',
anthropic_api_key: 'YOUR_ANTHROPIC_API_KEY',
vision_prompt: 'List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.',
});
console.log(result.vision);
<?php
require 'vendor/autoload.php';
use Shotsmith\Client;
$shotsmith = new Client('YOUR_ACCESS_KEY');
$result = $shotsmith->takeJson([
'url' => 'https://shotsmith.dev/sample',
'viewport_device' => 'iphone_15_pro',
'vision_provider' => 'anthropic',
'anthropic_api_key' => 'YOUR_ANTHROPIC_API_KEY',
'vision_prompt' => 'List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.',
]);
echo $result['vision'];
curl -X POST "https://shotsmith.dev/v1/take" \
-H "X-Access-Key: YOUR_ACCESS_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://shotsmith.dev/sample",
"viewport_device": "iphone_15_pro",
"vision_provider": "anthropic",
"anthropic_api_key": "YOUR_ANTHROPIC_API_KEY",
"vision_prompt": "List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.",
"response_type": "json"
}'
const res = await fetch('https://shotsmith.dev/v1/take', {
method: 'POST',
headers: {
'X-Access-Key': 'YOUR_ACCESS_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
url: 'https://shotsmith.dev/sample',
viewport_device: 'iphone_15_pro',
vision_provider: 'anthropic',
anthropic_api_key: 'YOUR_ANTHROPIC_API_KEY',
vision_prompt: 'List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.',
response_type: 'json',
}),
});
if (!res.ok) throw new Error((await res.json()).error_message);
console.log(await res.json());
import json
import urllib.request
body = {
"url": "https://shotsmith.dev/sample",
"viewport_device": "iphone_15_pro",
"vision_provider": "anthropic",
"anthropic_api_key": "YOUR_ANTHROPIC_API_KEY",
"vision_prompt": "List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.",
"response_type": "json"
}
req = urllib.request.Request(
"https://shotsmith.dev/v1/take",
data=json.dumps(body).encode(),
headers={"X-Access-Key": "YOUR_ACCESS_KEY", "Content-Type": "application/json"},
method="POST",
)
# Raises urllib.error.HTTPError on a 4xx/5xx response
with urllib.request.urlopen(req, timeout=60) as res:
print(json.load(res))
<?php
$ch = curl_init('https://shotsmith.dev/v1/take');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['X-Access-Key: YOUR_ACCESS_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'url' => 'https://shotsmith.dev/sample',
'viewport_device' => 'iphone_15_pro',
'vision_provider' => 'anthropic',
'anthropic_api_key' => 'YOUR_ANTHROPIC_API_KEY',
'vision_prompt' => 'List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.',
'response_type' => 'json',
]),
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
]);
$response = json_decode(curl_exec($ch), true);
if (curl_getinfo($ch, CURLINFO_RESPONSE_CODE) >= 400) {
throw new RuntimeException($response['error_message']);
}
print_r($response);
package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
body := strings.NewReader(`{
"url": "https://shotsmith.dev/sample",
"viewport_device": "iphone_15_pro",
"vision_provider": "anthropic",
"anthropic_api_key": "YOUR_ANTHROPIC_API_KEY",
"vision_prompt": "List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.",
"response_type": "json"
}`)
req, _ := http.NewRequest("POST", "https://shotsmith.dev/v1/take", body)
req.Header.Set("X-Access-Key", "YOUR_ACCESS_KEY")
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
out, _ := io.ReadAll(res.Body)
fmt.Println(string(out))
}
require "net/http"
require "json"
body = {
"url" => "https://shotsmith.dev/sample",
"viewport_device" => "iphone_15_pro",
"vision_provider" => "anthropic",
"anthropic_api_key" => "YOUR_ANTHROPIC_API_KEY",
"vision_prompt" => "List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.",
"response_type" => "json"
}
res = Net::HTTP.post(
URI("https://shotsmith.dev/v1/take"),
body.to_json,
"X-Access-Key" => "YOUR_ACCESS_KEY",
"Content-Type" => "application/json"
)
raise res.body unless res.is_a?(Net::HTTPSuccess)
puts JSON.parse(res.body)
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Request {
public static void main(String[] args) throws Exception {
var body = """
{
"url": "https://shotsmith.dev/sample",
"viewport_device": "iphone_15_pro",
"vision_provider": "anthropic",
"anthropic_api_key": "YOUR_ANTHROPIC_API_KEY",
"vision_prompt": "List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.",
"response_type": "json"
}
""";
var request = HttpRequest.newBuilder(URI.create("https://shotsmith.dev/v1/take"))
.header("X-Access-Key", "YOUR_ACCESS_KEY")
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(body))
.build();
var res = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(res.body());
}
}
using System;
using System.Net.Http;
using System.Text;
using var http = new HttpClient();
http.DefaultRequestHeaders.Add("X-Access-Key", "YOUR_ACCESS_KEY");
var body = """
{
"url": "https://shotsmith.dev/sample",
"viewport_device": "iphone_15_pro",
"vision_provider": "anthropic",
"anthropic_api_key": "YOUR_ANTHROPIC_API_KEY",
"vision_prompt": "List any broken layout, overlapping or cut-off text on this page. Answer OK if there is none.",
"response_type": "json"
}
""";
var res = await http.PostAsync(
"https://shotsmith.dev/v1/take",
new StringContent(body, Encoding.UTF8, "application/json")
);
res.EnsureSuccessStatusCode();
Console.WriteLine(await res.Content.ReadAsStringAsync());
Send provider keys in a POST body, as above, never in a URL.
Prompts that work well
- Layout: “List any overlapping, cut-off or misaligned elements. Answer OK if there are none.”
- Content: “Does the page show a price for the Pro plan? Reply with just the price, or NONE.”
- Brand: “Is the logo visible in the header, and are the primary buttons blue?”
- Accessibility smells: “Point out any text with poor contrast against its background.”
Ask for a fixed format (“OK”, a number, “NONE”) when a script will read the answer, so you don’t have to parse prose.
Run it on every deploy
- After deploying, request your key pages with a
vision_prompt, on both desktop and a phone viewport. - If any answer isn’t “OK”, fail the pipeline or post the screenshot and the answer to your team chat.
- Keep the prompt and viewport fixed, so answers are comparable from one deploy to the next.
For pixel-level change detection alongside it, see visual regression testing.
Costs and limits
- The render uses one of your shotsmith renders. The model call is billed by your AI provider, on your key.
- Large full-page screenshots are scaled down before they’re sent, to stay within the models’ image limits. For detail in one area, capture just that element with
selector. - Vision models can be wrong. Treat their answers as a strong hint that something needs a look, not as proof.