examples/integration-e2b/README.md
This example shows a complete prompt→LLM→sandboxed-execution→metric pipeline using:
promptfoo to run LLM prompts and manage evaluation cases.e2b-code-interpreter) to run generated code safely.You can run this example with:
npx promptfoo@latest init --example integration-e2b
cd integration-e2b
Set these in your shell before running the example.
# Required
export E2B_API_KEY="e2b_xxx_your_key_here" # e2b sandbox API key
export OPENAI_API_KEY="sk_xxx_your_key_here" # OpenAI key (or your chosen LLM provider)
# Recommended
export PROMPTFOO_PYTHON="$(pwd)/.venv/bin/python" # tell promptfoo which Python/venv to use
Install and prepare a Python virtual environment, and install the required packages.
# create & activate venv
python -m venv .venv
source .venv/bin/activate
# install Python packages
pip install --upgrade pip
pip install e2b-code-interpreter
npm i -g promptfoo
Activate venv and ensure env vars are set:
source .venv/bin/activate
export E2B_API_KEY="e2b_xxx"
export OPENAI_API_KEY="sk_xxx"
export PROMPTFOO_PYTHON="$(pwd)/.venv/bin/python"
Run the evaluation:
promptfoo eval
Open the interactive viewer:
promptfoo view