LLM. Cache. Search. From any application.
One connection line — and any Node/TS/JS app gets LLM, cache, vector search, and telemetry. Swap the adapter in config, never touch the code.
Three lines. Platform is live.
KBPlatform from @kb-labs/sdk/platform is an HTTP client for the Gateway. Zero external dependencies, uses native fetch. All calls go through POST /platform/v1/{adapter}/{method}.
Inside plugins — same adapters via in-process hooks useLLM(), useCache() — no HTTP round-trip.
import { KBPlatform } from '@kb-labs/sdk/platform';
const platform = new KBPlatform({
endpoint: process.env.KB_ENDPOINT!, // http://localhost:4000
apiKey: process.env.KB_API_KEY!,
});
// LLM, cache, vector search, telemetry — ready to useLLM. Cache. Vectors. Telemetry.
Each adapter is a typed proxy over the Unified Platform API. Provider is set in config — same code works for OpenAI and any custom adapter.
// Text completion
const result = await platform.llm.complete(
'Explain this function',
{
model: 'gpt-4o',
systemPrompt: 'You are a code assistant.',
temperature: 0.3,
}
);
console.log(result.content);
// { content: '...', usage: { promptTokens: 84, completionTokens: 312 }, model: 'gpt-4o' }
// Chat with tool calling
const res = await platform.llm.chatWithTools(messages, tools);
// { content, toolCalls: [{ id, name, input }], stopReason: 'tool_use' }In-process hooks. Zero HTTP overhead.
Plugins use the same adapters via SDK hooks — directly in memory, no network layer. Same ILLM, ICache, IAnalytics interfaces, different delivery.
Adapter access is declared in manifest.ts via withPlatform(). Platform applies governance, quotas, and namespace isolation automatically.
import { useLLM, useCache, useAnalytics, useStorage } from '@kb-labs/sdk';
// In-process — no HTTP round-trip, same interfaces as KBPlatform
const llm = useLLM();
const cache = useCache();
const analytics = useAnalytics();
const storage = useStorage();
const result = await llm.complete(prompt, { temperature: 0.2 });
await cache.set('result', result, 60_000);
await analytics.track('commit.plan.generated', { tokensUsed: result.usage.completionTokens });Swap adapter. Zero code changes.
LLM provider, cache backend, vector DB — all in kb.config.json. Change one line and the entire stack moves to a different provider. Plugins and external apps share the same interface.
// kb.config.json — swap adapter here, code stays the same
{
"platform": {
"adapters": {
"llm": "@kb-labs/adapters-openai",
"cache": "@kb-labs/adapters-redis",
"vectorStore": "@kb-labs/adapters-qdrant",
"analytics": "@kb-labs/adapters-analytics-duckdb"
},
"adapterOptions": {
"llm": { "model": "gpt-4o-mini" },
"cache": { "url": "redis://localhost:6379" }
}
}
}One SDK. Any Node app.
LLM, cache, search, and telemetry — no vendor lock-in. Adapter swaps in config.
npm install @kb-labs/sdk