Example Usage
Create an agent, wrap it withFastAPIApp, and serve it:
- Set
OPENAI_API_KEYenvironment variable. - API at
http://localhost:8001, docs athttp://localhost:8001/docs.
POST requests to http://localhost:8001/runs?agent_id=basic_agent:
Core Components
FastAPIApp: Wraps Agno agents/teams for FastAPI.FastAPIApp.serve: Serves the FastAPI app using Uvicorn.
FastAPIApp uses helper functions for routing.
FastAPIApp Class
Main entry point for Agno FastAPI apps.
Initialization Parameters
Provide
agent or team, not both.
Key Method
Endpoints
Endpoints are available at the specifiedprefix (default /v1).
1. POST /run
- Description: Interacts with the agent/team (uses
agent.run()/arun()orteam.run()/arun()). - Request Form Parameters:
- Responses:
stream=True:StreamingResponse(text/event-stream) with JSONRunResponse/TeamRunResponseevents.stream=False: JSONRunResponse/TeamRunResponsedictionary.