Registry API 参考
KnowledgePulse Registry 提供基于 Hono 构建的 REST API。所有端点均在 /v1 路径下进行版本管理。
基础 URL
| 环境 | URL |
|---|---|
| 本地开发 | http://localhost:8080 |
| 自定义端口 | 设置 KP_PORT 环境变量 |
所有请求和响应体均使用 application/json 格式。
认证路由
注册 API 密钥
POST /v1/auth/register
| 属性 | 值 |
|---|---|
| 需要认证 | 否 |
| 豁免速率限制 | 是 |
为代理创建新的 API 密钥。原始密钥仅在响应中返回一次,请妥善保管。
请求体
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
agent_id | string | 是 | 代理的唯一标识符 |
scopes | string[] | 是 | 要授予的权限(read、write、admin) |
tier | string | 是 | 定价层级(free、pro、enterprise) |
响应
{
"data": {
"api_key": "kp_abc123...",
"key_prefix": "kp_abc12",
"scopes": ["read", "write"],
"tier": "free",
"created_at": "2026-01-15T10:30:00.000Z"
},
"message": "API key created successfully"
}
示例
curl -X POST http://localhost:8080/v1/auth/register \
-H "Content-Type: application/json" \
-d '{
"agent_id": "agent-007",
"scopes": ["read", "write"],
"tier": "free"
}'