Platform API · SDK

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.

External apps

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.

typescript
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 use
Adapters

LLM. 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.

LLM
OpenAI, KB Labs Gateway
complete() · chatWithTools() · streaming
Cache
Redis, in-memory
get/set/delete/clear · TTL · glob patterns
Vector Store
Qdrant
upsert · search · filter · count
Analytics
DuckDB, SQLite, JSONL
track · event · metric · log · batching
Embeddings
OpenAI, Voyage AI
embed() · embedBatch()
Storage
Local FS, S3
read · write · list · delete
typescript
// 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' }
Inside plugins

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.

typescript
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 });
Configuration

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.

LLMOpenAI GPT-4o / KB Labs Gateway / customCacheRedis · in-memory · customVector StoreQdrant · in-memory · customAnalyticsDuckDB · SQLite · JSONL fileEmbeddingsOpenAI · Voyage AI · customStorageLocal FS · S3 · custom
json
// 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" }
    }
  }
}
Platform API

One SDK. Any Node app.

LLM, cache, search, and telemetry — no vendor lock-in. Adapter swaps in config.

npm install @kb-labs/sdk
Platform API — KB Labs