Skip to content

Latest commit

 

History

History
125 lines (87 loc) · 3.76 KB

File metadata and controls

125 lines (87 loc) · 3.76 KB

API Dashboard

Sign up, create API keys, and call the hosted compress endpoint with usage tracking.

Live: supercompress.dev/dashboard

Quick start (local dev)

pip install -e ".[serve]"
SC_AUTH_DEV=1 SC_KEY_STORE=memory python scripts/local_web_server.py

Open http://127.0.0.1:8790/dashboard. Dev mode accepts any email — no Firebase required.

Production setup

1. Firebase project

  1. Create a Firebase project
  2. Enable Authentication → Email/Password and Google
  3. Create a Firestore database
  4. Generate a service account JSON → set GOOGLE_APPLICATION_CREDENTIALS
  5. Add supercompress.dev to Firebase Auth → Settings → Authorized domains
  6. Copy web app config into env vars (see scripts/generate-firebase-config.js)

Deploy Firestore rules:

firebase deploy --only firestore:rules

2. Run the API server

pip install -e ".[serve,firebase]"
SC_KEY_STORE=firestore python scripts/local_web_server.py

For production, the live site ships serverless API routes on Vercel (/api/health, /api/keys, /api/v1/compress) with keys stored in Vercel Blob. No separate deploy step when using the main Vercel project.

Optional self-host (Python FastAPI)

fly apps create supercompress-api
fly volumes create sc_data --size 1 --region sjc -a supercompress-api
fly deploy

Docker (local / other hosts)

docker build -t supercompress-api .
docker run -p 8790:8790 -e SC_AUTH_DEV=1 -e SC_KEY_STORE=file -v sc-data:/data supercompress-api

Render — use the included render.yaml blueprint (Docker + persistent disk for keys).

Set SC_API_BASE in firebase-config.js only if the dashboard and API are on different origins. On the live Vercel site, leave it empty ("") so the dashboard hits the same origin.

Dashboard

URL Description
/dashboard Sign up / sign in, manage keys, view usage
Docs link docs/API.md

Key management

  • Create — name your key; full secret shown once (sc_live_…)
  • Rename — update display name
  • Revoke — permanently disable a key
  • Usage — requests, tokens in/out, tokens saved per key

API endpoints

Authenticated (Firebase ID token)

Method Path Description
GET /api/me Current user
GET /api/keys List keys + usage summary
POST /api/keys Create key { "name": "Production" }
PATCH /api/keys/{id} Rename { "name": "New name" }
DELETE /api/keys/{id} Revoke key
GET /api/keys/{id}/usage Usage for one key

Header: Authorization: Bearer <firebase_id_token>

Compress (API key)

POST /v1/compress
X-API-Key: sc_live_xxxxxxxx
Content-Type: application/json

{
  "context": "long document…",
  "query": "Summarize this context.",
  "budget_ratio": 0.35
}

Or: Authorization: Bearer sc_live_…

Response includes compressed_text, token counts, and savings metrics. Usage is recorded automatically.

Playground (no key)

POST /api/compress remains unauthenticated for the browser demo and local testing.

Environment variables

Variable Default Description
SC_AUTH_DEV off Accept dev:uid:email tokens
SC_KEY_STORE auto memory, firestore, or auto
SC_KEY_STORE_FILE JSON file persistence (dev)
GOOGLE_APPLICATION_CREDENTIALS Firebase service account path

Security

  • Full API keys are never stored — only SHA-256 hashes
  • Firestore is server-side only; clients use FastAPI + Firebase Auth
  • Revoked keys are removed from the lookup index immediately