Environment Variables
Overview
LLM Provider API Keys
Crowe uses environment variables to store API keys for various LLM providers, ensuring secure credential management and easy configuration across environments.
# OpenAI
OPENAI_API_KEY="your-openai-key"
# Anthropic
ANTHROPIC_API_KEY="your-anthropic-key"
# Google
GEMINI_API_KEY="your-gemini-key"
# Hugging Face
HUGGINGFACE_TOKEN="your-huggingface-token"
# Perplexity AI
PPLX_API_KEY="your-perplexity-key"
Security Best Practices
1. Managing Environment Files
Place a
.env
file in the root directory of your project.Always exclude
.env
from version control to prevent accidental exposure of secrets.Update
.gitignore
to include the.env
file:
echo ".env" >> .gitignore
2. Protecting API Keys
To keep your credentials safe:
Rotate keys periodically to reduce the risk of misuse.
Use separate keys for development and production environments.
Avoid embedding API keys directly in your source code.
Assign the minimal set of permissions required.
Actively monitor API usage for unexpected activity.
3. Configuration Template
Provide a .env.example
file to help others set up their environment without exposing your real keys:
# Essential Settings
OPENAI_API_KEY=""
ANTHROPIC_API_KEY=""
GROQ_API_KEY=""
WORKSPACE_DIR="agent_workspace"
# Optional Settings
CROWE_VERBOSE_MODE="False"
4. Loading Environment Variables in Python
import os
from dotenv import load_dotenv
# Load variables from .env file
load_dotenv()
# Retrieve values
workspace_dir = os.getenv("WORKSPACE_DIR")
openai_key = os.getenv("OPENAI_API_KEY")
Environment Setup Guide
#Install Dependencies
pip install python-dotenv
#Create Environment File
cp .env.example .env
#Configure Variables
Open .env in your text editor
Add your API keys and configuration
Save the file
#Verify Setup
import os
from dotenv import load_dotenv
load_dotenv()
assert os.getenv("OPENAI_API_KEY") is not None, "OpenAI API key not found"
Environment-Specific Configuration
#Development
WORKSPACE_DIR="agent_workspace"
CROWE_VERBOSE_GLOBAL="True"
#Production
WORKSPACE_DIR="/var/crowe/workspace"
CROWE_VERBOSE_GLOBAL="False"
Troubleshooting¶
Common Issues¶
Last updated