Quick Start
This page gets a working integration in front of you fast. Pick the package that matches where your code runs — see Introduction if you’re unsure.
Browser chat — Client SDK
Section titled “Browser chat — Client SDK”The client works in terms of threads: you open a chat thread, then send or stream messages into it.
-
Install the package
Terminal window npm install @divinci-ai/client -
Initialize the client
import { DivinciClient } from "@divinci-ai/client";const client = new DivinciClient({releaseId: "rel_your-release-id",apiKey: "divinci_key_...", // for browsers in production, prefer a user token — see Authentication}); -
Open a thread and stream a reply
const thread = await client.chat.create();const reply = await client.chat.stream(thread.id, "Hello, how can you help me?", {assistantName: "your-assistant-id", // the release's assistant/model idonChunk: (text) => process.stdout.write(text),});console.log(reply.content);
Why stream() and not send()?
Section titled “Why stream() and not send()?”Replies are generated asynchronously: chat.send() returns an
acknowledgement while generation continues server-side. chat.stream()
holds the connection and resolves with the assistant’s message — it’s the
right default. To fetch history later, use chat.getTranscript(thread.id).
Server-side operations — Server SDK
Section titled “Server-side operations — Server SDK”-
Install the package
Terminal window npm install @divinci-ai/server -
Initialize the client
import { DivinciServer } from "@divinci-ai/server";const divinci = new DivinciServer({apiKey: process.env.DIVINCI_API_KEY,}); -
Create a workspace
const workspace = await divinci.workspaces.create({name: "My AI Assistant",});
Upload a document to a knowledge base
Section titled “Upload a document to a knowledge base”RAG documents belong to a collection (a vector index) inside a workspace. Create the collection, then upload a file buffer to it:
import { readFileSync } from "node:fs";
const collection = await divinci.rag.createCollection({ workspaceId: workspace.id, name: "Product docs",});
const file = readFileSync("./knowledge.pdf");
const doc = await divinci.rag.uploadDocument( workspace.id, collection.id, file, "knowledge.pdf", { mimeType: "application/pdf" },);
// Wait for chunking + embedding to finish before queryingawait divinci.rag.waitForProcessing(workspace.id, collection.id, doc.id);MCP integration — MCP SDK
Section titled “MCP integration — MCP SDK”import { McpClient } from "@divinci-ai/mcp";
const mcp = new McpClient({ serverUrl: "https://mcp.divinci.app",});
await mcp.connect();
// Tool discovery and invocation live on the `tools` accessorconst tools = await mcp.tools.listTools();
const result = await mcp.tools.callTool("search_knowledge", { query: "return policy",});Next steps
Section titled “Next steps”- Authentication — API keys, user tokens, and external users.
- Error Handling — the error classes every package throws.
- Client SDK · Server SDK · MCP SDK