This guide explains how to set up the environment variables required for the Pen2PDF application.
Create a .env file in the backend directory with the following variables:
cd backend
touch .envAdd the following content to the .env file:
# Google Gemini AI API Key (Required for AI features)
# Get your API key from: https://ai.google.dev/
GEMINI_API_KEY=your_gemini_api_key_here
# LongCat API Key (Required for AI Assistant LongCat models)
# Get your API key from LongCat
LONGCAT_API_KEY=your_longcat_api_key_hereThe application supports both naming conventions for compatibility:
GEMINI_API_KEY(recommended)geminiApiKey(alternative)
LONGCAT_API_KEY(recommended)longcatApiKey(alternative)
- Visit Google AI Studio
- Sign in with your Google account
- Create a new API key
- Copy the API key to your
.envfile
- Contact LongCat or visit their platform
- Get your API key from the documentation provided
- Copy the API key to your
.envfile
- Never commit your
.envfile to version control - it's already in.gitignore - Keep your API keys secure and don't share them publicly
- If you accidentally expose an API key, regenerate it immediately
After setting up your .env file:
-
Restart your backend server:
cd backend node index.js -
Test the AI Assistant:
- Open the AI Assistant from the main page
- Try sending a message with Gemini models
- Try sending a message with LongCat models
If you see error messages about API keys, verify:
- The
.envfile exists in thebackenddirectory - The API keys are correctly copied (no extra spaces or quotes)
- The environment variable names match exactly
- Ensure
LONGCAT_API_KEYis set in your.envfile - Restart the backend server after adding the key
- Check your internet connection
- Verify your Gemini API key is valid
- Check if there are any firewall/proxy restrictions
- Verify your LongCat API key is valid
- Check the LongCat service status
- Ensure you have proper internet connectivity