Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_agent-0.1.2.tar.gz (120.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_agent-0.1.2-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_agent-0.1.2.tar.gz.

File metadata

  • Download URL: fastapi_agent-0.1.2.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

Hashes for fastapi_agent-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bd9d73723a2728d4ec38430d24699e95969e59d65f0eae6a53fb718bdff87f9d
MD5 8762de818c3d3d729b8a1ad1fa62760c
BLAKE2b-256 c083f2ffa79eaceb38c0e7a9100524ea07d6f707abad488c7fcaebb04fe90f73

See more details on using hashes here.

File details

Details for the file fastapi_agent-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: fastapi_agent-0.1.2-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

Hashes for fastapi_agent-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7f8ba187c7a5d8582a1db04982597549f507bdb12bf5601844d89ed789ee87e3
MD5 95435491f7e6bf09a3f45435040cf09b
BLAKE2b-256 79b9bb57f92be8a465feda4acca477ef26fa95f5a202268148b648606bafba21

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page