Move Stripe and AI keys out of Lovable

An app with AI or payments reads secret keys in its edge functions. Lovable keeps those keys for you and they do not come with the code. Before the app runs without Lovable, you add every key again and move the Stripe webhook.

Payments and AI that keep working after the move

Do you need this?

Only if the backend moves from Lovable Cloud to your own Supabase project. If the app keeps Lovable Cloud, its secrets stay in Lovable and keep working, also when you host the app somewhere else.

1. Find the names your app needs

Paste this into Claude Code, Codex or Cursor in the project folder:

Search the code and the supabase/functions folder for every secret the functions read. List the names only and where each one is used. Do not print any value.

2. Get each key

SecretWhere to get it
OPENAI_API_KEYplatform.openai.com, API keys
STRIPE_SECRET_KEYStripe, Developers, API keys. In a sandbox it starts with sk_test_.
STRIPE_WEBHOOK_SECRETStripe, the new event destination you create in step 3, Signing secret. It starts with whsec_.
The Stripe API keys page in test mode with the key values hidden

3. Move the Stripe webhook

Payment providers like Stripe tell your app about payments by calling a fixed address (a webhook). Change that address to your new backend.

In Stripe create a new event destination with the address of the function that handles the webhook in your new project. The old signing secret does not work for it.

https://YOUR-PROJECT-REF.supabase.co/functions/v1/FUNCTION-NAME
The Stripe form for a new event destination with the endpoint URL filled in

Then open the new destination and copy its signing secret. That is your STRIPE_WEBHOOK_SECRET.

The details of a Stripe event destination with the endpoint URL and a hidden signing secret

4. Add them in Supabase

Add every key in the Supabase dashboard under Edge Functions, Secrets, with the same name as before. Do not paste the values into the chat.

Open Edge Functions, Secrets again. You should see every key name the edge functions read.

The Lovable AI key does not come with you

If the app uses the AI built into Lovable, its functions call the Lovable AI gateway with a key that only works there. A new key is not enough. Change those functions so they call your AI provider's API directly, with your own key as a secret. Your AI tool can do this for you.

5. Test with a test card

Use a sandbox or test mode at your payment provider so no real money moves. In a Stripe sandbox use the test card:

FieldTest value
Card number4242 4242 4242 4242
ExpiryAny date in the future
CVCAny three digits
The Stripe sandbox checkout for a monthly subscription with the test card filled in

Send one AI request and make one test payment in the app. You should see the AI answer on screen and the payment in the provider dashboard.

Sources

  1. Lovable docs: Secrets
  2. Supabase docs: Edge Function secrets
  3. Stripe docs: Webhooks
  4. Stripe docs: Testing

Read next

Pick your route.

Choose where you are and where you want to go. The guide takes it from there.