API
API 概览
通过 REST 和 GraphQL 自动化 PentAGI — 创建 Bearer 令牌,从 CI/CD 启动 flows,将结果拉取到您自己的工具中并生成客户端。
您在 Web UI 中可以执行的大部分操作均可通过 API 实现——从 CI/CD 启动 flowsflow — 流程PentAGI 的一次运行:一个目标、根据您的消息创建的任务,以及智能体在此过程中执行的所有操作。、将结果拉取到您自己的工具中,或构建集成。
| API | 端点 | 交互式文档 |
|---|---|---|
| GraphQL | / | / |
| REST | / | / |
创建令牌
- 在 Web UI 中打开 Settings → API Tokens。
- 点击 Create Token,可选择为其命名,并设置 1 分钟至 3 年之间的有效期。
- 请立即复制令牌——它仅显示一次。
令牌归属于您的账户,并继承您角色的权限。用户、角色和 API 令牌、flow 模板、收藏夹以及您的设置仅能从已登录的浏览器会话进行管理:令牌在 REST /、/ 和 / 路由上会收到 403 错误,并在这些 GraphQL 操作中收到错误。
调用 API
curl -X POST https://your-pentagi-host:8443/api/v1/graphql \
-H "Authorization: Bearer YOUR_API_TOKEN" \
-H "Content-Type: application/json" \
-d '{"query": "{ flows { id title status } }"}'
curl https://your-pentagi-host:8443/api/v1/flows/ \
-H "Authorization: Bearer YOUR_API_TOKEN"使用 GraphQL 变更启动 flow:
mutation CreateFlow {
createFlow(modelProvider: "openai", input: "Test the security of https://example.com") {
id
title
status
createdAt
}
}生成客户端
- GraphQL — 模式位于代码仓库中的
backend/;可使用 GraphQL Code Generator、genqlient 或 Apollo。pkg/ graph/ schema.graphqls - REST — OpenAPI 规范可通过
/获取:api/ v1/ swagger/ doc.json
openapi-generator-cli generate \
-i https://your-pentagi-host:8443/api/v1/swagger/doc.json \
-g python \
-o ./pentagi-client最后更新于