Add an AI Agent to your FastAPI application. The agent knows how to interact with your endpoints within a chat interface.
Project description
FastAPI Agent
Interact with your FastAPI endpoints using an AI-based chat interface. FastAPI Agent adds an AI Agent to your FastAPI application. The agent knows how to interact with your API endpoints within a chat interface or with an API route (/agent/query).
Installation:
To install the dependencies, run:
pip install fastapi_agent
Usage:
To use the FastAPI Agent, initialize it with your FastAPI app and model. You can add agent routes to your app and interact with the agent through chat.
Example:
Here is an example of how to use the FastAPI Agent with your FastAPI application:
import uvicorn
from fastapi import FastAPI
from fastapi_agent import FastAPIAgent
# set your FastAPI app
app = FastAPI(
title="YOUR APP TITLE",
version="0.1.0",
description="some app description",
)
# add routes
@app.get("/")
async def root():
"""Welcome endpoint that returns basic API information"""
return {"message": "Welcome to Test API"}
# add the FastAPI Agent + routes
agent = FastAPIAgent(
app,
model="openai:gpt-4o",
base_url="http://localhost:8000",
include_router=True,
)
uvicorn.run(app, host="0.0.0.0", port=8000)
Additional Examples:
use /agent/query with dependecies
curl -k -X POST "http://127.0.0.1:8000/agent/query" \
-H 'deps: {"api-key": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"}' \
-H "Content-Type: application/json" \
-d '{"query": "show all endpoints"}'
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_agent-0.1.1.tar.gz.
File metadata
- Download URL: fastapi_agent-0.1.1.tar.gz
- Upload date:
- Size: 120.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4a6047369063e4d02d765845a626cdcdc10b62b9d636ef5363f4ddd383c517a
|
|
| MD5 |
593ad9743693c8035994208175340de7
|
|
| BLAKE2b-256 |
4d9873ffd03e28e19a49064db6a42fd4337c224e62891946f79aba827581dcbe
|
File details
Details for the file fastapi_agent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: fastapi_agent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 25.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ebcc090b23103664c7a0dc3576cdff536ff29a05bdf0a537d5c08777c247d115
|
|
| MD5 |
700b03df165d12e3d345af2fa283e99b
|
|
| BLAKE2b-256 |
8dc95995c29db0accccbd19790b3341c36a0fe6cc288faa4d6fae1b83206cb0a
|