AI API

Metered boat-photo analysis

The same defect-detection pipeline that powers Skiff inspections, available as an API. Requires a key with the ai:analyzescope (tick "Allow AI photo analysis" when creating the key). Analyze calls are metered and billed monthly at US$0.05 per analyzed photo; subject checks are free.

Analyze a photo

curl -X POST https://binranoynwqpydttvgbs.supabase.co/functions/v1/ai-public \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "action": "analyze",
    "image_base64": "<base64, max ~1.3MB binary>",
    "mime": "image/jpeg",
    "subject": "engine anode",
    "context": "annual haul-out check"
  }'

{
  "subject": { "identified": "sacrificial anode on a saildrive",
               "match": "match", "confidence": 0.93 },
  "detections": [
    { "label": "anode wastage ~70%", "confidence": 0.88,
      "x": 0.41, "y": 0.52, "w": 0.2, "h": 0.18, "severity": "attention" }
  ],
  "note": "The anode is roughly 70% wasted and due for replacement…",
  "diy": { "suitability": "diy_ok", "reason": "Simple bolt-on swap with the boat out of the water." }
}

Subject check (free)

A fast "what is in frame" check, useful for guiding a camera before spending an analyze call.

{ "action": "subject_check", "image_base64": "…", "subject": "bilge pump" }

{ "subject": { "identified": "bilge pump", "match": "match", "confidence": 0.9 } }

Semantics

When the photo does not show the requested subject, detections are empty and the note asks for a better frame; you are still charged for the analyze call, so use subject_check first on ambiguous input. Bounding boxes are normalised fractions of image width and height, origin top-left. The DIY read is deliberately cautious: safety-critical systems always come back pro_required.

Limits and billing

400 image_too_large        base64 above ~1.8MB
403 missing_scope          key lacks ai:analyze
429 monthly_quota_exceeded key hit its configured monthly cap
503 ai_api_disabled        the AI API is switched off platform-wide

Billing: usage meters nightly to Stripe (meter skiff_ai_analysis,
price lookup_key skiff_ai_api_usd) against your Skiff billing account.