Prerequisites
Make sure to have Python and Poetry installed.Setup a New Project with Poetry
First, let’s create a new project and set up Poetry for dependency management:Install Dependencies
Now, let’s install the necessary packages:Create a Basic Endpoint with FastAPI
Create a new file calledmy_endpoint/main.py
with the following code:Run and Test Your Endpoint
Start the server with:Parsing AG-UI Input
Next let’s update our endpoint to properly parse the incoming AG-UI request using theRunAgentInput
Pydantic model:Add Event Streaming
AG-UI supports streaming events using Server-Sent Events (SSE). Let’s modify our/awp
endpoint to stream events back to the client:RunStartedEvent
and RunFinishedEvent
events,
which gives us a basic AG-UI compliant endpoint. Now let’s make it do something
useful.