AI Generator

We added feature for AI chatbot and Image generator in recent version. To use this feature, you need to enable the AI option from your backend and add the Open AI Api key to your app for this feature to work.

Enable AI feature from Backend

  1. Login to the backend and click on the Settings menu

  2. On the settings page, click on App Settings

  3. On the App Settings page, scroll down to the AI Settings. Enable the ai feature you want, either AI Chat or AI Image Generator or both option.

  4. then save the settings.

Set OpenAI api key in app code

You need to get API key from your openAI bashboard. Checkout the link below on how to get your api key: https://www.howtogeek.com/885918/how-to-get-an-openai-api-key/

You need to set your api key in the mobile app source code for the ai feature to work on the mobile app.

  1. Create a .env file in the root of the flutter app folder. If there is a .env file in the root folder already then no need in create any one.

  2. Open the .env file in the flutter app code.

  3. Add a key name OPENAI_API_KEY and set your api key in there. Example below: OPENAI_API_KEY="sk-7sdsdsdC"

  4. save the .env file

Now, you need to run a command to so the app is aware of the new key you just set. The command is as stated below:

flutter pub run build_runner build

After the command has finished successfully, you can now run your app with no issue.

AI Feature throws invalid api key error

When modifying the .env file, the generator might not pick up the change, if that happens simply clean the build cache and run the generator again.

dart run build_runner clean
dart run build_runner build --delete-conflicting-outputs

Last updated