Skip to main content
The FastAPI App is used to serve Agents or Teams using a FastAPI server with a rest api interface.

Example Usage

Create an agent, wrap it with FastAPIApp, and serve it:
To run:
  1. Set OPENAI_API_KEY environment variable.
  2. API at http://localhost:8001, docs at http://localhost:8001/docs.
Send 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 specified prefix (default /v1).

1. POST /run

  • Description: Interacts with the agent/team (uses agent.run()/arun() or team.run()/arun()).
  • Request Form Parameters:
  • Responses:
    • stream=True: StreamingResponse (text/event-stream) with JSON RunResponse/TeamRunResponse events.
    • stream=False: JSON RunResponse/TeamRunResponse dictionary.

Parameters