Competitor Page Diff
Fetch two competitor URLs (capped), extract messaging, and generateObject a structured positioning diff.
Run this experiment yourself
Demos are not embedded on this site. Deploy a standalone copy on Vercel or run the experiment app locally.
Local development
cd apps/experiments/competitor-page-diff pnpm install pnpm dev
Then open http://localhost:3010.
This is an experimental demo. Use it as a starting point for your own projects.
Competitor Page Diff fetches two public http(s) URLs with the same size/timeout caps as URL Brief Lab, extracts title/meta/text for each single page, and returns a structured messaging diff via generateObject. Missing AI keys return 503.
Features
- Dual capped fetch – parallel page fetches with timeout + byte limits
- Structured messaging diff – sharedThemes / aOnly / bOnly / positioningNotes
- Honest
503when AI is unavailable
Server Reference
POST /api/diff
{ "urlA": "https://a.com", "urlB": "https://b.com" }| Status | Cause |
|---|---|
503 | No AI provider |
400 | Validation / upstream / empty input |
Implementation Details
Pure helpers in logic.ts
Caps, parsers, and clamps live in the experiment folder and are covered by logic.test.ts.
Route Handler
POST /api/diff validates input, applies fetch/parse limits where relevant, then returns JSON from generateObject.
Use Cases
- Learn composition patterns for this lab’s stack.
- Prototype before wiring production auth and quotas.
- Deploy the standalone app as a reference implementation.
Limitations
- Demo-scale caps on input size and output counts.
- No auth / rate limits on public deploys.
- Model quality depends on input clarity.
- Treat outputs as drafts, not production truth.
Use in your project
Copy the Route Handler and logic.ts helpers from apps/experiments/competitor-page-diff/. Wire your own persistence and auth as needed.
Deployment
Local Development
cd apps/experiments/competitor-page-diff
pnpm install
pnpm devConfiguration
| Variable | Required | Purpose |
|---|---|---|
AI_GATEWAY_API_KEY | Yes (or OPENAI_API_KEY) | Preferred provider |
OPENAI_API_KEY | No | Fallback |
AI_MODEL | No | Model override |
Vercel / Next.js Features Used
- Route Handlers
- Zod
- AI SDK
generateObject