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.1.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.1-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

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

Hashes for fastapi_agent-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d4a6047369063e4d02d765845a626cdcdc10b62b9d636ef5363f4ddd383c517a
MD5 593ad9743693c8035994208175340de7
BLAKE2b-256 4d9873ffd03e28e19a49064db6a42fd4337c224e62891946f79aba827581dcbe

See more details on using hashes here.

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

Hashes for fastapi_agent-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ebcc090b23103664c7a0dc3576cdff536ff29a05bdf0a537d5c08777c247d115
MD5 700b03df165d12e3d345af2fa283e99b
BLAKE2b-256 8dc95995c29db0accccbd19790b3341c36a0fe6cc288faa4d6fae1b83206cb0a

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