🤖 AI Agent / LLM Function Calling 对接说明
OpenAPI 3.0 Ready
可直接将 Backup Hub 作为外部工具挂载给 Claude Projects、OpenAI GPTs、Cursor、Windsurf、Dify、Coze 等智能体,Agent 可自主纳管新项目、触发备份或直传数据归档。
1. System Prompt (系统提示词 / Agent Context)
You have access to the Backup Hub API at https://bak.bestool.cc.
Backup Hub connects Linux servers, Docker containers, and external development projects to an encrypted Google Drive cold-storage pipeline.
Authentication:
All requests must include the header:
Authorization: Bearer <YOUR_API_TOKEN>
Capabilities:
1. Register/manage a new project: POST /v1/services
2. Trigger an immediate backup: POST /v1/services/{id}/run
3. Directly push external project tarball/SQL dump: POST /v1/push?name={filename}
4. Monitor task status and execution logs: GET /v1/tasks/{id} and GET /v1/tasks/{id}/log
2. Function Calling / Tools JSON Schema (智能体工具声明)
{
"name": "backup_hub_push_file",
"description": "直接将本地备份归档文件(tar.gz/sql/zip)推送到 Backup Hub 并加密上传至 Google Drive",
"parameters": {
"type": "object",
"properties": {
"file_name": { "type": "string", "description": "例如 my-app.sql.gz" },
"file_path": { "type": "string", "description": "本地待推送文件的绝对路径" }
},
"required": ["file_name", "file_path"]
}
}
3. Python Agent Tool 实现示例
import requests
def backup_to_gdrive(local_path: str, filename: str, token: str):
url = f"https://bak.bestool.cc/v1/push?name={filename}"
headers = {"Authorization": f"Bearer {token}", "Content-Type": "application/octet-stream"}
with open(local_path, "rb") as f:
res = requests.post(url, headers=headers, data=f, timeout=300)
return res.json()
外部项目 10 秒极速接入指南
任何项目只需使用该项目的专属 Token 向 https://bak.bestool.cc/v1/... 发送 HTTP 请求即可完成接入。
方式一:外部异地项目直接推送压缩包或数据文件 (Push to Cloud)
curl -X POST "https://bak.bestool.cc/v1/push?name=my-app-db.sql" \
-H "Authorization: Bearer <PROJECT_TOKEN>" \
--data-binary "@/path/to/backup.sql.gz"
方式二:远程触发本机/纳管目录自动打包上传 (Trigger Remote Backup)
curl -X POST "https://bak.bestool.cc/v1/tasks" \
-H "Authorization: Bearer <PROJECT_TOKEN>" \
-H "Content-Type: application/json" \
-d '{
"type": "paths",
"name": "backup-my-code",
"params": { "paths": ["/home/PriceAI"], "prefix": "price-ai" }
}'
方式三:查询备份任务执行结果与状态
curl -s "https://bak.bestool.cc/v1/tasks/<TASK_ID>" \
-H "Authorization: Bearer <PROJECT_TOKEN>"