Playground App
Host agents as Playground Applications.
The Playground App is used to serve Agents, Teams and Workflows using a FastAPI server with several endpoints to manage and interact with Agents
, Workflows
, and Teams
on the Agno Playground.
Example Usage
Create an agent, and serve it with Playground
:
To run:
- Ensure your PostgreSQL server is running and accessible via the
db_url
. - Set the
OPENAI_API_KEY
environment variable. - The Playground UI will be available at
http://localhost:7777
. API docs (if enabled in settings) are typically athttp://localhost:7777/docs
. - Use playground with Agent Playground .
Core Components
Playground
: Wraps Agno agents, teams, or workflows in an API.serve_playground_app
: Serves the Playground FastAPI app using Uvicorn.
The Playground
class is the main entry point for creating Agno Playground applications. It allows you to easily expose your agents, teams, and workflows through a web interface with Agent Playground or Agent UI.
Playground
Class
Initialization Parameters
Parameter | Type | Default | Description |
---|---|---|---|
agents | Optional[List[Agent]] | None | List of Agno Agent instances. |
teams | Optional[List[Team]] | None | List of Agno Team instances. |
workflows | Optional[List[Workflow]] | None | List of Agno Workflow instances. |
settings | Optional[PlaygroundSettings] | None | Playground configuration. Defaults if None . |
api_app | Optional[FastAPI] | None | Existing FastAPI app. A new one is created if None . |
router | Optional[APIRouter] | None | Existing APIRouter. A new one is created if None . |
app_id | Optional[str] | None | App identifier (autogenerated if not set). |
name | Optional[str] | None | Name for the App. |
description | Optional[str] | None | Description for the App. |
Provide at least one of agents
, teams
, or workflows
.
Key Methods
Method | Parameters | Return Type | Description |
---|---|---|---|
get_app | use_async: bool = True prefix: str = "/v1" | FastAPI | Returns configured FastAPI app (async by default). Sets prefix, error handlers, CORS, docs. |
get_router | APIRouter | Returns the synchronous APIRouter for playground endpoints. | |
get_async_router | APIRouter | Returns the asynchronous APIRouter for playground endpoints. |
Endpoints
Endpoints are available at the specified prefix
(default /v1
) combined with the playground router’s prefix (/playground
). For example, the status endpoint is typically /v1/playground/status
.
Serving the Application
serve_playground_app
serves the Playground’s FastAPI app using Uvicorn.
Parameters
Parameter | Type | Default | Description |
---|---|---|---|
app | Union[str, FastAPI] | N/A | FastAPI app instance or import string (Required). |
host | str | "localhost" | Host to bind. |
port | int | 7777 | Port to bind. |
reload | bool | False | Enable auto-reload for development. |