快速开始
当前版本的 Aidy 已切换为 PG-only runtime。
准备 PostgreSQL
创建一个空库,例如 aidy,并设置:
export DATABASE_URL='postgres://postgres:postgres@localhost:5432/aidy?sslmode=disable'
执行 migration
just db-migrate
写入默认 seed
just db-seed
默认等价于:
just db-seed profile=dev
这个命令会先清掉当前 schema 的所有表、重跑 migration,再写入默认 seed。
启动网关
just dev
这会同时启动:
- gateway
- management server
- dashboard dev server
此时 /dashboard 会直接反代到前端 dev server,支持热更新。
验证
Dashboard:
http://localhost:12581/dashboard/
健康检查:
curl http://localhost:12581/health
curl http://localhost:12581/ready
发送一个最小请求
如果使用默认 dev seed:
- route prefix:
/mock - consumer api key:
sk-mock - model:
mock
可以直接发:
curl http://localhost:8080/mock/v1/chat/completions \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer sk-mock' \
-d '{"model":"mock","messages":[{"role":"user","content":"hello"}]}'
当前选路语义
运行时直接做:
- 匹配 route
- 按 route 认证规则鉴权
- 读取
route.upstreams[]作为基础 upstream 集合 - 叠加 route / consumer / api key 的 selector 过滤
- 在筛选后的 upstream 上查找
upstream_models - 命中多个 upstream 时,按 route 级
priority / lb_weight做选择