Quickstart
Production integration in minutes
This guide covers the minimum reliable pattern for creating, tracking, and consuming verified task outcomes in production.
1) Prerequisites
- • Server-side API key management.
- • Retry-safe request pipeline with idempotency support.
- • Status polling or webhook event handling.
2) Install SDK
npm install @kernprotocol/sdk3) Initialize client
import { KernClient } from "@kernprotocol/sdk";
const kern = new KernClient({
apiKey: process.env.KERN_API_KEY!,
baseUrl: process.env.KERN_API_BASE_URL,
});4) Create a task with idempotency
const task = await kern.tasks.create({
title: "Storefront verification",
instructions: "Capture storefront photo and open/closed status",
location: { lat: -12.0464, lng: -77.0428 },
}, {
idempotencyKey: crypto.randomUUID(),
});
console.log(task.id, task.status);Use one idempotency key per logical operation. On retry, reuse the same key to avoid duplicate task creation.
5) Read status and consume output
const current = await kern.tasks.get(task.id);
if (current.status === "completed") {
console.log("Evidence ready", current.evidence);
}6) Handle retries and rate limits
if (response.status === 429) {
const retryAfter = Number(response.headers.get("retry-after") ?? 1);
await sleep(retryAfter * 1000 + jitter());
// retry request with same idempotency key
}Combine exponential backoff, jitter, and idempotency reuse for safe recovery.
7) Flow summary
Your App
|
| create task (+ idempotency)
v
Kern API -----> Execution Network
| |
| task status | evidence capture
v v
Your App <----- Verified result