Standard Setup Workflow
- Create provider account and complete verification/billing where required.
- Generate API keys, OAuth client IDs, or webhook secrets in the provider dashboard.
- Add values to production
.envand local.env(never commit secrets). - Mirror credentials in Admin → Settings when the panel supports runtime overrides (Mail, Payment, AI, YouTube).
- Test in sandbox/test mode, then switch to live keys.
- Run
php artisan optimize:clearthenphp artisan config:cacheon the server.
OpenAI
Portal: platform.openai.com/api-keys
- Sign up and add a payment method under Billing.
- Create a new secret API key (copy immediately — shown once).
- Optional: set organization ID if you use multiple orgs.
OPENAI_API_KEY=sk-proj-...OPENAI_ORGANIZATION=OPENAI_IMAGE_MODEL=gpt-image-1OPENAI_SSL_VERIFY=trueUsed for images, text, and related AI features configured in Admin → Settings → AI.
xAI (Grok)
Portal: console.x.ai
- Create account and open API keys section.
- Generate API key and copy to
XAI_API_KEY.
XAI_API_KEY=xai-...XAI_BASE_URL=https://api.x.ai/v1XAI_IMAGE_MODEL=grok-imagine-image-qualityXAI_VIDEO_MODEL=grok-imagine-videoFAL.ai & Suno API
FAL.ai (video models: Kling, Veo, etc.)
Portal: fal.ai/dashboard/keys
FAL_KEY=...Suno (music generation)
- Register at your Suno API provider (e.g. sunoapi.org) and create an API key.
- Generate your own webhook secret — Suno does not issue a webhook signing secret. You create a long random string and use it on both sides below.
- Set
SUNO_WEBHOOK_SECRETin.envto that value (required in production). - In the Suno provider dashboard, set the callback/webhook URL to the same secret as the
tokenquery parameter:
https://yourdomain.com/webhooks/suno?token=YOUR_SUNO_WEBHOOK_SECRETGenerate a secret locally (example):
php -r "echo bin2hex(random_bytes(32));"SUNO_API_BASE_URL=https://api.sunoapi.orgSUNO_API_KEY=...SUNO_WEBHOOK_SECRET=paste_the_same_random_string_hereSUNO_WEBHOOK_SECRET is required in production. MelodAI appends it to Suno callback URLs as ?token=... so only requests with your secret are accepted — this is your secret, not one from Suno.
YouTube OAuth (Publishing)
Portal: Google Cloud Console → Credentials
- Create a project (or select existing).
- Enable YouTube Data API v3.
- Configure OAuth consent screen (External, add test users during development).
- Create OAuth 2.0 Client ID → type Web application.
- Add authorized redirect URI exactly:
https://yourdomain.com/dashboard/youtube/callback - Copy Client ID and Client Secret.
YOUTUBE_CLIENT_ID=....apps.googleusercontent.comYOUTUBE_CLIENT_SECRET=GOCSPX-...YOUTUBE_REDIRECT_URI=https://yourdomain.com/dashboard/youtube/callbackFor Expo dev against a LAN API, set YOUTUBE_REDIRECT_URI to your production HTTPS callback while the mobile app uses the server OAuth flow. Also configure in Admin → Settings → YouTube.
Cloudflare R2 Storage
Portal: Cloudflare Dashboard → R2
- Create an R2 bucket (e.g.
melodai-storage). - Create R2 API token with Object Read & Write on that bucket.
- Copy Access Key ID, Secret Access Key, and account endpoint URL.
- Optionally connect a custom domain for public CDN URL.
FILESYSTEM_DISK=cloudflareCLOUDFLARE_R2_KEY=...CLOUDFLARE_R2_SECRET=...CLOUDFLARE_R2_REGION=autoCLOUDFLARE_R2_BUCKET=melodai-storageCLOUDFLARE_R2_ENDPOINT=https://<account-id>.r2.cloudflarestorage.comCLOUDFLARE_R2_URL=https://cdn.yourdomain.comStripe (Laravel Cashier)
Portal: dashboard.stripe.com/apikeys
- Create Stripe account and complete business verification.
- Copy Publishable key and Secret key (test mode first).
- Developers → Webhooks → Add endpoint:
https://yourdomain.com/stripe/webhook(Cashier default). - Select events Cashier needs (checkout, customer subscription, invoice).
- Copy webhook signing secret.
STRIPE_KEY=pk_live_...STRIPE_SECRET=sk_live_...STRIPE_WEBHOOK_SECRET=whsec_...STRIPE_CURRENCY=usdAlso enable Stripe in Admin → Settings → Payment.
Flutterwave
Portal: dashboard.flutterwave.com
- Complete merchant verification.
- Copy Public Key, Secret Key, and Encryption Key.
- Set webhook URL and copy webhook hash.
FLUTTERWAVE_PUBLIC_KEY=FLWPUBK-...FLUTTERWAVE_SECRET_KEY=FLWSECK-...FLUTTERWAVE_ENCRYPTION_KEY=...FLUTTERWAVE_WEBHOOK_HASH=...Enable Flutterwave in Admin → Settings → Payment.
Revolut Merchant API
Portal: Revolut Merchant API (Business account → Merchant API). MelodAI uses API version 2026-04-20 for orders, webhooks, and refunds.
- Create or open a Revolut Business merchant account and complete onboarding.
- Generate API keys (public + secret). Start with sandbox.
- Create a webhook endpoint on Revolut pointing to your MelodAI URL (HTTPS in production).
- Copy the webhook signing secret (
wsk_...). - Add keys to
.envor Admin → Settings → Payment → Revolut (admin values override .env when saved). - Turn on Enabled and save. Revolut appears at checkout only when enabled and a secret key is configured.
Webhook & return URLs
https://yourdomain.com/webhooks/revoluthttps://yourdomain.com/dashboard/billing/payment/revolut/returnThe return URL runs after hosted checkout. Fulfillment also runs from webhooks when the order completes.
Environment variables
REVOLUT_PUBLIC_KEY=pk_...REVOLUT_SECRET_KEY=sk_...REVOLUT_WEBHOOK_SIGNING_SECRET=wsk_...REVOLUT_CURRENCY=USDREVOLUT_ENVIRONMENT=sandboxSet REVOLUT_ENVIRONMENT=production (or Production in admin) for live payments. Sandbox: https://sandbox-merchant.revolut.com; production: https://merchant.revolut.com.
Subscriptions and credit packs use one-shot Revolut orders, not Revolut Subscription Plans. Refunds: Admin → Billing → Invoices when the invoice allows refunds.
Cryptomus (crypto payments)
Portal: cryptomus.com → Business → Merchant → API integration.
- Register a Cryptomus merchant account and complete verification.
- Copy Merchant UUID and Payment API key.
- Set the payment webhook URL in Cryptomus to your MelodAI endpoint (HTTPS).
- Add credentials to
.envor Admin → Settings → Payment → Cryptomus. - Enable Enabled. Checkout shows Cryptomus when enabled and both UUID and payment key are set.
Webhook & return URLs
https://yourdomain.com/webhooks/cryptomushttps://yourdomain.com/dashboard/billing/payment/cryptomus/returnCryptomus signs webhooks with an MD5 signature from your payment key; MelodAI verifies before fulfilling invoices or subscriptions.
Environment variables
CRYPTOMUS_MERCHANT_UUID=...CRYPTOMUS_PAYMENT_KEY=...CRYPTOMUS_CURRENCY=USDCRYPTOMUS_INVOICE_LIFETIME=7200Refunds require a destination crypto wallet address. In Admin → Billing → Invoices, enter the refund wallet when refunding Cryptomus payments.
Payment providers — activation checklist
MelodAI supports Stripe (Cashier), Flutterwave, Revolut, and Cryptomus. Configure in Admin → Settings → Payment or .env; admin-saved values override .env when present.
- Set
APP_URLand Admin → Settings → General → Site URL to your public HTTPS domain. - Register webhook URLs at each provider (see sections above).
- Enable each provider toggle and save required keys.
- Run sandbox/test checkout for subscriptions and credit packs from Dashboard → Billing.
- Confirm invoice creation and entitlements (credits or active subscription).
- For production, switch Revolut to production, Stripe to live keys, and Cryptomus/Flutterwave to live credentials.
Admin refunds
- Stripe: payment intent refund when allowed.
- Flutterwave: transaction refund API.
- Revolut: order refund API.
- Cryptomus: refund with admin-supplied wallet address; entitlements reversed on success.
Social Login (Google, GitHub, Discord)
- Google Cloud Console → OAuth client (Web).
- Redirect URI:
https://yourdomain.com/auth/google/callback
GOOGLE_CLIENT_ID=...GOOGLE_CLIENT_SECRET=...GOOGLE_REDIRECT_URI=${APP_URL}/auth/google/callbackGitHub
github.com/settings/developers → OAuth App → Authorization callback URL https://yourdomain.com/auth/github/callback
GITHUB_CLIENT_ID=...GITHUB_CLIENT_SECRET=...Discord
discord.com/developers/applications → OAuth2 → Redirect https://yourdomain.com/auth/discord/callback
DISCORD_CLIENT_ID=...DISCORD_CLIENT_SECRET=...Leave blank to hide social login buttons (FEATURE_SOCIAL_LOGIN=true still requires keys).
Cloudflare Turnstile (Captcha)
Portal: Cloudflare Dashboard → Turnstile → Add site widget for your domain.
TURNSTILE_SITE_KEY=0x4AAAA...TURNSTILE_SECRET_KEY=0x4AAAA...Prefer Admin → Settings → Security for runtime updates.
SMTP Email
Use your hosting mailbox or transactional provider (Brevo, Mailgun, Amazon SES).
MAIL_MAILER=smtpMAIL_HOST=mail.yourdomain.comMAIL_PORT=587MAIL_USERNAME=info@yourdomain.comMAIL_PASSWORD=...MAIL_FROM_ADDRESS=info@yourdomain.comTest from Admin → Settings → Mail → Send test email.
Pusher & Reverb (Real-Time)
Pusher (managed)
dashboard.pusher.com → Create app → copy app id, key, secret, cluster.
BROADCAST_CONNECTION=pusherPUSHER_APP_ID=...PUSHER_APP_KEY=...PUSHER_APP_SECRET=...PUSHER_APP_CLUSTER=mt1Reverb (self-hosted VPS)
See VPS documentation for generating REVERB_APP_KEY and REVERB_APP_SECRET.
Full .env Reference (MelodAI)
Core application and infrastructure variables from .env.example:
| Variable | Purpose |
|---|---|
| APP_NAME | Application display name |
| APP_ENV | local | production |
| APP_DEBUG | true locally, false in production |
| APP_URL | Public HTTPS base URL of Laravel app |
| CRON_SECRET_TOKEN | Optional fallback for HTTP /cron/* endpoints |
| DB_* | MySQL connection credentials |
| QUEUE_CONNECTION | database (default) or redis with Horizon on VPS |
| CACHE_STORE | database or redis |
| SANCTUM_TOKEN_EXPIRATION | Mobile API token lifetime in minutes |
| FILESYSTEM_DISK | local or cloudflare (R2) |
| FFMPEG_BINARIES / FFPROBE_BINARIES | Paths to FFmpeg binaries |
| SUPER_ADMIN_EMAIL | Email for super admin notifications |
| TELESCOPE_ENABLED | false in production |
Feature flags:
| Variable | Purpose |
|---|---|
| FEATURE_BLOG | Enable blog module |
| FEATURE_SOCIAL_LOGIN | Show OAuth login buttons when keys exist |
| FEATURE_TWO_FACTOR | Enable 2FA for users |
| DEFAULT_CREDITS_FREE | Free credits for new users |
Admin Settings Mapping
- General: Site name, Site URL (cron base), contact emails
- AI: OpenAI, xAI, Suno, FAL defaults
- Mail: SMTP host, port, credentials (overrides .env at runtime)
- Payment: Stripe, Flutterwave, Revolut, Cryptomus toggles and keys
- YouTube: OAuth client and redirect URI
- Security: Turnstile keys
- Cron & Queue: HTTP cron URLs and cPanel commands