一键导入
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 职业分类
| 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 的写法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.