KEM Connect · API v1 · Early access
Build on KEM from your own backend.
Your product keeps its brand and owns its users’ data. KEM does the governed work behind it and tells you when it’s done.
Base URL: https://api.kem.ai/v1 (planned). During early access, use your workspace’s own origin with /api/v1.
Endpoints
- GET
/v1/agentsAgents this key may use.agents:read - POST
/v1/tasksAssign work: input, optional structured data and your own externalRef. Returns 202.tasks:create - GET
/v1/tasks/{id}Status, result, error code, whether a human approval is pending, the CI credits used (ciCredits), and machineGenerated: true.tasks:read - POST
/v1/intelligence/queriesAn evidence-based answer with validated citations, or “insufficient evidence”, flagged machineGenerated: true.intelligence:query - GET
/v1/intelligence/queries/{id}A stored answer with its evidence snapshot.intelligence:query
Ground rules
- Server to server only
- Never put a key in a browser or app. Keys are shown once and stored only as hashes.
- Scoped and revocable
- Limit a key to scopes, agents, a rate and an expiry. Keys can never approve, deploy or manage.
- Safe to retry
- Send Idempotency-Key on POST; repeats return the original response and never duplicate work.
- Webhooks over polling
- task.completed, task.failed, task.cancelled and task.awaiting_approval, each with ciCredits, signed with HMAC-SHA256 and retried for about 14 hours.
- Machine-generated content is flagged
- Task results, task webhooks and Intelligence answers carry "generatedBy": "ci" and "machineGenerated": true; social post events say who drafted the post. Tell your users when content is machine-generated.
Verify every webhook
import { createHmac, timingSafeEqual } from "node:crypto";
export function verifyKemWebhook(secret: string, rawBody: string, header: string) {
const parts = Object.fromEntries(header.split(",").map((p) => p.split("=", 2)));
const t = Number(parts.t);
if (!Number.isFinite(t) || Math.abs(Date.now() / 1000 - t) > 300) return false;
const expected = createHmac("sha256", secret).update(`${t}.${rawBody}`).digest();
const given = Buffer.from(parts.v1 ?? "", "hex");
return given.length === expected.length && timingSafeEqual(expected, given);
}Create keys and webhook endpoints in your workspace under Connect (admins and owners).
Get an API key