Docs
Ship context-aware agents with a four-endpoint API.
Introduction
ContextKit is a payable context service for autonomous agents. It turns verbose conversations into compact memory, handoff payloads, and durable user profiles.
Quick Start
For the normal public paid flow, use Bankr-hosted x402. You do not need a ContextKit API key for these paid generation calls.
npm install contextkit
bankr x402 call https://x402.bankr.bot/0xdace98cd605dd56b2edc66f0f4df3687f64fd824/contextkit-summarize \
-X POST \
-d '{"messages":[{"role":"user","content":"Summarize this long agent conversation."}]}'Authentication
Bankr-hosted x402 calls
Best for new users and agents. Call x402.bankr.bot, approve payment with Bankr, and receive JSON. No ContextKit API key is required.
ContextKit API keys
Used for dashboard data, analytics, token estimates, webhook management, and advanced direct API integrations. Keys are scoped and can be revoked.
x402 Payments
Recommended production flow is Bankr-hosted x402: agents call
x402.bankr.bot, Bankr settles USDC on Base, then forwards to ContextKit internal endpoints. Advanced self-hosted clients can still use direct HTTP 402 challenge/retry flows.API Reference
POST/api/summarize$0.002
Summarize long conversations into concise optimized context.
Webhook: summarization.completed
POST/api/compress-context$0.003
Compress context into compact structured memory.
Webhook: context.compressed
POST/api/handoff$0.003
Generate a structured agent-to-agent continuation payload.
Webhook: handoff.generated
POST/api/extract-profile$0.004
Extract durable user preferences for reusable agent memory.
Webhook: profile.extracted
Webhooks
Webhook deliveries include `ContextKit-Signature`, `ContextKit-Event`, and `ContextKit-Request-Id` headers. Replay endpoints are available for audit recovery.
SDK Usage
import { ContextKit } from "contextkit";
const client = new ContextKit({
apiKey: process.env.CONTEXTKIT_API_KEY!,
x402: async (challenge) => bankrWallet.pay(challenge)
});
const context = await client.compressContext({ messages });Deployment
Deploy the web app to Vercel or Cloudflare Pages. Set `BANKR_LLM_KEY`, `CONTEXTKIT_WEBHOOK_SECRET`, `X402_PAY_TO`, and `X402_NETWORK`.
Error Handling
Errors are structured with `code`, `message`, `requestId`, and optional validation details so agents can retry intelligently.
Rate Limits
Default abuse prevention is 120 requests per IP per minute. Replace the storage adapter with durable appKV bindings in production.