Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore(examples): openai env var for edge function example

Greg Richardsonf4feabb65a71
diff --git a/examples/edge-functions/supabase/.env.local.example b/examples/edge-functions/supabase/.env.local.example
index 2f2c44b56a5..4456221dc6c 100644
--- a/examples/edge-functions/supabase/.env.local.example
+++ b/examples/edge-functions/supabase/.env.local.example
@@ -11,4 +11,7 @@ FUNCTION_SECRET="random secret"
# stripe-webhooks
STRIPE_API_KEY="<YOUR API KEY HERE>"
-STRIPE_WEBHOOK_SIGNING_SECRET="<YOUR WEBHOOK SIGNING HERE>"
\ No newline at end of file
+STRIPE_WEBHOOK_SIGNING_SECRET="<YOUR WEBHOOK SIGNING HERE>"
+
+# openai
+OPENAI_API_KEY="<YOUR API KEY HERE>"
diff --git a/examples/edge-functions/supabase/functions/openai/README.md b/examples/edge-functions/supabase/functions/openai/README.md
index 9351df67647..4433aa6abb1 100644
--- a/examples/edge-functions/supabase/functions/openai/README.md
+++ b/examples/edge-functions/supabase/functions/openai/README.md
@@ -1,9 +1,15 @@
# openai
+## Setup env vars
+
+```bash
+cp supabase/.env.local.example supabase/.env.local
+```
+
## Run locally
```bash
-supabase functions serve --no-verify-jwt openai
+supabase functions serve --no-verify-jwt --env-file ./supabase/.env.local openai
```
Use cURL or Postman to make a POST request to http://localhost:54321/functions/v1/openai.
@@ -18,4 +24,5 @@ curl -i --location --request POST http://localhost:54321/functions/v1/openai \
```bash
supabase functions deploy --no-verify-jwt openai
+supabase secrets set --env-file ./supabase/.env.local
```