with one click
add-api-endpoint
// Step-by-step guide to add a new REST or WebSocket endpoint to the backend
// Step-by-step guide to add a new REST or WebSocket endpoint to the backend
REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend
Architecture, directory layout, communication protocol, and conventions for the full-stack multi-agent application
Step-by-step guide to add a new agent to the multi-agent team
Step-by-step guide to add a new page or component to the React frontend
How the Code Reviewer agent conducts systematic code reviews with prioritized findings
How the Research Analyst agent conducts research, evaluates sources, and produces structured reports
| name | add-api-endpoint |
| description | Step-by-step guide to add a new REST or WebSocket endpoint to the backend |
| license | Apache-2.0 |
backend/app/schemas.pyclass SummarizeRequest(BaseModel):
"""Request to summarize a conversation."""
conversation_id: str
class SummarizeResponse(BaseModel):
"""Summary of a conversation."""
summary: str
message_count: int
backend/app/main.pyfrom .schemas import SummarizeRequest, SummarizeResponse
@app.post("/api/summarize", response_model=SummarizeResponse)
async def summarize(req: SummarizeRequest) -> SummarizeResponse:
# Call the agent team or implement logic
responses = await run_team(f"Summarize conversation {req.conversation_id}")
return SummarizeResponse(
summary=responses[-1]["content"] if responses else "",
message_count=len(responses),
)
backend/tests/test_api.py@pytest.mark.asyncio
async def test_summarize(client: AsyncClient) -> None:
resp = await client.post("/api/summarize", json={"conversation_id": "abc"})
assert resp.status_code == 200
body = resp.json()
assert "summary" in body
const resp = await fetch("/api/summarize", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ conversation_id: id }),
});
const data = await resp.json();
The Vite proxy forwards /api requests to the backend automatically.
backend/app/main.py@app.websocket("/ws/stream")
async def stream_ws(websocket: WebSocket) -> None:
await websocket.accept()
try:
while True:
data = await websocket.receive_text()
payload = json.loads(data)
# Process and stream responses
await websocket.send_text(
AgentMessage(agent="system", content="...", type="status").model_dump_json()
)
except WebSocketDisconnect:
pass
const ws = new WebSocket(`${protocol}//${window.location.host}/ws/stream`);
ws.onmessage = (event) => {
const msg = JSON.parse(event.data);
// Handle message
};
The Vite proxy handles /ws paths — add the new path to vite.config.ts if using a different prefix.
schemas.pymain.py with response_model (REST) or structured JSON (WS)tests/test_api.py/api/ or /ws/ prefix (proxied by Vite)