원클릭으로
add-endpoint
Add a new FastAPI API endpoint. Use when creating new REST API routes for the application.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Add a new FastAPI API endpoint. Use when creating new REST API routes for the application.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Add a new LLM provider to fusion-api. Use when integrating a new AI model service.
Fusion API 项目架构、技术栈、核心组件总览。Use when you need to understand how the backend works, its architecture, or tech stack.
Quick reference for all API endpoints. Use when you need to know available endpoints, their methods, and purposes.
Debug streaming issues (stop not working, content loss, reconnect problems). Use when SSE streaming has bugs.
查看 dev 服务器 fusion-api 日志。Use when debugging backend issues, checking errors, or tracing request flow.
用 curl 测试 dev 服务器 API 端点。Use to verify API behavior, test streaming, or debug issues end-to-end.
| name | add-endpoint |
| description | Add a new FastAPI API endpoint. Use when creating new REST API routes for the application. |
| argument-hint | <endpoint-name> |
按以下步骤添加新的 FastAPI 端点,以 {endpoint_name} 为例。
在 app/schemas/{endpoint_name}.py 中定义请求/响应模型:
from pydantic import BaseModel
from typing import Optional
class {Name}Request(BaseModel):
"""请求模型"""
field: str
class {Name}Response(BaseModel):
"""响应模型"""
id: str
field: str
在 app/services/{endpoint_name}_service.py 中实现业务逻辑:
from sqlalchemy.orm import Session
class {Name}Service:
def __init__(self, db: Session):
self.db = db
def create(self, data: dict) -> dict:
# 业务逻辑
pass
在 app/api/{endpoint_name}.py 中定义路由:
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session
from app.core.security import get_current_user
from app.db.database import get_db
from app.db.models import User
from app.schemas.{endpoint_name} import {Name}Request, {Name}Response
router = APIRouter()
@router.post("/", response_model={Name}Response)
async def create_{endpoint_name}(
request: {Name}Request,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_user),
):
"""创建{name}"""
pass
在 main.py 中注册:
from app.api.{endpoint_name} import router as {endpoint_name}_router
app.include_router({endpoint_name}_router, prefix="/api/{endpoint_name}", tags=["{endpoint_name}"])
在 test/test_{endpoint_name}.py 中编写测试。
get_current_user 鉴权(除非明确公开)HTTPException(status_code=xxx, detail="中文描述")app/api/chat.py 的写法