AG-UI to CrewAI AMP FastAPI bridge
Project description
fiqros-ag-ui-crewai
fiqros-ag-ui-crewai is a FastAPI bridge that converts CrewAI AMP REST responses into AG-UI event streams (SSE), so AG-UI clients (including CopilotKit Cloud) can consume Crew runs correctly.
It acts as middleware between:
- CopilotKit Cloud / AG-UI client (expects AG-UI streaming events)
- CrewAI AMP deployment (exposes REST endpoints like
/kickoffand/status/{id})
Without this bridge, pointing CopilotKit directly to an AMP URL typically fails because AMP does not emit AG-UI terminal events on the wire.
What this package does
The bridge helper (add_crewai_amp_fastapi_endpoint) mounts a FastAPI route that:
- Accepts AG-UI
RunAgentInputoverPOST(for example,/agent) - Emits
RUN_STARTED - Calls CrewAI AMP
POST /kickoffwith the latest user message - Polls AMP
GET /status/{kickoff_id}until terminal state - On success:
- emits
TEXT_MESSAGE_START - emits chunked
TEXT_MESSAGE_CONTENTdeltas - emits
TEXT_MESSAGE_END
- emits
- On failure:
- emits
RUN_ERROR
- emits
- Always emits
RUN_FINISHED(required so AG-UI clients do not hang)
Why this works with AG-UI
AG-UI clients expect a protocol-compliant event stream, including terminal events. This package converts AMP JSON status/result payloads into AG-UI-compatible SSE events, making CrewAI AMP flows consumable by AG-UI runtimes.
Installation
pip install fiqros-ag-ui-crewai
Quick usage
from fastapi import FastAPI
from fiqros_ag_ui_crewai.amp import add_crewai_amp_fastapi_endpoint
app = FastAPI(title="AG-UI <-> CrewAI AMP Bridge")
add_crewai_amp_fastapi_endpoint(
app,
deployment_url="https://your-deployment.crewai.com",
bearer_token="your-crewai-bearer-token",
path="/agent",
)
Run:
uvicorn your_module:app --host 0.0.0.0 --port 8000
Then register your AG-UI endpoint as:
http://localhost:8000/agent(local)https://<your-ngrok-domain>/agent(public tunnel)
Optional packaged app entry
This package includes fiqros_ag_ui_crewai.app with a ready-made app object that reads environment variables:
CREWAI_DEPLOYMENT_URLCREWAI_BEARER_TOKEN
Run it directly:
uvicorn fiqros_ag_ui_crewai.app:app --host 0.0.0.0 --port 8000
Environment variables
When using the packaged app module:
CREWAI_DEPLOYMENT_URL=https://your-deployment.crewai.com
CREWAI_BEARER_TOKEN=your-token
Middleware architecture
CopilotKit Cloud / AG-UI client
|
| POST /agent (AG-UI input)
v
FastAPI bridge (this package)
|
| POST /kickoff
| GET /status/{kickoff_id} (polling)
v
CrewAI AMP deployment
|
| JSON status/result
v
Bridge converts JSON -> AG-UI SSE events
|
v
CopilotKit Cloud / AG-UI client
Tuning parameters
add_crewai_amp_fastapi_endpoint(...) supports:
path(default:/)poll_interval_seconds(default:2.0)kickoff_timeout_seconds(default:600.0)chunk_size(default:64)
These control endpoint mount path, AMP polling cadence, timeout ceiling, and response chunking granularity.
Notes
- Use
path="/agent"to avoid route collisions and to match typical AG-UI agent endpoint conventions. - Ensure your client points to
/agent(not/) if mounted there. - Keep your bearer token server-side only; never expose it in frontend code.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fiqros_ag_ui_crewai-0.1.0.tar.gz.
File metadata
- Download URL: fiqros_ag_ui_crewai-0.1.0.tar.gz
- Upload date:
- Size: 7.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.3 Linux/6.17.0-22-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d303a7734de1d76bfb30f8e819b0c7f54a0213a44245cd094a9c9da505a0010
|
|
| MD5 |
d1b415ffe2b34fe53b7ce41cb77811bc
|
|
| BLAKE2b-256 |
2fc8e295dcc368ed4ce6b0e391c11c8bc9f9148361bdc25124379f032875f465
|
File details
Details for the file fiqros_ag_ui_crewai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: fiqros_ag_ui_crewai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.3.4 CPython/3.12.3 Linux/6.17.0-22-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
812ba564e9d8a48f317f2ee7d8ab28e8c30a96377262d198dba4239e80679e1d
|
|
| MD5 |
76eca8e2a9238920883f291f388c8aa9
|
|
| BLAKE2b-256 |
64563fe15cae46b74f1b1ad536e9a9f7a7812e48efe9ca554ed0a909bf86d982
|