diff --git a/internal/start/start.go b/internal/start/start.go index 9263a0b22..b382f50c4 100644 --- a/internal/start/start.go +++ b/internal/start/start.go @@ -843,6 +843,7 @@ EOF "SUPABASE_ANON_KEY=" + utils.Config.Auth.AnonKey, "SUPABASE_SERVICE_KEY=" + utils.Config.Auth.ServiceRoleKey, "LOGFLARE_API_KEY=" + utils.Config.Analytics.ApiKey, + "OPENAI_KEY=" + utils.Config.Studio.OpenaiApiKey, fmt.Sprintf("LOGFLARE_URL=http://%v:4000", utils.LogflareId), fmt.Sprintf("NEXT_PUBLIC_ENABLE_LOGS=%v", utils.Config.Analytics.Enabled), fmt.Sprintf("NEXT_ANALYTICS_BACKEND_PROVIDER=%v", utils.Config.Analytics.Backend), diff --git a/internal/utils/config.go b/internal/utils/config.go index 5e07dbbfa..177751696 100644 --- a/internal/utils/config.go +++ b/internal/utils/config.go @@ -213,7 +213,7 @@ var Config = config{ } // We follow these rules when adding new config: -// 1. Update init_config.toml with the new key, default value, and comments to explain usage. +// 1. Update init_config.toml (and init_config.test.toml) with the new key, default value, and comments to explain usage. // 2. Update config struct with new field and toml tag (spelled in snake_case). // 3. Add custom field validations to LoadConfigFS function for eg. integer range checks. // @@ -286,9 +286,10 @@ type ( } studio struct { - Enabled bool `toml:"enabled"` - Port uint `toml:"port"` - ApiUrl string `toml:"api_url"` + Enabled bool `toml:"enabled"` + Port uint `toml:"port"` + ApiUrl string `toml:"api_url"` + OpenaiApiKey string `toml:"openai_api_key"` } inbucket struct { @@ -560,6 +561,7 @@ func LoadConfigFS(fsys afero.Fs) error { if Config.Studio.Port == 0 { return errors.New("Missing required field in config: studio.port") } + Config.Studio.OpenaiApiKey, _ = maybeLoadEnv(Config.Studio.OpenaiApiKey) } // Validate email config if Config.Inbucket.Enabled { diff --git a/internal/utils/templates/init_config.test.toml b/internal/utils/templates/init_config.test.toml index 086b34dd8..ecbde4918 100644 --- a/internal/utils/templates/init_config.test.toml +++ b/internal/utils/templates/init_config.test.toml @@ -49,6 +49,8 @@ enabled = true port = 54323 # External URL of the API server that frontend connects to. api_url = "http://127.0.0.1" +# OpenAI API Key to use for Supabase AI in the Supabase Studio. +openai_api_key = "env(OPENAI_API_KEY)" # Email testing server. Emails sent with the local dev setup are not actually sent - rather, they # are monitored, and you can view the emails that would have been sent from the web interface. diff --git a/internal/utils/templates/init_config.toml b/internal/utils/templates/init_config.toml index 55ea84d62..dbbadd06c 100644 --- a/internal/utils/templates/init_config.toml +++ b/internal/utils/templates/init_config.toml @@ -49,6 +49,8 @@ enabled = true port = 54323 # External URL of the API server that frontend connects to. api_url = "http://127.0.0.1" +# OpenAI API Key to use for Supabase AI in the Supabase Studio. +openai_api_key = "env(OPENAI_API_KEY)" # Email testing server. Emails sent with the local dev setup are not actually sent - rather, they # are monitored, and you can view the emails that would have been sent from the web interface.