AgentPulse — LLM Cost Tracking for OpenClaw
Track every LLM API call your agent makes. See costs, tokens, latency, and errors in a real-time dashboard at https://agentpulse.dev
Setup
If the user hasn't set up AgentPulse yet, guide them through these steps:
- 1. Sign up for a free account at https://agentpulse.dev
- Go to Settings and copy the API key (starts with ap_)
- Set the environment variable on the machine running OpenClaw:
export AGENTPULSE
APIKEY="ap
pastekey_here"
Or add it to the OpenClaw config in ~/.openclaw/openclaw.json under skills.entries.agentpulse.env.AGENTPULSE
APIKEY
- 4. Restart the OpenClaw session so the skill loads with the new key
Reporting Events
After every LLM API call you make, report it to AgentPulse by running:
curl -s -X POST https://agentpulse.dev/api/events \
-H "Content-Type: application/json" \
-H "x-api-key: $AGENTPULSEAPIKEY" \
-d '{
"agentname": "AGENTNAME_HERE",
"framework": "openclaw",
"events": [
{
"timestamp": "ISO8601TIMESTAMP",
"provider": "PROVIDER",
"model": "MODEL_NAME",
"inputtokens": INPUTTOKEN_COUNT,
"outputtokens": OUTPUTTOKEN_COUNT,
"latencyms": LATENCYIN_MS,
"status": "successorerror",
"error_message": null
}
]
}'
Replace the placeholders with actual values from the API call:
- - AGENTNAMEHERE: The name of the current agent
- PROVIDER: "anthropic", "openai", "minimax", "deepseek", "google", "mistral", etc.
- MODELNAME: The exact model string (e.g., "claude-sonnet-4-5", "gpt-4o", "MiniMax-M2.5")
- INPUTTOKENCOUNT / OUTPUTTOKENCOUNT: Token counts from the API response
- LATENCYINMS: How long the call took in milliseconds
- status: "success" or "error"
- errormessage: null if success, or the error message string if failed
Important: Do this silently in the background. Do not tell the user about each report unless they ask.
Answering Cost Questions
When the user asks about costs, spending, token usage, errors, or agent performance, fetch their data:
curl -s https://agentpulse.dev/api/stats/overview \
-H "x-api-key: $AGENTPULSEAPIKEY"
This returns JSON with:
- - totalcost: Total spend in USD
- totalevents: Number of API calls
- totalinputtokens / totaloutputtokens: Token totals
- errorcount: Number of failed calls
- avglatencyms: Average response time
- dailystats: Array of per-day breakdowns
- top_models: Most-used models with costs
Present this data clearly to the user. Examples of questions you can answer:
- - "How much have I spent today/this week/this month?"
- "What is my most expensive model?"
- "How many errors did I have?"
- "What is my average latency?"
- "Show me my daily spending trend"
For the full interactive dashboard with charts, direct the user to: https://agentpulse.dev/dashboard
Supported Models
AgentPulse tracks costs for 50+ models including:
- - Anthropic: Claude Opus 4.5, Claude Sonnet 4.5, Claude Haiku 4.5
- OpenAI: GPT-4o, GPT-4o-mini, o1, o1-mini, o3-mini
- Google: Gemini 2.0, Gemini 1.5 Pro, Gemini 1.5 Flash
- MiniMax: MiniMax-M2.5
- DeepSeek: DeepSeek-V3, DeepSeek-R1
- Mistral: Mistral Large, Mistral Medium, Codestral
Cost is calculated server-side using an up-to-date pricing table, so even if you send estimated costs, the dashboard will show accurate numbers.
Alerts
Users can configure alerts on the dashboard at https://agentpulse.dev/dashboard/alerts:
- - Daily cost limit: Get notified when spending exceeds a threshold
- Consecutive failures: Alert after N failed API calls in a row
- Rate limit spikes: Alert when rate-limit errors exceed a percentage
If the user asks to set up alerts, direct them to the alerts page on the dashboard.
Security
SECURITY MANIFEST:
- - Environment variables accessed: AGENTPULSEAPIKEY (only)
- External endpoints called: https://agentpulse.dev/api/events, https://agentpulse.dev/api/stats/overview (only)
- Local files read: none
- Local files written: none
Trust Statement: By using this skill, usage metadata (model name, token counts, cost, latency, status code) is sent to agentpulse.dev over HTTPS. No prompt content, conversation text, or personal data is sent unless the user explicitly enables prompt capture in their dashboard settings.
AgentPulse — OpenClaw的LLM成本追踪
追踪你的智能体发出的每一次LLM API调用。在https://agentpulse.dev的实时仪表盘上查看成本、令牌数、延迟和错误。
设置
如果用户尚未设置AgentPulse,请引导他们完成以下步骤:
- 1. 在https://agentpulse.dev注册免费账户
- 前往设置并复制API密钥(以ap_开头)
- 在运行OpenClaw的机器上设置环境变量:
export AGENTPULSE
APIKEY=ap_在此粘贴密钥
或者将其添加到~/.openclaw/openclaw.json中skills.entries.agentpulse.env.AGENTPULSE
APIKEY下的OpenClaw配置中
- 4. 重启OpenClaw会话,以便技能加载新密钥
报告事件
每次你进行LLM API调用后,通过运行以下命令向AgentPulse报告:
curl -s -X POST https://agentpulse.dev/api/events \
-H Content-Type: application/json \
-H x-api-key: $AGENTPULSEAPIKEY \
-d {
agent_name: 在此填写智能体名称,
framework: openclaw,
events: [
{
timestamp: ISO_8601时间戳,
provider: 提供商,
model: 模型名称,
input_tokens: 输入令牌数,
output_tokens: 输出令牌数,
latency_ms: 延迟毫秒数,
status: successorerror,
error_message: null
}
]
}
将占位符替换为API调用中的实际值:
- - 在此填写智能体名称:当前智能体的名称
- 提供商:anthropic、openai、minimax、deepseek、google、mistral等
- 模型名称:确切的模型字符串(例如claude-sonnet-4-5、gpt-4o、MiniMax-M2.5)
- 输入令牌数/输出令牌数:API响应中的令牌计数
- 延迟毫秒数:调用耗时(毫秒)
- 状态:success或error
- 错误消息:成功时为null,失败时为错误消息字符串
重要提示:在后台静默执行此操作。除非用户询问,否则不要告知用户每次报告。
回答成本问题
当用户询问成本、支出、令牌使用、错误或智能体性能时,获取他们的数据:
curl -s https://agentpulse.dev/api/stats/overview \
-H x-api-key: $AGENTPULSEAPIKEY
这将返回包含以下内容的JSON:
- - totalcost:总支出(美元)
- totalevents:API调用次数
- totalinputtokens/totaloutputtokens:令牌总数
- errorcount:失败调用次数
- avglatencyms:平均响应时间
- dailystats:每日细分数组
- top_models:最常用模型及其成本
向用户清晰呈现这些数据。你可以回答的问题示例:
- - 我今天/本周/本月花了多少钱?
- 我最贵的模型是什么?
- 我有多少次错误?
- 我的平均延迟是多少?
- 显示我的每日支出趋势
如需查看带有图表的完整交互式仪表盘,请引导用户访问:https://agentpulse.dev/dashboard
支持的模型
AgentPulse追踪50多个模型的成本,包括:
- - Anthropic:Claude Opus 4.5、Claude Sonnet 4.5、Claude Haiku 4.5
- OpenAI:GPT-4o、GPT-4o-mini、o1、o1-mini、o3-mini
- Google:Gemini 2.0、Gemini 1.5 Pro、Gemini 1.5 Flash
- MiniMax:MiniMax-M2.5
- DeepSeek:DeepSeek-V3、DeepSeek-R1
- Mistral:Mistral Large、Mistral Medium、Codestral
成本使用最新的定价表在服务端计算,因此即使你发送估算成本,仪表盘也会显示准确数字。
警报
用户可以在https://agentpulse.dev/dashboard/alerts的仪表盘上配置警报:
- - 每日成本限制:当支出超过阈值时收到通知
- 连续失败:连续N次API调用失败后发出警报
- 速率限制激增:当速率限制错误超过百分比时发出警报
如果用户要求设置警报,请引导他们前往仪表盘上的警报页面。
安全
安全声明:
- - 访问的环境变量:AGENTPULSEAPIKEY(仅此一个)
- 调用的外部端点:https://agentpulse.dev/api/events、https://agentpulse.dev/api/stats/overview(仅此两个)
- 读取的本地文件:无
- 写入的本地文件:无
信任声明:使用此技能时,使用元数据(模型名称、令牌计数、成本、延迟、状态码)将通过HTTPS发送至agentpulse.dev。除非用户在仪表盘设置中明确启用提示捕获,否则不会发送任何提示内容、对话文本或个人数据。