Installation#
AdalFlow is available in Python.
1. Install AdalFlow#
To install the package, run:
pip install adalflow
If you know you will need openai and faiss-cpu, you can do so with:
pip install adalflow[openai, faiss-cpu]
Note
Check the Optional Packages section for more information on the available packages.
2. Set up API keys#
A .env
file is recommended.
You can have it at your project root directory.
Here is an example:
OPENAI_API_KEY=YOUR_API_KEY_IF_YOU_USE_OPENAI
GROQ_API_KEY=YOUR_API_KEY_IF_YOU_USE_GROQ
ANTHROPIC_API_KEY=YOUR_API_KEY_IF_YOU_USE_ANTHROPIC
GOOGLE_API_KEY=YOUR_API_KEY_IF_YOU_USE_GOOGLE
COHERE_API_KEY=YOUR_API_KEY_IF_YOU_USE_COHERE
HF_TOKEN=YOUR_API_KEY_IF_YOU_USE_HF
3. Load environment variables#
You can use the following import:
from adalflow.utils import setup_env
setup_env()
Or, you can load it yourself with python-dotenv
:
from dotenv import load_dotenv
load_dotenv() # This loads the environment variables from `.env`.
This setup ensures that AdalFlow can access all necessary configurations during runtime.
4. Install Optional Packages#
AdalFlow currently has built-in support for (1) OpenAI, Groq, Anthropic, Google, and Cohere, and (2) FAISS and Transformers.
You can find all optional packages at OptionalPackages
.
Make sure to install the necessary SDKs for the components you plan to use.
Here is the list of our tested versions:
openai = "^1.12.0"
groq = "^0.5.0"
faiss-cpu = "^1.8.0"
sqlalchemy = "^2.0.30"
pgvector = "^0.3.1"
torch = "^2.3.1"
anthropic = "^0.31.1"
google-generativeai = "^0.7.2"
cohere = "^5.5.8"
You can install the optional packages with either pip install package_name
or pip install lightrag[package_name]
.