integrate
它能做什么
这项技能为已经能正常运行的 AI 智能体或 LLM 应用添加 Olakai 监控。适合希望跟踪 AI 功能的使用情况和业务成果的开发者。
适用场景
- ✓当你已有一个能正常运行的 AI 应用,并想跟踪其表现的时候。
- ✓当你想设置自定义 KPI,例如处理的条目数或成功率的时候。
- ✓当你需要从头到尾检查监控是否正常工作的时候。
技能链接
https://github.com/andrewyng/context-hub/blob/main/content/olakai/skills/integrate/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“我想为我现有的 OpenAI 聊天机器人添加 Olakai 监控,并设置两个 KPI。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会用 Olakai SDK 包装 LLM 客户端,为这一个智能体设置几项 KPI,并运行检查以确认数据能够到达。设置过程使用 Olakai CLI。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Integrate Olakai into Existing AI Code
This skill guides you through adding Olakai monitoring to an existing AI agent or LLM-powered application with minimal code changes.
For full SDK documentation, see: https://app.olakai.ai/llms.txt
Prerequisites
- Existing working AI agent/application using OpenAI, Anthropic, or other LLM
- Olakai CLI installed and authenticated (
npm install -g olakai-cli && olakai login) - Olakai API key for your agent (get via CLI:
olakai agents get AGENT_ID --json | jq '.apiKey') - Node.js 18+ (for TypeScript) or Python 3.7+ (for Python)
Note: Each agent can have its own API key. Create one with
olakai agents create --name "Name" --with-api-key
Why Custom KPIs Are Essential
Adding monitoring is only the first step. The real value of Olakai comes from tracking custom KPIs specific to your agent's business purpose.
Without KPIs configured:
- Only basic token counts and request data
- No aggregated business KPIs on dashboard
- No alerting capabilities
- No ROI tracking
With KPIs configured:
- Custom KPIs (items processed, success rates, quality scores)
- Trend analysis and performance dashboards
- Threshold-based alerting
- Business value calculations
Plan to configure at least 2-4 KPIs that answer: "How do I know this agent is performing well?"
KPIs are unique per agent. If adding monitoring to an agent that needs the same KPIs as another already-configured agent, you must still create new KPI definitions for this agent. KPIs cannot be shared or reused across agents.
Understanding the customData to KPI Pipeline
Before adding monitoring, understand how custom data flows through Olakai:
SDK customData → CustomDataConfig (Schema) → Context Variable → KPI Formula → kpiData
Critical Rules
| Rule | Consequence |
|---|---|
| Only CustomDataConfig fields become variables | Unregistered customData fields are NOT usable in KPIs |
| Formula evaluation is case-insensitive | stepCount, STEPCOUNT, StepCount all work in formulas |
| NUMBER configs need numeric values | Don't send "5" (string), send 5 (number) |
IMPORTANT: The SDK accepts any JSON in
customData, but only fields registered as CustomDataConfigs are processed. Unregistered fields are stored but cannot be used in KPIs.
Quick Start (5-Minute Integration)
For TypeScript/JavaScript
1. Install the SDK:
npm install @olakai/sdk
2. Add tracking after your LLM call:
Before:
import OpenAI from "openai";
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: userMessage }],
});
After:
import OpenAI from "openai";
import { olakaiConfig, olakai } from "@olakai/sdk";
olakaiConfig({ apiKey: process.env.OLAKAI_API_KEY });
const openai = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
const response = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: userMessage }],
});
// Track the interaction (fire-and-forget)
olakai("event", "ai_activity", {
prompt: userMessage,
response: response.choices[0].message.content,
tokens: response.usage?.total_tokens,
userEmail: user.email,
task: "Customer Experience",
});
For Python
1. Install the SDK:
pip install olakai-sdk
2. Add tracking after your LLM call:
Before:
from openai import OpenAI
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": user_message}],
)
After:
from openai import OpenAI
from olakaisdk import olakai_config, olakai, OlakaiEventParams
olakai_config(os.getenv("OLAKAI_API_KEY"))
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": user_message}],
)
# Track the interaction
olakai("event", "ai_activity", OlakaiEventParams(
prompt=user_message,
response=response.choices[0].message.content,
tokens=response.usage.total_tokens,
userEmail=user.email,
task="Customer Experience",
))
Detailed Integration Guide
Step 1: Identify Your Integration Pattern
Pattern A: Single LLM Client You have one OpenAI/Anthropic client used throughout your app. Use the fire
常见问题
我应该设置多少个 KPI?
该技能建议为每个智能体规划至少两到四个 KPI。
KPI 可以在智能体之间共享吗?
不可以。该技能说明每个智能体都需要自己的 KPI 定义。
开始之前我需要什么?
Olakai CLI 登录、智能体 API 密钥,以及 Node.js 18 或 Python 3.7 或更高版本。
详情
作者的原始描述
Add Olakai monitoring to existing AI code — wrap your LLM client, configure custom KPIs, and validate the integration end-to-end
repo: andrewyng/context-hub
热度
- GitHub 星标
- 14k
- 排名
- #11273
- 许可证
- MIT
- 更新时间
- 2026/5/31
评论
- …
同一仓库的更多技能
get-api-docs
14k帮你的智能体在编写代码之前获取第三方 API 和库的最新文档,而不是依赖旧的记忆。
bloc-cubit
14k教你的智能体如何用 Bloc 或 Cubit 管理 Flutter 应用的状态,包括何时选择哪一个,以及便于测试的安全默认设置。
riverpod
14k教你的智能体如何用 Riverpod 管理 Flutter 应用的状态,涵盖 provider、异步数据和测试,并为每种情况提供合理的默认设置。
document-extraction
14k帮你的智能体读取 PDF、图片和电子表格,将其转换为干净的文本,并使用 LandingAI 的 ADE 服务提取发票总额等字段。