DEV Community

parkway
parkway

Posted on

How to provide API key via environment variables for Forem

To provide an API key via environment variables for a self-hosted Forem instance, you generally follow these steps:

Obtain your API key from the AI image generation service you plan to use.

Add the API key to your Forem server’s environment variables. This is typically done by adding a line such as

text
FOREM_IMAGE_GEN_API_KEY=your_api_key_here
in your environment configuration file, commonly a .env file at the root of your Forem project.

Alternatively, you can export the variable in your shell environment directly:

On Linux/macOS, run:

text
export FOREM_IMAGE_GEN_API_KEY='your_api_key_here'
On Windows, set the variable in the System Environment Variables or use PowerShell:

text
$env:FOREM_IMAGE_GEN_API_KEY='your_api_key_here'
Make sure your Forem application code is configured to read this environment variable, typically accessible in the backend via something like ENV['FOREM_IMAGE_GEN_API_KEY'].

Restart your Forem server to make the new environment variable active.

Confirm the key is being accessed by the application during runtime (e.g., via logs or debug).

This approach keeps the API keys secure and separate from the codebase, a standard practice when deploying self-hosted applications. Forem’s open-source documentation or GitHub repo should specify the exact environment variable name and usage details for the cover image generation integration, but the pattern above is the common and secure way to provide API keys via environment variables
temu coupon code $100 off

Top comments (0)