DEVUP Docs
Back to Dashboard

Integrations

Node.js SDK

Connect to DEVUP AI using the official devupai npm package. Built for Node.js, Bun, and Deno with TypeScript definitions, streaming completions, embeddings, and error handling.

Prerequisites

  • A DEVUP AI account with a valid API key (Dashboard → API Keys).
  • Node.js 18.0.0 or later (or a modern runtime such as Bun or Deno).

Installation

Install the official client package from npm:

npm install devupai

Create a client

Instantiate the client by passing your API key, or let the SDK read it automatically from the DEVUP_API_KEY environment variable:

import DevupAI from "devupai";

const apiKey = process.env.DEVUP_API_KEY;
if (!apiKey) throw new Error("Set the DEVUP_API_KEY environment variable.");

const client = new DevupAI({
  apiKey,
});

Chat completions

Create non-streaming completions using client.chat.completions.create:

import DevupAI from "devupai";

const apiKey = process.env.DEVUP_API_KEY;
if (!apiKey) throw new Error("Set the DEVUP_API_KEY environment variable.");

const client = new DevupAI({
  apiKey,
});

const response = await client.chat.completions.create({
  model: "deepseek-ai/DeepSeek-V4-Pro",
  messages: [{ role: "user", content: "Say hello in one word." }],
});

console.log(response.choices[0]?.message?.content);

Streaming

Stream tokens as they are generated.

import DevupAI from "devupai";

const apiKey = process.env.DEVUP_API_KEY;
if (!apiKey) throw new Error("Set the DEVUP_API_KEY environment variable.");

const client = new DevupAI({ apiKey });

const stream = await client.chat.completions.create({
  model: "deepseek-ai/DeepSeek-V4-Pro",
  messages: [{ role: "user", content: "Count from 1 to 5." }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "");
}
process.stdout.write("\n");

Embeddings

Generate dense vector representations for semantic search or retrieval with client.embeddings.create:

import DevupAI from "devupai";

const apiKey = process.env.DEVUP_API_KEY;
if (!apiKey) throw new Error("Set the DEVUP_API_KEY environment variable.");

const client = new DevupAI({
  apiKey,
});

const response = await client.embeddings.create({
  model: "BAAI/bge-m3",
  input: ["First document for search", "Second document for retrieval"],
});

console.log("Vectors:", response.data.length);
console.log("Dimensions:", response.data[0]?.embedding?.length);

Configuration

Configure client-level defaults such as base URLs and custom headers, or supply per-request timeouts and headers:

import DevupAI from "devupai";

const apiKey = process.env.DEVUP_API_KEY;
if (!apiKey) throw new Error("Set the DEVUP_API_KEY environment variable.");

const client = new DevupAI({
  apiKey,
  baseURL: "https://api.devupai.com/v1",
  headers: {
    "X-Application-Name": "docs-example",
  },
});

const response = await client.chat.completions.create({
  model: "deepseek-ai/DeepSeek-V4-Pro",
  messages: [{ role: "user", content: "Say hello in one word." }],
  timeout: 30000,
  headers: {
    "X-Request-Source": "nodejs-guide",
  },
});

console.log(response.choices[0]?.message?.content);

Error handling

Catch DevupAPIError to inspect HTTP status codes, error codes, and request identifiers:

import DevupAI, { DevupAPIError } from "devupai";

const apiKey = process.env.DEVUP_API_KEY;
if (!apiKey) throw new Error("Set the DEVUP_API_KEY environment variable.");

const client = new DevupAI({
  apiKey,
});

try {
  await client.chat.completions.create({
    model: "deepseek-ai/DeepSeek-V4-Pro",
    messages: [{ role: "user", content: "Hi" }],
  });
} catch (error) {
  if (error instanceof DevupAPIError) {
    console.log(error.name + " " + error.status);
  } else {
    throw error;
  }
}

For error classifications and status codes, see the Error handling guide.

Webhooks

The SDK includes built-in webhook signature verification utilities (client.webhooks.verifySignature and client.webhooks.constructEvent). For webhook configuration, secret management, and payload structures, see the Webhooks documentation.