Skip to main content

Environment Setup

This guide will help you set up your development environment for building RAG applications with LlamaIndex.

Prerequisites

  • Python 3.8+ - Programming language
  • Git - Version control
  • Code Editor - VS Code, PyCharm, or your preferred editor

Installation Steps

1. Clone the Repository

git clone https://github.com/llm-stacks/llm-learning-guide.git
cd llm-learning-guide

2. Create Virtual Environment

# Create virtual environment
python -m venv venv

# Activate virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate

3. Install Dependencies

pip install -r requirements.txt

4. Environment Variables

Create a .env file in the project root:

# OpenAI API (recommended)
OPENAI_API_KEY=your_openai_api_key_here

# Or OpenRouter API (alternative)
OPENROUTER_API_KEY=your_openrouter_api_key_here

# Hugging Face (for embeddings)
HUGGINGFACE_API_KEY=your_huggingface_api_key_here

API Key Setup

  1. Visit OpenAI Platform
  2. Create an account and navigate to API Keys
  3. Create a new API key
  4. Add to your .env file

Option 2: OpenRouter API (Alternative)

  1. Visit OpenRouter
  2. Sign up and get your API key
  3. Add to your .env file

Verify Installation

Run the verification script:

python verify_setup.py

You should see:

✅ Python environment: OK
✅ Dependencies: OK
✅ API keys: OK
✅ All systems ready!

Next Steps

Now you're ready to build your first RAG application!

👉 Start with: Simple RAG Tutorial

Troubleshooting

Common Issues

Python version error

python --version  # Should be 3.8+

API key not found

  • Check your .env file format
  • Ensure no extra spaces around the = sign
  • Restart your terminal after adding environment variables

Import errors

pip install --upgrade pip
pip install -r requirements.txt --force-reinstall

Need help? Open an issue on GitHub!