Demo page with `wasp new <project-name> -t saas` can't launch due to missing OpenAI API key

Is there a way to use wasp new <project-name> -t saas but simply disable OpenAI? I still think it should not crash the whole build and launch process at wasp start simply because no API key was provided in the .env.server.example
3 Replies
kapa.ai
kapa.ai5w ago
Hi @tim.enchanter. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the available knowledge sources, the current OpenSaaS (saas) template for Wasp requires an OpenAI API key to be set in your environment variables; otherwise, the app will crash at startup with an error like:
[Server!] Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'my apiKey' }).
[Server!] Error: The OPENAI_API_KEY environment variable is missing or empty; either provide it, or instantiate the OpenAI client with an apiKey option, like new OpenAI({ apiKey: 'my apiKey' }).
This is a known pain point, as seen in community discussions, but there is no official documentation or built-in flag to simply disable the OpenAI integration when using the saas template. The template expects the key to be present, and if it is missing, the app fails to start. The error message and community responses indicate that the only current workaround is to provide a (possibly dummy) value for the OPENAI_API_KEY in your .env.server file, or to manually modify the generated code to bypass or stub out the OpenAI-dependent features if you do not wish to use them at all. There is no mention of a template option or environment variable to disable OpenAI cleanly at project creation or runtime in the official docs or support threads [Available Templates]. If you want to avoid this issue, you could: - Add a dummy OPENAI_API_KEY to your .env.server to allow the app to start, but OpenAI features will not work. - Manually remove or comment out the OpenAI-dependent code in the generated project. The knowledge sources do not mention any official or supported way to disable OpenAI integration in the saas template at project creation or via configuration. This is a valid point for improvement in the template, as it should ideally degrade gracefully if the API key is missing [Discord support thread]. If you need a template without OpenAI, you may consider starting from a simpler template (like basic or todo-ts) and adding only the features you need. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @tim.enchanter, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
tim.enchanter
tim.enchanterOP5w ago
I tried with a dummy API as well but still crashes OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Filip
Filip5w ago
This is strange, it should work with a dummy key @tim.enchanter How are you providing the key Also, the app asks for the Open API key because parts of the app use open AI features (and the app defines a valdiation for the key). If you don't need open AI features, you can remove those parts of the app that use it and remove the validation for the env var.

Did you find this page helpful?