@aimform/ai
A single-package AI SDK that handles everything from real-time chat streaming to multi-layer memory persistence. Plug in your LLM, database, and transport — the rest is automatic.
Quick Start
pnpm add @aimform/ai
import { AI } from "@aimform/ai";
const ai = new AI({
model: "deepseek-v4-flash",
apiKeys: { deepseekApiKey: process.env.DEEPSEEK_API_KEY },
db: dbAdapter,
transport: transportAdapter,
});
const result = await ai.chat({
runId: crypto.randomUUID(),
conversationId: "conv-1",
messages: [{ role: "user", content: "What can you do?" }],
toolContext: { userId: "user-1", profileId: "profile-1", sessionId: "s1", env: {} },
});
Architecture
Every component is an adapter interface — swap providers at any level.
| Layer | Interface | Default Implementations |
|---|---|---|
| LLM | LLMAdapter | OpenAI, Anthropic, DeepSeek |
| Database | DatabaseAdapter (from @aimform/core) | D1, Neon, Postgres |
| Transport | ChatTransportAdapter | Cloudflare Agents SDK, Raw DO |
| Memory | MemoryStorage | DB-backed with 5-layer system |
| Plugins | 12 plugin interfaces | 25+ provider implementations |
Sections
- Getting Started — Installation and first chat
- Chat Engine — Streaming, tool calling, blocks
- Memory System — 5-layer conversation memory
- Plugins — File processing, vision, OCR, code gen
- Transport — Real-time event delivery
- Deployment — Cloudflare, AWS, VPS setups