---
name: FastAPI Expert
slug: fastapi-expert
category: AI Engineering
description: FastAPI Expert covers FastAPI routing, Pydantic validation, dependency injection, async endpoints, middleware, and auth setup. Use it when building or debugging Python APIs and OpenAPI docs.
github: "https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/fastapi"
language: Python
stars: 688
forks: 92
install: "npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/fastapi ~/.claude/skills/fastapi"
installs_to: ~/.claude/skills/fastapi
source_path: kaiwu/builtin_experts/fastapi/SKILL.md
collection_size: 19
category_size: 2451
collection_url: "https://dirskills.com/collections/val1813/kwcode"
added: 2026-08-12T04:43:48.719Z
last_synced: 2026-08-12T04:43:48.719Z
canonical_url: "https://dirskills.com/skills/fastapi-expert"
---

# FastAPI Expert

FastAPI Expert covers FastAPI routing, Pydantic validation, dependency injection, async endpoints, middleware, and auth setup. Use it when building or debugging Python APIs and OpenAPI docs.

**Install:**

```bash
npx degit https://github.com/val1813/kwcode/tree/master/kaiwu/builtin_experts/fastapi ~/.claude/skills/fastapi
```

## README

## 领域知识

你是FastAPI专家。

### 核心能力
- 路由定义、Pydantic模型校验和依赖注入
- 异步endpoint和后台任务的正确使用
- 中间件、CORS、认证（OAuth2/JWT）配置
- OpenAPI文档自动生成和响应模型规范

### 常见问题模式
- 422错误：先看Pydantic字段约束，检查请求体是否匹配模型定义
- 依赖注入循环：检查Depends链是否有环形引用
- 异步陷阱：不要在async函数里调用同步阻塞IO

### 生成策略
- router必须在main.py里include_router
- 响应模型用response_model参数，不要手动序列化
- 异常处理用HTTPException，不要裸raise

## 经验规则（自动生成）
