{"id":24534425,"url":"https://github.com/blairhudson/fastapi-agents","last_synced_at":"2025-04-14T21:50:58.430Z","repository":{"id":272125880,"uuid":"915611987","full_name":"blairhudson/fastapi-agents","owner":"blairhudson","description":"A FastAPI extension for integrating common AI agent frameworks.","archived":false,"fork":false,"pushed_at":"2025-01-21T22:04:07.000Z","size":1090,"stargazers_count":32,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T05:16:05.339Z","etag":null,"topics":["agents","fastapi","llama-index","pydantic-ai","smolagents"],"latest_commit_sha":null,"homepage":"https://fastapi-agents.blairhudson.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blairhudson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":"ROADMAP.md","authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":".zenodo.json"},"funding":{"github":["blairhudson"]}},"created_at":"2025-01-12T10:40:09.000Z","updated_at":"2025-03-29T21:28:44.000Z","dependencies_parsed_at":null,"dependency_job_id":"aca0bec4-6fdb-4795-97e0-9b2a4ec3698a","html_url":"https://github.com/blairhudson/fastapi-agents","commit_stats":null,"previous_names":["blairhudson/fastapi-agents"],"tags_count":24,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blairhudson%2Ffastapi-agents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blairhudson%2Ffastapi-agents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blairhudson%2Ffastapi-agents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blairhudson%2Ffastapi-agents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blairhudson","download_url":"https://codeload.github.com/blairhudson/fastapi-agents/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248968741,"owners_count":21191158,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["agents","fastapi","llama-index","pydantic-ai","smolagents"],"created_at":"2025-01-22T11:17:09.207Z","updated_at":"2025-04-14T21:50:58.418Z","avatar_url":"https://github.com/blairhudson.png","language":"Python","funding_links":["https://github.com/sponsors/blairhudson"],"categories":[],"sub_categories":[],"readme":"# FastAPI Agents\n\n**FastAPI Agents** is the ultimate FastAPI extension for integrating AI agents into your applications. With just a few lines of code, you can create, manage, and secure AI-powered endpoints, enabling you to build smarter, more interactive apps effortlessly. Whether you're a seasoned developer or just exploring AI integrations, FastAPI Agents has you covered! 🎉\n\n## ✨ Features at a Glance\n\n- 🤖 **Easy Agent Management**: Register, organize, and interact with multiple AI agents seamlessly.\n- 🔐 **Built-In Security**: Easily add API key, OAuth2, cookie, or OpenID authentication to your endpoints.\n- 📚 **Agent Framework Support**: Compatible with agent frameworks like PydanticAI, Llama-Index, HuggingFace Smolagents and CrewAI.\n- 🐳 **Pre-Built Containers**: Easily deploy agents in your favourite framework with ready made containers.\n- 🔌 **OpenAI Compatibility**: Use your APIs with other AI tooling including the OpenAI SDK itself. (Experimental)\n- 🛠️ **Extensibility**: Support additional agent frameworks by extending the `BaseAgent` class.\n- 🧩 **Dynamic Dependencies**: Inject and resolve request-specific configurations effortlessly.\n- 🚀 **Performance Optimized**: Leverage FastAPI's high performance and scalability for AI agent interactions.\n- 📖 **Auto-Generated API Documentation**: OpenAPI integration for your registered agents, out of the box!\n\nSee [Releases](https://github.com/blairhudson/fastapi-agents/releases) for the latest updates at and [Roadmap](https://fastapi-agents.blairhudson.com/roadmap/) for what's coming.\n\n## 💖 Sponsors\n\nYou can support the ongoing development of FastAPI Agents by becoming a sponsor:\n\n[Sponsor FastAPI Agents](https://github.com/sponsors/blairhudson)\n\n## 📚 Documentation\n\nFor further documentation, including detailed API documentation for the available agent frameworks, visit the [FastAPI Agents Documentation](https://fastapi-agents.blairhudson.com/).\n\n## 🚀 Installation\n\nInstall `FastAPI Agents` using pip, poetry or uv:\n\n```bash\npip install fastapi-agents\npoetry add fastapi-agents\nuv add fastapi-agents\n```\n\nInstall optional extras for your chosen agent frameworks:\n\n```bash\npip install 'fastapi-agents[pydantic-ai]'\npoetry add fastapi-agents -E pydantic-ai\nuv add fastapi-agents --extra pydantic-ai\n```\n\nFor available extras, replace `pydantic-ai` with the desired agent framework (e.g. `smolagents` or `llama-index`). See [pyproject.toml](https://github.com/blairhudson/fastapi-agents/blob/main/pyproject.toml) for the full list of extras.\n\nThat's it! You're all set to start integrating AI agents into your FastAPI applications. 🎉\n\n## 🏁 Quick Start\n\n### Registering Agents\n\nHere’s how to get started with a basic `PydanticAI` agent:\n\n```python\nfrom fastapi import FastAPI\nfrom fastapi_agents import FastAPIAgents\nfrom pydantic_ai import Agent\n\n# Create a FastAPI application and FastAPIAgents instance.\napp = FastAPI()\nagents = FastAPIAgents(path_prefix=\"/agents\")\n\n# Initialize and register the agent. \n# The framework is automatically detected.\nagent = Agent(\"openai:gpt-4o-mini\")\nagents.register(\"pydanticai\", agent)\n\n# Include the router in your FastAPI application.\napp.include_router(agents)\n```\n\n### Adding Security\n\nSecure your endpoints with API Key authentication in just a few steps:\n\n```python\nfrom fastapi.security import APIKeyHeader\nfrom fastapi_agents import FastAPIAgents\n\n# Define API Key validation\ndef validate_api_key(api_key: str = Depends(APIKeyHeader(name=\"X-API-Key\"))):\n    if api_key != \"my-secret-api-key\":\n        raise HTTPException(status_code=403, detail=\"Invalid API Key\")\n\n# Secure the agents\nagents = FastAPIAgents(path_prefix=\"/agents\", security_dependency=validate_api_key)\n```\n\n👉 See [Security Examples](https://github.com/blairhudson/fastapi-agents/tree/main/examples/security) for more details.\n\n### Running the Application\n\nRun your FastAPI application with the registered agents:\n\n```bash\nuvicorn --reload \u003cmodule\u003e:app\n```\n\nReplace `\u003cmodule\u003e` with the name of the Python module containing your FastAPI application.\n\nThat's it! You're all set to start building smarter, more secure FastAPI applications with AI agents. 🚀\n\n## 🤝 Supported Agent Frameworks\n\n`FastAPI Agents` supports a variety of agent frameworks, including:\n\n1. **PydanticAI**: AI agents powered by Pydantic AI. [Examples](https://github.com/blairhudson/fastapi-agents/tree/main/examples/pydantic-ai)\n2. **Llama Index**: OpenAI agents with Llama Index integration. [Examples](https://github.com/blairhudson/fastapi-agents/tree/main/examples/llama-index)\n3. **HuggingFace Smolagents**: Lightweight and efficient AI agents. [Examples](https://github.com/blairhudson/fastapi-agents/tree/main/examples/smolagents)\n4. **CrewAI**: Multi-agent Framework to create Crews. [Examples](https://github.com/blairhudson/fastapi-agents/tree/main/examples/crewai)\n\n## 🐳 Using Docker\n\nFastAPI Agents provides pre-built Docker images for each agent framework. To get started, pull the desired image from the GitHub Container Registry (GHCR):\n\n```bash\ndocker pull ghcr.io/blairhudson/fastapi-agents:pydantic-ai\n```\n\nFor more information, see the [FastAPI Agents Docker Documentation](https://fastapi-agents.blairhudson.com/docker/).\n\n## 💡 Examples\n\nExplore real-world examples for implementing `FastAPI Agents` in different scenarios, including step-by-by Jupyter notebook guides and standalone code samples.\n\nSee all available [Guides](https://fastapi-agents.blairhudson.com/notebooks/getting-started/) and [Example Code](https://fastapi-agents.blairhudson.com/examples) in the FastAPI Agents documentation.\n\n## 🤝 Contributing\n\nWe welcome contributions! To contribute:\n\n1. Fork the repository.\n2. Create a feature branch.\n3. Add any new tests and ensure they pass. i.e. `uv run pytest`.\n4. Submit a pull request.\n\nFor any questions or feature requests including additional agent frameworks, open an issue in the repository.\n\n## 📄 Citation\n\nIf you use **FastAPI Agents** in your work, please consider citing it using the metadata in the `CITATION.cff` file:\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.14635504.svg)](https://doi.org/10.5281/zenodo.14635504)\n\nThis DOI represents all versions of the project. For version-specific DOIs, refer to the [Zenodo project page](https://doi.org/10.5281/zenodo.14635504).\n\nAlternatively, you can use the following BibTeX entry:\n\n```bibtex\n@software{fastapi_agents,\n  author = {Blair Hudson},\n  title = {FastAPI Agents},\n  year = {2025},\n  version = {0.1},\n  doi = {10.5281/zenodo.14635504},\n  url = {https://github.com/blairhudson/fastapi-agents},\n  orcid = {https://orcid.org/0009-0007-4216-4555},\n  abstract = {FastAPI Agents is the ultimate FastAPI extension for integrating AI agents into your applications.}\n}\n```\n\n## 📜 License\n\nThis project is licensed under the MIT License. See the `LICENSE` file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblairhudson%2Ffastapi-agents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblairhudson%2Ffastapi-agents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblairhudson%2Ffastapi-agents/lists"}