{"id":10033,"library":"phidata","title":"PhiData (phidata) Library","description":"PhiData (phidata) is a Python library designed for building multi-modal AI Agents with capabilities like memory, knowledge retrieval (RAG), and tool integration. It simplifies the development of complex AI workflows by providing high-level abstractions for agents, assistants, and various components. The current stable version is 2.7.10, and it maintains an active release cadence with frequent updates.","status":"active","version":"2.7.10","language":"en","source_language":"en","source_url":"https://github.com/phidatahq/phidata","tags":["LLM","Agent","AI","RAG","Tools","Assistant"],"install":[{"cmd":"pip install phidata","lang":"bash","label":"Base Installation"},{"cmd":"pip install \"phidata[gradio]\"","lang":"bash","label":"With Gradio UI (optional)"},{"cmd":"pip install \"phidata[qdrant]\"","lang":"bash","label":"With Qdrant VectorDB (optional)"},{"cmd":"pip install \"phidata[chroma]\"","lang":"bash","label":"With Chroma VectorDB (optional)"}],"dependencies":[{"reason":"Primary LLM integration, widely used.","package":"openai","optional":false},{"reason":"Data validation and settings management (v2 required).","package":"pydantic","optional":false},{"reason":"Loading environment variables from .env files.","package":"python-dotenv","optional":false},{"reason":"For building web UIs for agents.","package":"gradio","optional":true},{"reason":"For Qdrant vector database integration.","package":"qdrant-client","optional":true},{"reason":"For ChromaDB vector database integration.","package":"chromadb","optional":true},{"reason":"For Mistral AI LLM integration.","package":"mistralai","optional":true},{"reason":"For Anthropic LLM integration.","package":"anthropic","optional":true}],"imports":[{"note":"In phidata v1, 'Assistant' was often imported from `phi.assistant`. In v2, the explicit `phidata` path is required.","wrong":"from phi.assistant import Assistant","symbol":"Assistant","correct":"from phidata.assistant import Assistant"},{"note":"Similar to 'Assistant', 'Agent' moved from `phi.agent` to `phidata.agent` in v2.","wrong":"from phi.agent import Agent","symbol":"Agent","correct":"from phidata.agent import Agent"},{"note":"LLM providers also moved to the explicit `phidata.llm` path in v2.","wrong":"from phi.llm.openai import OpenAILLM","symbol":"OpenAILLM","correct":"from phidata.llm.openai import OpenAILLM"},{"note":"`PhiWorkflows` was renamed and refactored into `PhiApp` under `phidata.app` in v2.","wrong":"from phidata.workflows import PhiWorkflows","symbol":"PhiApp","correct":"from phidata.app import PhiApp"}],"quickstart":{"code":"import os\nfrom phidata.llm.openai import OpenAILLM\nfrom phidata.assistant import Assistant\n\n# Ensure OPENAI_API_KEY is set in your environment variables\n# For local development, you might use python-dotenv:\n# from dotenv import load_dotenv; load_dotenv()\n\n# Initialize LLM (e.g., OpenAI)\n# Replace with os.environ.get('OPENAI_API_KEY', '') for production if not using dotenv\nllm = OpenAILLM(model=\"gpt-4o\", api_key=os.environ.get('OPENAI_API_KEY', ''))\n\n# Create an Assistant\nassistant = Assistant(llm=llm, name=\"MyChatAssistant\")\n\n# Run a chat interaction\nresponse = assistant.chat(\"Hello, how are you?\")\nprint(f\"Assistant: {response}\")\n\nresponse = assistant.chat(\"What is the capital of France?\")\nprint(f\"Assistant: {response}\")\n\n# Example with a tool (requires 'pip install \"phidata[wikipedia]\"')\n# from phidata.tools.wikipedia import WikipediaTool\n# assistant_with_tool = Assistant(\n#     llm=llm,\n#     name=\"WikiAssistant\",\n#     tools=[WikipediaTool()]\n# )\n# response = assistant_with_tool.chat(\"Who is Marie Curie?\")\n# print(f\"WikiAssistant: {response}\")","lang":"python","description":"This quickstart demonstrates how to initialize an OpenAI LLM and create a simple Assistant to handle chat interactions. It highlights the basic setup for agents in phidata. Remember to set your `OPENAI_API_KEY` environment variable."},"warnings":[{"fix":"Migrate your codebase to the phidata v2 API. Refer to the official documentation (docs.phidata.dev) for updated import paths, class names, and configuration patterns.","message":"Phidata v2 introduced significant breaking changes compared to v1. Imports, configuration (from YAML to Python classes), and core APIs (e.g., `workflows` module) were completely refactored. Code written for v1 will not work with v2.","severity":"breaking","affected_versions":"1.x -> 2.x"},{"fix":"Ensure all dependencies in your project are compatible with Pydantic v2, or use a tool like `pip-tools` or `poetry` for robust dependency resolution. Isolate environments if necessary.","message":"Phidata requires Pydantic v2. If your project has other dependencies that explicitly pin Pydantic v1, you may encounter dependency conflicts or runtime errors due to incompatible Pydantic models.","severity":"gotcha","affected_versions":"2.x"},{"fix":"Set the required API key as an environment variable (e.g., `export OPENAI_API_KEY='sk-...'`). For local development, consider using `python-dotenv` to load keys from a `.env` file.","message":"All LLM integrations (OpenAI, Mistral, Anthropic, etc.) require their respective API keys to be set as environment variables (e.g., `OPENAI_API_KEY`). Failing to set these will result in authentication errors.","severity":"gotcha","affected_versions":"2.x"},{"fix":"Install phidata with the necessary extras using `pip install \"phidata[extra_name]\"`. For example, `pip install \"phidata[qdrant]\"` for Qdrant support. Consult the phidata documentation for a list of available extras.","message":"Many advanced features, tools, and vector database integrations (e.g., Gradio UI, Qdrant, ChromaDB, specific LLMs like Mistral/Anthropic) require installing phidata with optional 'extras'. Without these, you will encounter `ModuleNotFoundError`.","severity":"gotcha","affected_versions":"2.x"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Set the environment variable for your LLM provider. For OpenAI, `export OPENAI_API_KEY='sk-...'` or add `OPENAI_API_KEY=sk-...` to a `.env` file and use `python-dotenv`.","cause":"The required LLM API key (e.g., OPENAI_API_KEY) environment variable is not set or is incorrect.","error":"openai.AuthenticationError: No API key provided."},{"fix":"Install phidata with the necessary extra: `pip install \"phidata[qdrant]\"`. Replace `qdrant` with the appropriate extra for the missing module (e.g., `chroma`, `gradio`).","cause":"You are trying to use a feature (e.g., Qdrant vector database) that requires an optional dependency which was not installed.","error":"ModuleNotFoundError: No module named 'qdrant_client'"},{"fix":"Update your code to use the phidata v2.x API. For this specific error, `phidata.workflows` was renamed and moved to `phidata.app.PhiApp`. Consult the v2 documentation for correct imports.","cause":"Attempting to use a module or class path from phidata v1.x (e.g., `phidata.workflows` or `phi.assistant`) with a phidata v2.x installation. The API was refactored in v2.","error":"AttributeError: module 'phidata' has no attribute 'workflows'"},{"fix":"Ensure all Pydantic-dependent libraries are compatible with Pydantic v2. Check the data structures you are providing to phidata components against the expected Pydantic models in the documentation.","cause":"This can occur if you have a mix of Pydantic v1 and v2 libraries in your environment, or if you're passing incorrect data types to phidata models expecting Pydantic v2 behavior.","error":"ValidationError: 'Model' object has no attribute 'field_name' (related to Pydantic)"}]}