This project demonstrates the integration between Open Web UI and AWS Strands Agents SDK through an OpenAI-compatible API layer.
┌─────────────────┐
│ Open Web UI │ (Port 3000)
│ Web Interface │
└────────┬────────┘
│ HTTP Requests
│ (OpenAI API Format)
▼
┌─────────────────┐
│ Agent API │ (Port 8000)
│ FastAPI Server │
│ /v1/models │
│ /v1/chat/... │
└────────┬────────┘
│ Python SDK Calls
▼
┌─────────────────┐
│ Strands Agent │
│ (Alfred) │
│ Bedrock Model │
└────────┬────────┘
│ API Calls
▼
┌─────────────────┐
│ AWS Bedrock │
│ Nova Pro v1 │
└─────────────────┘
┌─────────────────┐
│ PostgreSQL 17 │ (Port 5432)
│ Database │ (Stores Open Web UI data)
└─────────────────┘
The FastAPI application provides OpenAI-compatible endpoints:
- GET /v1/models: Lists available Strands agents as "models"
- POST /v1/chat/completions: Processes chat messages through the Strands agent
- GET /v1/models/{model_id}: Retrieves specific model information
The AlfredAgent class:
- Initialises a Strands Agent with AWS Bedrock model
- Configures the agent with a custom system prompt (Alfred personality)
- Provides synchronous and asynchronous invocation methods
- Handles response formatting
- User sends message in Open Web UI
- Open Web UI makes POST request to
/v1/chat/completions - API extracts user message from OpenAI format
- Message is passed to Strands Agent (Alfred)
- Agent processes through AWS Bedrock
- Response is formatted as OpenAI completion
- Open Web UI displays the response
- AWS Credentials: Required for Bedrock access
- OPENAI_API_KEY: Used for service-to-service authentication
- Database: PostgreSQL connection details for Open Web UI
All services communicate through the strands-network bridge network:
- Services reference each other by container name
- Open Web UI connects to
http://agent-api:8000/v1 - Agent API and Open Web UI both connect to
postgres:5432
This is a demonstration project. For production use:
- Implement proper API key validation
- Add rate limiting
- Use secrets management for credentials
- Enable HTTPS/TLS
- Implement proper error handling and logging
- Add authentication and authorisation
- Use environment-specific configurations
- Create new agent class in
src/agent.py - Register in
src/api.pymodels list - Route requests based on model ID
Strands SDK supports tools. Example:
from strands import tool
@tool
def get_weather(city: str) -> dict:
"""Get weather for a city."""
# Implementation
return {"status": "success", "content": [...]}
agent = Agent(tools=[get_weather])To add streaming responses:
- Enable streaming in Bedrock model
- Implement Server-Sent Events (SSE) in API
- Stream tokens as they arrive from Bedrock