Skip to content

Setup & Prerequisites

Get a clean Python environment and an API key so every example in Bee just works.

Overview

You need three things: Python 3.10+, an isolated environment (so projects don't clash), and an API key. This page sets all three up in about five minutes.

Learning Objectives

After this page you will be able to:

  • Create an isolated Python environment with uv (or venv).
  • Store an API key safely using a .env file.
  • Verify your setup with a one-line check.

1. Install Python 3.10+

Check what you have:

python3 --version

If it's older than 3.10 (or missing), install a current version from python.org or via your package manager (brew install python, apt install python3).

2. Choose an environment tool

We recommend uv โ€” it's fast and manages both Python versions and dependencies. Standard venv + pip works everywhere too.

# Install uv (macOS/Linux)
curl -LsSf https://astral.sh/uv/install.sh | sh

# In an example folder, uv handles the venv for you:
cd examples/01-chatbot
uv sync            # creates .venv and installs pinned deps
uv run python -m app
python3 -m venv .venv
source .venv/bin/activate      # Windows: .venv\Scripts\activate
pip install anthropic python-dotenv

Why isolate?

A virtual environment keeps each project's dependencies separate, so upgrading one project never breaks another. Never pip install into your system Python.

3. Get an API key

Bee's examples default to Anthropic, but any provider works โ€” the concepts are the same.

  1. Create an account with a provider (e.g. Anthropic Console).
  2. Generate an API key.
  3. Never commit it. Store it in a .env file (which is git-ignored):
.env
ANTHROPIC_API_KEY=sk-ant-your-key-here

Load it in Python with python-dotenv:

import os
from dotenv import load_dotenv

load_dotenv()                       # reads .env into environment variables
api_key = os.environ["ANTHROPIC_API_KEY"]

Protect your key

An API key is a password that can spend real money. Never paste it into code, commit it, or share it in an issue. If a key leaks, revoke it immediately in your provider's console.

4. Verify your setup

python3 -c "import anthropic, dotenv; print('โœ… Ready to build with Bee')"

If that prints the success message, you're ready.

Best Practices

  • โœ… One virtual environment per project.
  • โœ… Keep secrets in .env; commit a .env.example with placeholder values.
  • โœ… Pin dependency versions so examples stay reproducible.

Common Mistakes

  • โŒ Installing packages globally โ€” leads to version conflicts. Use a venv.
  • โŒ Committing your .env โ€” add it to .gitignore (Bee's already does).
  • โŒ Hardcoding the API key in your script โ€” load it from the environment.

Exercises

  1. Create a fresh environment and install the anthropic SDK.
  2. Add your key to a .env file and load it in a script โ€” print only the length of the key to confirm it loaded (never print the key itself).

References


Next: Your First LLM Call โ†’