AI Agent API 代码生成器 —— curl、JavaScript 和 Python
为 OpenAI 兼容的 Agent 对话接口生成可直接粘贴的代码,支持按终端用户隔离和流式输出。适用于 FastClaw 的 /v1/chat/completions。
通过 user 字段发送 —— 该用户的历史和个人记忆只属于他自己。
通过 X-Fastclaw-Session-Key 发送 —— 每个会话保持固定,例如 myapp:conv_42。
密钥保持为占位符:在服务端从 FASTCLAW_API_KEY 读取,永远不要下发到浏览器。
POST /v1/chat/completions · curl
curl -sN "http://localhost:18953/v1/chat/completions" \
-H "Authorization: Bearer $FASTCLAW_API_KEY" \
-H "Content-Type: application/json" \
-H "X-Fastclaw-Session-Key: myapp:conv_42" \
-d '{
"user": "user-123",
"stream": true,
"messages": [
{
"role": "user",
"content": "总结一下今天的工单"
}
]
}'还没有密钥?
在控制台创建一个 user 类型的密钥,或运行 fastclaw apikey create --type user。