An aisong.io-style website: users describe a song or paste lyrics, and the site generates a full original song with vocals (via Google Lyria 3 Pro through OpenRouter).
The API key alone is not enough — the account needs credits, otherwise every
generation fails with 402 Payment Required.
- Go to https://openrouter.ai/settings/credits and add credits (a few dollars is plenty to start; each song ≈ $0.08).
- The same
sk-or-v1-...key will then work for paid models.
cd ai-song-site
npx wrangler login
npx wrangler secret put OPENROUTER_API_KEY # paste the sk-or-v1-... key when asked
npx wrangler deploy worker.js --name ganerdhol-aiCopy the worker URL, e.g. https://ganerdhol-ai.yourname.workers.dev.
Abuse protection (important): every song costs ~$0.08 of YOUR money. In the Cloudflare dashboard, add a Rate Limiting rule for
https://<your-worker>/api/generate— e.g. max 10 requests / 10 minutes per IP. The worker also has a best-effort cap of 5 songs / IP / day.
- On github.com create a public repo, e.g.
GanerDhol-AI. - Push these files to the
mainbranch. - Repo Settings → Pages → Source: Deploy from a branch, branch
main, folder/ (root). - Site goes live at
https://mdnaimislambd.github.io/GanerDhol-AI/.
Edit config.js and set:
WORKER_URL: "https://ganerdhol-ai.yourname.workers.dev"Push the change. Done — the Generate button now makes real songs.
Two ad slots are pre-wired with publisher ID ca-pub-8912117199500932.
Create ad units in AdSense and replace REPLACE_WITH_AD_SLOT in index.html.
- User fills the form → frontend POSTs JSON to
WORKER_URL/api/generate. - Worker builds a Lyria prompt and calls OpenRouter (
google/lyria-3-pro-preview,modalities: ["audio","text"],stream: true— audio output requires streaming). - Worker assembles the base64 MP3 chunks from the SSE stream and returns
audio/mpeg. - Frontend plays it in the
<audio>player, offers Download, and keeps a session history.
- Per song: ~$0.08 (OpenRouter → Lyria 3 Pro Preview).
- 100 songs ≈ $8. Backend + frontend hosting: $0.
- Do NOT offer unlimited free generations publicly unless you add user accounts + payments — anyone can drain the OpenRouter balance otherwise.
