Skip to content

Quick Start

Copy page

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.

The client works in terms of threads: you open a chat thread, then send or stream messages into it.

  1. Install the package

    Terminal window
    npm install @divinci-ai/client
  2. 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
    });
  3. 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 id
    onChunk: (text) => process.stdout.write(text),
    });
    console.log(reply.content);

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

  1. Install the package

    Terminal window
    npm install @divinci-ai/server
  2. Initialize the client

    import { DivinciServer } from "@divinci-ai/server";
    const divinci = new DivinciServer({
    apiKey: process.env.DIVINCI_API_KEY,
    });
  3. Create a workspace

    const workspace = await divinci.workspaces.create({
    name: "My AI Assistant",
    });

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 querying
await divinci.rag.waitForProcessing(workspace.id, collection.id, doc.id);
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` accessor
const tools = await mcp.tools.listTools();
const result = await mcp.tools.callTool("search_knowledge", {
query: "return policy",
});