/api/v1/tasks/{task_id} 接口用于查询后台任务状态,如 commit 的摘要生成和记忆提取进度。
任务状态包括:
pending(等待执行)、running(执行中)、completed(成功完成)、failed(失败)。
完成 API 鉴权说明 页面的 API Key 获取后,可调用本接口查询任务状态。
URI | /api/v1/tasks/{task_id} | 统一资源标识符 |
|---|---|---|
请求方法 | GET | 客户端请求类型 |
请求头 | Authorization: Bearer | Bearer Token 鉴权 |
参数 | 类型 | 必选 | 默认值 | 备注 |
|---|---|---|---|---|
task_id | string | 是 | -- | 任务 ID |
字段 | 参数说明 |
|---|---|
status | 请求状态,成功为 |
result | 成功时返回的数据对象 |
result.task_id | 任务 ID |
result.task_type | 任务类型,如 |
result.status | 任务状态: |
result.result | 任务完成时返回的结果对象(进行中时为 |
error | 失败时返回的错误对象 |
error.code | 错误码字符串,常见值见下表 |
error.message | 可读的错误描述 |
常见错误码:
error.code | HTTP 状态码 | 说明 |
|---|---|---|
UNAUTHENTICATED | 401 | 缺少或无效的 API Key |
NOT_FOUND | 404 | 任务未找到 |
curl -X GET "https://xxx/api/v1/tasks/uuid-xxx" \ -H "X-API-Key: your-key"
执行成功返回(进行中):
HTTP/1.1 200 OK Content-Type: application/json { "status": "ok", "result": { "task_id": "uuid-xxx", "task_type": "session_commit", "status": "running" } }
curl -X GET "https://xxx/api/v1/tasks/uuid-xxx" \ -H "X-API-Key: your-key"
执行成功返回(已完成):
HTTP/1.1 200 OK Content-Type: application/json { "status": "ok", "result": { "task_id": "uuid-xxx", "task_type": "session_commit", "status": "completed", "result": { "session_id": "a1b2c3d4", "archive_uri": "viking://session/alice/a1b2c3d4/history/archive_001", "memories_extracted": { "profile": 1, "preferences": 2, "entities": 1, "cases": 1 }, "active_count_updated": 2, "token_usage": { "llm": { "prompt_tokens": 5200, "completion_tokens": 1800, "total_tokens": 7000 }, "embedding": { "total_tokens": 1500 }, "total": { "total_tokens": 8500 } } } } }