FastAPI + Flask Hybrid Proxy for Openclaw

A comprehensive skill for deploying and managing hybrid architectures featuring FastAPI backends and Flask frontend services.

hunwenpinghao
v1.0.0
Mar 31, 2026
0
828
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install fastapi-flask-proxy

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install fastapi-flask-proxy using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is FastAPI + Flask Hybrid Proxy?

The FastAPI + Flask Hybrid Proxy skill provides a robust architectural pattern for developers who need to combine the high-performance asynchronous capabilities of FastAPI with the flexibility of Flask. This Openclaw Skills guide addresses the common pitfalls of running multiple Python web frameworks simultaneously, such as port conflicts, cross-origin resource sharing (CORS) issues, and routing registration errors.

By implementing a structured proxy pattern, this skill ensures that your frontend and backend communicate seamlessly. It provides templates for handling RESTful methods (GET, POST, PUT, DELETE) through a unified gateway, making it ideal for modern AI agent development where varied service layers are common.

FastAPI + Flask Hybrid Proxy Use Cases

  • Running a legacy Flask frontend alongside a modern FastAPI microservice.
  • Avoiding CORS issues by using Flask as a reverse proxy for FastAPI routes.
  • Building AI-powered web applications that require separate service layers for UI and high-speed data processing.
  • Deploying multi-container Python applications using Docker Compose.

How FastAPI + Flask Hybrid Proxy Works

  1. The user browser connects to the Flask application on a designated port (e.g., 15000) for static pages and UI components.
  2. When an API request is made, the Flask app acts as a gateway, intercepting the request via dedicated proxy routes.
  3. The proxy layer forwards the request to the internal FastAPI service running on a separate port (e.g., 18000).
  4. FastAPI processes the business logic and database interactions (SQLAlchemy/ORMs) and returns the data.
  5. Flask receives the response from FastAPI and delivers it back to the client, maintaining consistent headers and status codes.

FastAPI + Flask Hybrid Proxy Setup

To implement this Openclaw Skills solution, ensure you have python3 installed.

  1. Define your FastAPI app with routes declared before the main execution block:
from fastapi import FastAPI
app = FastAPI()

@app.get("/api/hello")
def hello():
    return {"message": "Hello"}
  1. Set up the Flask proxy to forward requests to the FastAPI backend:
# Install dependencies
pip install flask fastapi uvicorn requests sqlalchemy
  1. Use a startup script to run both services:
#!/bin/bash
# Start FastAPI in background
python -m uvicorn api:app --host 0.0.0.0 --port 18000 &
# Start Flask frontend
python frontend.py

FastAPI + Flask Hybrid Proxy Data Schema & Taxonomy

The skill suggests a relational database structure using SQLAlchemy. Key entities include:

Table Purpose Relationships
trajectories Main data record for tracking Has many annotations
annotations Metadata or labels linked to trajectories Foreign Key: trajectory_id

It supports cascade deletion strategies to maintain data integrity when records are removed from the system.

FastAPI + Flask Hybrid Proxy Advanced Features

  • Generic API Proxying: Dynamically routes all HTTP methods from Flask to FastAPI.
  • Automated Dependency Management: Ensures model imports (Trajectory, Annotation) are handled correctly to prevent NameErrors.
  • Docker Compose Orchestration: Pre-configured service containers for seamless cloud deployment.
  • Database Cascade Support: Implements both database-level and manual application-level cascade deletions for complex data structures.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*