Deuz SDK

Installation

Install @deuz-sdk/core, check runtime requirements, and pick the optional peers and subpath exports you need.

@deuz-sdk/core is a single package with zero runtime dependencies. Install it, and the chat core, the agentic tool loop, streaming, and the canonical UI wire are all available out of the box. Heavier or stateful capabilities (schema-typed objects, MCP, document parsing) pull in optional peers only when you actually use them.

Install

npm
npm install @deuz-sdk/core
pnpm
pnpm add @deuz-sdk/core
yarn
yarn add @deuz-sdk/core
bun
bun add @deuz-sdk/core

Requirements

The core is pure and web-first: it touches only Web APIs (fetch, Web Streams, TextDecoder, WebCrypto, atob/btoa). Anything stateful or non-deterministic — HTTP, clock, logging, metering, circuit-breaker, API keys, id generation — is injected through a single Dependencies seam, with no-op/in-memory defaults applied for you. As a result the same build runs unchanged on any runtime that has fetch plus Web Streams.

RuntimeSupportedNotes
Node.js>= 22.0.0Enforced via engines. Native fetch + Web Streams.
DenoWeb APIs available by default.
BunWeb APIs available by default.
Cloudflare WorkersImport @deuz-sdk/core/edge for the guaranteed-safe subset.
Vercel EdgeSame — use the /edge entry.
Browsers⚠️Works for the canonical wire, but never ship provider API keys to the client. Use the UI wire and a server route instead.

Node-only capabilities (filesystem skill sources, document parsers, the markdown memory vault, MCP stdio transport) live behind dedicated …/node subpaths and never leak node:* imports into the edge-safe core.

Zero runtime dependencies

The package ships nothing in dependencies. The chat core, resilience, metering, the four provider wires, the agentic loop, and the UI wire all run on Web APIs alone. The only things you may need to add are optional peers, and only for the specific features that use them.

Optional peer dependencies

Install a peer only when you reach for the feature in its row. Each is declared optional in peerDependenciesMeta, so package managers will not nag you for the ones you skip.

PeerInstall when you useFor
zod (or any Standard Schema lib) + @standard-community/standard-jsongenerateObject with a typed schemaConverts your schema to JSON Schema and infers the object's TypeScript type. You can also pass a raw JSON Schema and skip both.
@modelcontextprotocol/sdk@deuz-sdk/core/mcp / @deuz-sdk/core/mcp/stdioMCP client — discover and call tools over HTTP/SSE or stdio. Loaded lazily.
unpdf@deuz-sdk/core/rag/nodePDF document parsing for RAG.
mammoth@deuz-sdk/core/rag/nodeDOCX document parsing for RAG.
xlsx@deuz-sdk/core/rag/nodeXLSX spreadsheet parsing for RAG.
schema-typed generateObject
npm install zod @standard-community/standard-json
MCP client
npm install @modelcontextprotocol/sdk
rag/node document parsers
npm install unpdf mammoth xlsx

The rag/node parsers are independent — install only the formats you need. The RAG core (MIME sniffing, chunkers, retrieve/rerank, BM25, RRF) is edge-safe and needs no peers; only the Node document parsers do.

Subpath exports

The root export carries the free functions, the client, errors, and all canonical types. Everything else is a focused subpath so bundlers tree-shake what you don't import.

ImportPurpose
@deuz-sdk/coreFree functions (streamChat, generateText, generateObject, embed, embedMany), createClient, error taxonomy, pricing, middleware, all types
@deuz-sdk/core/anthropicAnthropic Messages provider (createAnthropic)
@deuz-sdk/core/openaiOpenAI Chat Completions + Responses (createOpenAI, createOpenAIResponses) + openaiEmbedding
@deuz-sdk/core/xaixAI Grok, OpenAI-compatible (createXai)
@deuz-sdk/core/googleGemini — compat (createGoogle) + native generateContent (createGoogleNative) + googleEmbedding
@deuz-sdk/core/google/extrasGemini explicit caching + Files API (createGeminiCache, uploadFile)
@deuz-sdk/core/voyageVoyage AI embeddings (createVoyage)
@deuz-sdk/core/vertexVertex AI — Claude (createVertexAnthropic) + Gemini compat (createVertexGoogle) and native (createVertexGoogleNative)
@deuz-sdk/core/pricingOptional USD cost table (2026) + createPriceProvider (token → $)
@deuz-sdk/core/middlewarewrapModel + bundled logging / simpleCache / redactPII / promptInjectionGuard
@deuz-sdk/core/imageSynchronous OpenAI-compatible image generation (generateImage)
@deuz-sdk/core/midjourneyAsync Midjourney (imagine — submit / poll / action / webhook)
@deuz-sdk/core/yunwuYunwu unified relay — createYunwu + 2026 YUNWU_MODELS catalog
@deuz-sdk/core/memoryPure memory layer — extract / reconcile / recall + store seam
@deuz-sdk/core/memory/markdownObsidian-style markdown MemoryStore (Node; hybrid .md + vector sidecar)
@deuz-sdk/core/ragRAG primitives — MIME sniff, chunkers, retrieve/rerank, BM25, RRF (edge-safe)
@deuz-sdk/core/rag/nodeNode document parsers — unpdf / mammoth / xlsx
@deuz-sdk/core/skillsAgent Skills — SKILL.md parser, progressive-disclosure registry, matcher seam
@deuz-sdk/core/skills/nodeNode filesystem SkillSource (nodeSkillSource)
@deuz-sdk/core/mcpMCP client over HTTP/SSE (edge-safe) (createMcpClient)
@deuz-sdk/core/mcp/stdioMCP client over stdio (Node-only) (createStdioMcpClient)
@deuz-sdk/core/uitoDeuzStreamResponse (server) + readDeuzStream (client) — our own UI wire
@deuz-sdk/core/edgeGuaranteed edge-safe subset (re-exports the Web-API-only surface)
@deuz-sdk/core/reactReact hooks — useChat / useObject (React = optional peer ^18 || ^19)

Verify it works

API keys are read from the environment at your app layer and passed into the provider factory — the SDK core never reads process.env itself.

verify.ts
import { streamChat } from '@deuz-sdk/core';
import { createAnthropic } from '@deuz-sdk/core/anthropic';

const anthropic = createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY! });

// streamChat returns synchronously; the request starts lazily on first access.
const res = streamChat({
  model: anthropic('claude-opus-4-8'),
  messages: [{ role: 'user', content: 'Say hello in one word.' }],
});

for await (const chunk of res.textStream) process.stdout.write(chunk);

const usage = await res.usage; // resolves when the stream finishes
console.log(`\n${usage.inputTokens} in / ${usage.outputTokens} out`);

res.textStream is an AsyncIterable<string> and res.usage is a Promise<Usage> — both are explained in streamChat.

Edge-safe subset

When you target Cloudflare Workers or Vercel Edge and want a build that is provably free of any Node API, import from the /edge entry. It re-exports the same streamChat / generateText / generateObject, the client, the base errors, and all types.

app/api/chat/route.ts (Edge runtime)
import { streamChat } from '@deuz-sdk/core/edge';
import { createAnthropic } from '@deuz-sdk/core/anthropic';
import { toDeuzStreamResponse } from '@deuz-sdk/core/ui';

export const runtime = 'edge';

const anthropic = createAnthropic({ apiKey: process.env.ANTHROPIC_API_KEY! });

export async function POST(req: Request) {
  const { messages } = await req.json();
  const res = streamChat({ model: anthropic('claude-opus-4-8'), messages });
  return toDeuzStreamResponse(res); // versioned Deuz UI wire
}

ESM and CJS

Every subpath ships both an ESM (import) and a CommonJS (require) build with matching .d.ts / .d.cts declarations, so the package resolves correctly under "moduleResolution": "Bundler", "Node16", or "NodeNext". It is authored against TypeScript strict mode (including noUncheckedIndexedAccess), so the public types are strict-ready in your project with no extra configuration.

ESM (recommended)
import { generateText } from '@deuz-sdk/core';
CommonJS
const { generateText } = require('@deuz-sdk/core');

Next steps

  • streamChat — the synchronous, never-throws streaming entry point.
  • generateText — buffered text plus the agentic tool loop.
  • generateObject — schema-typed structured output.
  • Providers — Anthropic, OpenAI, xAI, Gemini, Vertex, Yunwu, Voyage.

On this page