What is it?
The Python ecosystem offers many AI-related packages. This page is a decision guide by job-to-be-done, not a ranked leaderboard. Names you see in articles (HTTP clients, official provider SDKs, LangChain, LlamaIndex, NumPy/pandas, vector helpers) illustrate categories. Prefer one clear tool per role.
Why it matters
Installing everything creates version conflicts and hides what your program actually does. A thin stack is easier to secure, evaluate and replace. Understanding roles also clarifies when a framework helps versus when direct API calls are enough.
How to do it
Map your need to a role:
- Standard library — files, JSON, CSV,
urllib, argparse, logging. Enough for many scripts (JSON and CSV Handling for AI Work in Python, Calling AI and Model APIs with Python). - HTTP client — use when you want connection pooling, clearer timeouts or session helpers (
urllibremains valid). - Provider SDK — optional convenience around one vendor's API; keep business logic outside it.
- Data library — tables, joins, group-bys on larger CSV/Parquet sets.
- Embeddings / vector helper — batch embedding, local similarity, or talking to a vector database.
- Agent / orchestration framework — tool registries, multi-step graphs, multi-agent wiring. Choose only after a hand-written loop hurts (How to Choose an Agent Framework).
Write a one-page ADR (architecture decision record) when you add a heavy dependency.
Example
| Job | Lean choice | Heavier choice when needed |
|---|---|---|
| Call chat API | stdlib urllib + JSON | Official SDK |
| Eval CSV of questions | csv module | pandas / Polars |
| Toy RAG over 200 files | lists + cosine in pure Python | Vector DB client |
| Many tools + retries + tracing | Your own loop first | Orchestration framework |
A team might start with stdlib HTTP for chat and JSONL for eval scores, then add a vector database client when retrieval latency requires an index — without adopting an agent framework yet.
When to use it
Revisit library choices when onboarding cost rises, when cold-start scripts need twenty imports to print one completion, or when you cannot explain which package owns retries and which owns prompts.
Practical notes
When you evaluate a new package, write a twenty-line spike that performs your real job — one chat call, one embed, one retrieve — and measure latency and failure modes. Prefer libraries that let you swap the underlying HTTP client so tests can mock the network. Be wary of packages that download large models on import. Pin versions in 'requirements.txt' or a lockfile once a spike succeeds. If two libraries both claim to "do agents", pick one and delete the other from the environment; overlapping abstractions make tool permission bugs harder to see. Revisit the thin-stack choice every time you add a new production dependency.
Common mistakes
- Adding an agent framework on day one for a single prompt.
- Depending on two frameworks that both wrap the same API.
- Letting a notebook install packages globally instead of a venv.
- Treating a framework tutorial as a security model — you still validate tools (Agent Tools: How AI Agents Take Actions).