Skip to content

davidbroza/llmprices

Repository files navigation

llmprices.davidbroza.dev

Live + historical pricing for every major LLM and subscription plan.

  • Web app: TanStack Start SSR running as a Cloudflare Worker.
  • Daily scraper Worker pulls 300+ models from OpenRouter into D1.
  • Fixed-plans Worker pre-computes the effective $/M value of subscription plans (Claude Max, ChatGPT Pro, Gemini Advanced, …) at four usage profiles.
  • Wayback backfill fills prices with monthly snapshots back to 2023.

Layout

src/                 TanStack Start app (UI + server functions + JSON API)
src/server/db        Drizzle schema + D1 client + KV cache helpers
src/server/fn        Server functions consumed by route loaders
src/server/backfill  Wayback Machine one-time backfill
workers/scraper      Cron Worker — OpenRouter → D1
workers/fixed-plans  Cron Worker — recalculates plan_values nightly
migrations/          0001_init.sql + seed.sql (generated by scripts/seed.ts)
scripts/seed.ts      Generates an idempotent seed.sql from seed-data.ts
sst.config.ts        SST Ion infra (D1 + KV + Workers + cron + custom domain)

First-time setup

pnpm install

# 1. Provision D1 + KV (one-time)
pnpm wrangler d1 create llm-prices-db
pnpm wrangler kv namespace create CACHE
# → copy each printed id into wrangler.jsonc and the two workers/*/wrangler.jsonc

# 2. Apply schema
pnpm wrangler d1 execute llm-prices-db --local  --file=migrations/0001_init.sql
pnpm wrangler d1 execute llm-prices-db --remote --file=migrations/0001_init.sql

# 3. Generate + apply seed
pnpm db:seed
pnpm db:seed:apply:local
pnpm db:seed:apply:remote

Develop

pnpm dev          # TanStack Start + local D1/KV via Miniflare
pnpm typecheck

Deploy

# Set secrets once (SST Ion reads these via `sst.Secret`)
pnpm sst secret set AnthropicApiKey   sk-ant-...
pnpm sst secret set BraveApiKey       BSA...
pnpm sst secret set AdminSecret       $(openssl rand -hex 32)

# Deploys the SSR Worker, both cron Workers, D1, KV, and DNS
pnpm deploy

One-off historical backfill

After the first deploy:

curl -X POST https://llmprices.davidbroza.dev/api/admin/backfill \
  -H "X-Admin-Secret: $ADMIN_SECRET" \
  -H "Content-Type: application/json" \
  -d '{"fromDate":"20230601"}'

Public API

  • GET /api/models
  • GET /api/models/:id/history?months=24
  • GET /api/runs

CORS: open. Cached at the edge for 5 minutes.

Updating subscription plan limits

Edit workers/fixed-plans/plans.ts. Both the calculator UI and the nightly cron read from the same source, so changes take effect on the next run (or immediately on pnpm dev).

About

Live pricing for every major LLM. Updated daily from OpenRouter, with effective $/M for fixed plans (Claude Max, ChatGPT Pro, etc.) — at llmprices.davidbroza.dev

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors