AiTechWorlds
AiTechWorlds
A well configured development environment makes agent development dramatically less frustrating. This lesson walks through everything you need: Python environment, API keys, essential packages, and the project structure that scales as your agents grow.
Use a virtual environment or conda to keep agent project dependencies isolated:
# Create a new project directory
mkdir my-agent && cd my-agent
# Create virtual environment
python -m venv .venv
# Activate (Windows)
.venv\Scripts\activate
# Activate (Mac/Linux)
source .venv/bin/activate
# Verify Python version
python --version # Should be 3.11 or 3.12Install the foundation:
# LLM SDKs
pip install openai anthropic
# LangChain ecosystem
pip install langchain langchain-openai langchain-anthropic langchain-community
# LangGraph (for multi-agent and graph-based workflows)
pip install langgraph
# Vector database clients
pip install chromadb pinecone-client
# Search and tools
pip install tavily-python # Web search API
pip install duckduckgo-search # Free search (lower quality)
# Utilities
pip install python-dotenv # Load .env files
pip install pydantic # Data validation
pip install rich # Pretty terminal output
pip install httpx # Async HTTP client
# Save your requirements
pip freeze > requirements.txtCreate a .env file in your project root:
# .env
OPENAI_API_KEY=sk-proj-...
ANTHROPIC_API_KEY=sk-ant-...
TAVILY_API_KEY=tvly-...
LANGCHAIN_API_KEY=... # For LangSmith tracing (optional but valuable)
LANGCHAIN_TRACING_V2=true # Enable LangSmith tracing
LANGCHAIN_PROJECT=my-agent # Project name in LangSmith
# For vector databases
PINECONE_API_KEY=...
PINECONE_ENVIRONMENT=us-east-1
# For later — if you deploy
REDIS_URL=redis://localhost:6379Add .env to .gitignore immediately:
echo ".env" >> .gitignore
echo ".venv/" >> .gitignore
echo "__pycache__/" >> .gitignore
echo "*.pyc" >> .gitignoreLoad environment variables in your Python code:
from dotenv import load_dotenv
import os
load_dotenv() # Loads .env file
openai_key = os.environ["OPENAI_API_KEY"] # Raises error if missing
anthropic_key = os.getenv("ANTHROPIC_API_KEY") # Returns None if missing.env you won't see it againMinimum required for this course: OpenAI API key ($5-10 for typical development work)
LangSmith provides observability for your agents you can see exactly what prompts were sent, what tools were called, how long each step took, and what the LLM returned.
.env with the variables aboveOnce configured, every LangChain/LangGraph run is automatically traced and visible in the LangSmith dashboard.
A clean structure that scales:
my-agent/
├── .env # API keys (never commit)
├── .gitignore
├── requirements.txt
├── README.md
│
├── agents/
│ ├── __init__.py
│ ├── research_agent.py # Agent definitions
│ └── coding_agent.py
│
├── tools/
│ ├── __init__.py
│ ├── search.py # Tool implementations
│ ├── code_execution.py
│ └── file_tools.py
│
├── memory/
│ ├── __init__.py
│ └── vector_store.py # Vector database setup
│
├── prompts/
│ └── templates.py # System prompts as constants
│
└── main.py # Entry pointCreate test_setup.py and run it:
# test_setup.py
import os
from dotenv import load_dotenv
load_dotenv()
def test_openai():
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Say 'setup successful' and nothing else"}]
)
print(f"OpenAI: {response.choices[0].message.content}")
def test_anthropic():
import anthropic
client = anthropic.Anthropic()
message = client.messages.create(
model="claude-haiku-4-5-20251001",
max_tokens=50,
messages=[{"role": "user", "content": "Say 'setup successful' and nothing else"}]
)
print(f"Anthropic: {message.content[0].text}")
def test_tavily():
from tavily import TavilyClient
client = TavilyClient(api_key=os.environ["TAVILY_API_KEY"])
result = client.search("Python agent development", max_results=1)
print(f"Tavily: Found {len(result['results'])} results")
def test_langchain():
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o-mini")
response = llm.invoke("Say 'langchain works' and nothing else")
print(f"LangChain: {response.content}")
if __name__ == "__main__":
print("Testing setup...\n")
test_openai()
test_anthropic()
test_tavily()
test_langchain()
print("\nAll tests passed!")Run with python test_setup.py. Fix any failures before continuing.
LLM APIs charge per token. Develop cheaply:
Use smaller models for testing:
# During development
model = "gpt-4o-mini" # ~15x cheaper than gpt-4o
model = "claude-haiku-4-5-20251001" # Cheapest Claude
# Switch to powerful models only when needed
model = "gpt-4o"
model = "claude-sonnet-4-6"Set spending limits: OpenAI lets you set a monthly cap set $20-30 during development to prevent unexpected charges.
Use LangSmith to see where you're spending: Token counts per run are visible in traces.
Cache where possible: LangChain and LangGraph have built in caching repeat calls with identical prompts return cached responses for free during development.
VS Code extensions for agent development:
.vscode/settings.json:
{
"python.defaultInterpreterPath": ".venv/bin/python",
"python.linting.enabled": true,
"editor.formatOnSave": true,
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter"
}
}With this environment set up, you're ready to start building agents. The next lesson begins with LangChain the most widely used agent framework.
Next lesson: LangChain architecture understanding the components that power AI agents.
Get this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises