fastapi-agents
A FastAPI extension for integrating common AI agent frameworks.
Science Score: 67.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
✓DOI references
Found 6 DOI reference(s) in README -
✓Academic publication links
Links to: zenodo.org -
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.0%) to scientific vocabulary
Keywords
Repository
A FastAPI extension for integrating common AI agent frameworks.
Basic Info
- Host: GitHub
- Owner: blairhudson
- License: mit
- Language: Python
- Default Branch: main
- Homepage: https://fastapi-agents.blairhudson.com
- Size: 1.04 MB
Statistics
- Stars: 44
- Watchers: 2
- Forks: 2
- Open Issues: 0
- Releases: 21
Topics
Metadata Files
README.md
FastAPI Agents
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! 🎉
✨ Features at a Glance
- 🤖 Easy Agent Management: Register, organize, and interact with multiple AI agents seamlessly.
- 🔐 Built-In Security: Easily add API key, OAuth2, cookie, or OpenID authentication to your endpoints.
- 📚 Agent Framework Support: Compatible with agent frameworks like PydanticAI, Llama-Index, HuggingFace Smolagents and CrewAI.
- 🐳 Pre-Built Containers: Easily deploy agents in your favourite framework with ready made containers.
- 🔌 OpenAI Compatibility: Use your APIs with other AI tooling including the OpenAI SDK itself. (Experimental)
- 🛠️ Extensibility: Support additional agent frameworks by extending the
BaseAgentclass. - 🧩 Dynamic Dependencies: Inject and resolve request-specific configurations effortlessly.
- 🚀 Performance Optimized: Leverage FastAPI's high performance and scalability for AI agent interactions.
- 📖 Auto-Generated API Documentation: OpenAPI integration for your registered agents, out of the box!
See Releases for the latest updates at and Roadmap for what's coming.
💖 Sponsors
You can support the ongoing development of FastAPI Agents by becoming a sponsor:
📚 Documentation
For further documentation, including detailed API documentation for the available agent frameworks, visit the FastAPI Agents Documentation.
🚀 Installation
Install FastAPI Agents using pip, poetry or uv:
bash
pip install fastapi-agents
poetry add fastapi-agents
uv add fastapi-agents
Install optional extras for your chosen agent frameworks:
bash
pip install 'fastapi-agents[pydantic-ai]'
poetry add fastapi-agents -E pydantic-ai
uv add fastapi-agents --extra pydantic-ai
For available extras, replace pydantic-ai with the desired agent framework (e.g. smolagents or llama-index). See pyproject.toml for the full list of extras.
That's it! You're all set to start integrating AI agents into your FastAPI applications. 🎉
🏁 Quick Start
Registering Agents
Here’s how to get started with a basic PydanticAI agent:
```python from fastapi import FastAPI from fastapiagents import FastAPIAgents from pydanticai import Agent
Create a FastAPI application and FastAPIAgents instance.
app = FastAPI() agents = FastAPIAgents(path_prefix="/agents")
Initialize and register the agent.
The framework is automatically detected.
agent = Agent("openai:gpt-4o-mini") agents.register("pydanticai", agent)
Include the router in your FastAPI application.
app.include_router(agents) ```
Adding Security
Secure your endpoints with API Key authentication in just a few steps:
```python from fastapi.security import APIKeyHeader from fastapi_agents import FastAPIAgents
Define API Key validation
def validateapikey(apikey: str = Depends(APIKeyHeader(name="X-API-Key"))): if apikey != "my-secret-api-key": raise HTTPException(status_code=403, detail="Invalid API Key")
Secure the agents
agents = FastAPIAgents(pathprefix="/agents", securitydependency=validateapikey) ```
👉 See Security Examples for more details.
Running the Application
Run your FastAPI application with the registered agents:
bash
uvicorn --reload <module>:app
Replace <module> with the name of the Python module containing your FastAPI application.
That's it! You're all set to start building smarter, more secure FastAPI applications with AI agents. 🚀
🤝 Supported Agent Frameworks
FastAPI Agents supports a variety of agent frameworks, including:
- PydanticAI: AI agents powered by Pydantic AI. Examples
- Llama Index: OpenAI agents with Llama Index integration. Examples
- HuggingFace Smolagents: Lightweight and efficient AI agents. Examples
- CrewAI: Multi-agent Framework to create Crews. Examples
🐳 Using Docker
FastAPI Agents provides pre-built Docker images for each agent framework. To get started, pull the desired image from the GitHub Container Registry (GHCR):
bash
docker pull ghcr.io/blairhudson/fastapi-agents:pydantic-ai
For more information, see the FastAPI Agents Docker Documentation.
💡 Examples
Explore real-world examples for implementing FastAPI Agents in different scenarios, including step-by-by Jupyter notebook guides and standalone code samples.
See all available Guides and Example Code in the FastAPI Agents documentation.
🤝 Contributing
We welcome contributions! To contribute:
- Fork the repository.
- Create a feature branch.
- Add any new tests and ensure they pass. i.e.
uv run pytest. - Submit a pull request.
For any questions or feature requests including additional agent frameworks, open an issue in the repository.
📄 Citation
If you use FastAPI Agents in your work, please consider citing it using the metadata in the CITATION.cff file:
This DOI represents all versions of the project. For version-specific DOIs, refer to the Zenodo project page.
Alternatively, you can use the following BibTeX entry:
bibtex
@software{fastapi_agents,
author = {Blair Hudson},
title = {FastAPI Agents},
year = {2025},
version = {0.1},
doi = {10.5281/zenodo.14635504},
url = {https://github.com/blairhudson/fastapi-agents},
orcid = {https://orcid.org/0009-0007-4216-4555},
abstract = {FastAPI Agents is the ultimate FastAPI extension for integrating AI agents into your applications.}
}
📜 License
This project is licensed under the MIT License. See the LICENSE file for more details.
Owner
- Name: Blair Hudson
- Login: blairhudson
- Kind: user
- Location: Australia
- Repositories: 8
- Profile: https://github.com/blairhudson
Citation (CITATION.cff)
cff-version: 1.2.0
title: FastAPI Agents
message: >-
If you use this software, please cite it using the metadata from this file.
type: software
authors:
- given-names: Blair
family-names: Hudson
email: blairhudson@users.noreply.github.com
orcid: https://orcid.org/0009-0007-4216-4555
identifiers:
doi: '10.5281/zenodo.14635504'
repository-code: 'https://github.com/blairhudson/fastapi-agents'
url: 'https://github.com/blairhudson/fastapi-agents'
abstract: >-
FastAPI Agents is the ultimate FastAPI extension for integrating AI agents into your applications.
It provides easy agent management, built-in security, and support for frameworks like PydanticAI,
Llama-Index, and HuggingFace SmolAgents, enabling seamless AI-powered interactions in FastAPI apps.
keywords:
- fastapi
- ai
- agents
- smolagents
- llama-index
- pydantic-ai
license: MIT
version: 0.1
date-released: 2025-01-12
GitHub Events
Total
- Release event: 19
- Watch event: 40
- Delete event: 3
- Push event: 106
- Fork event: 2
- Create event: 29
Last Year
- Release event: 19
- Watch event: 40
- Delete event: 3
- Push event: 106
- Fork event: 2
- Create event: 29
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Blair Hudson | b****n | 72 |
| github-actions[bot] | g****] | 27 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 137 last-month
- Total dependent packages: 0
- Total dependent repositories: 0
- Total versions: 26
- Total maintainers: 1
pypi.org: fastapi-agents
A FastAPI extension for integrating common AI agent frameworks.
- Documentation: https://fastapi-agents.readthedocs.io/
- License: MIT License Copyright (c) 2025 Blair Hudson Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
Latest release: 0.1.28
published about 1 year ago