Node.js & TypeScript SDK for DEVUP AI
The official devupai npm package provides typed, direct access to DEVUP AI models and multimodal APIs. Designed with zero runtime dependencies, native streaming iterators, and integrated Algerian Dinar (DZD) billing metadata.
Installation
Install the Official Package
The core devupai SDK requires zero production runtime dependencies and runs on Node.js 18+ with native fetch and Web Standard APIs.
npm install devupaiQuickstart
Client Initialization & First Request
Initialize the client with your DEVUP AI API key. The example below uses the documented deepseek-ai/DeepSeek-V4-Pro example model to demonstrate chat completions and response cost inspection:
import DevupAI from "devupai";
// Initialize the client with your API key
const client = new DevupAI({
apiKey: process.env.DEVUP_API_KEY!,
});
async function main() {
const response = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Pro", // Example model
messages: [
{
role: "system",
content: "You are a concise technical assistant.",
},
{
role: "user",
content: "Explain artificial intelligence in one paragraph.",
},
],
});
console.log(response.choices[0]?.message?.content);
console.log("Cost:", response._devup?.cost_dzd, "DZD");
console.log("Balance:", response._devup?.balance_dzd, "DZD");
}
main().catch(console.error);_devup object, containing settled request cost (cost_dzd) and remaining account balance (balance_dzd) in Algerian Dinar.Streaming Iterators
Real-Time Token Streaming with Billing Chunks
When setting stream: true, the SDK returns an AsyncIterable that yields incremental delta chunks followed by a dedicated final _devup billing chunk:
import DevupAI from "devupai";
const client = new DevupAI({
apiKey: process.env.DEVUP_API_KEY!,
});
async function streamResponse() {
const stream = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Pro", // Example model
messages: [
{
role: "user",
content: "Write a short poem about Algeria.",
},
],
stream: true,
});
for await (const chunk of stream) {
// Check for the final billing chunk containing settled cost and balance
if ("_devup" in chunk) {
console.log("\n--- Billing Summary ---");
console.log("Cost:", chunk._devup.cost_dzd, "DZD");
console.log("Remaining balance:", chunk._devup.balance_dzd, "DZD");
continue;
}
// Process incremental text deltas
process.stdout.write(chunk.choices?.[0]?.delta?.content ?? "");
}
}
streamResponse().catch(console.error);SDK Capabilities
Full-Spectrum Multimodal Support
Chat & Reasoning
Full support for chat completions, system prompts, reasoning tokens, and streaming responses.
client.chat.completions.create()Text Embeddings
Dense vector generation with native single-string and batch-array input support.
client.embeddings.create()Image Generation
Direct text-to-image synthesis with resolution, dimension, and batch controls.
client.images.generate()Audio & Speech
Text-to-speech generation and audio transcription with automatic format support.
client.audio.speech / transcriptionsAccount & Models
Retrieve real-time account balance in DZD and discover live model catalog entries.
client.balance / models.list()Webhook Verification
Web Crypto HMAC-SHA256 signature verification and typed payload reconstruction.
client.webhooks.verifySignature()Advanced SDK Capabilities
client.images.edit()client.images.proxy()client.rerank.create()client.video.generationsclient.video.editsclient.inference.run()Embeddings
Vector Embeddings Generation
Generate dense semantic embedding vectors for search, clustering, and RAG workflows. Pass a single string or an array of strings for batch processing:
import DevupAI from "devupai";
const client = new DevupAI({
apiKey: process.env.DEVUP_API_KEY!,
});
async function createEmbeddings() {
const response = await client.embeddings.create({
model: "BAAI/bge-m3", // Example embedding model
input: ["Hello world", "مرحبا بالعالم", "Bonjour le monde"],
});
console.log("Embedding vector dimensions:", response.data[0]?.embedding?.length);
console.log("Total embeddings generated:", response.data.length);
}
createEmbeddings().catch(console.error);Configuration
Client & Request-Level Settings
Distinguish between client-level constructor options and per-request execution options. Note that the core DevupAI constructor requires you to pass apiKey explicitly and does not auto-read environment variables:
import DevupAI from "devupai";
// 1. Client-level options (constructor)
// Note: apiKey is passed explicitly — the core client does not auto-read process.env
const client = new DevupAI({
apiKey: process.env.DEVUP_API_KEY!,
baseURL: "https://api.devupai.com/v1", // Optional custom endpoint
headers: {
"X-Application-Name": "my-service", // Custom default headers
},
});
// 2. Per-request options (timeout, abort signals, custom headers)
const controller = new AbortController();
const response = await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Pro",
messages: [{ role: "user", content: "Summarize Algeria in three sentences." }],
timeout: 30_000, // Timeout after 30 seconds
signal: controller.signal, // External cancellation signal
headers: {
"X-Request-Source": "worker-pool",
},
});Constructor Options (Client-Level)
apiKey(required): Your DEVUP AI API key.baseURL(optional): Defaults tohttps://api.devupai.com/v1.headers(optional): Custom default headers included on all requests.
Request Options (Per-Request)
signal(optional): AbortSignal to cancel in-flight requests.timeout(optional): Request timeout in milliseconds.headers(optional): Request-specific custom HTTP headers.
Error Handling
Structured Exception Handling with DevupAPIError
API and network failures throw instances of DevupAPIError with normalized status codes, error classifications, request IDs, and rate-limit headers:
import DevupAI, { DevupAPIError } from "devupai";
const client = new DevupAI({
apiKey: process.env.DEVUP_API_KEY!,
});
async function main() {
try {
await client.chat.completions.create({
model: "deepseek-ai/DeepSeek-V4-Pro",
messages: [{ role: "user", content: "Hello DEVUP AI" }],
});
} catch (error) {
if (error instanceof DevupAPIError) {
console.error("DEVUP API request failed:");
console.error("Status:", error.status); // HTTP status code (or 0 for network failure)
console.error("Message:", error.message); // Human-readable error message
console.error("Type:", error.type); // API error classification
console.error("Code:", error.code); // Machine-readable error code
console.error("Request ID:", error.requestId); // Unique x-request-id header for tracing
console.error("Retry-After:", error.retryAfter); // Retry-After header value if rate-limited
return;
}
throw error;
}
}
main().catch(console.error);Environment & Security
Runtime Support & Best Practices
Runtime Support Classification
Node.js (>= 18.0.0), native ESM, CommonJS, and TypeScript declaration builds.
Bun and Deno environments support standard Web APIs and npm module resolution.
Security Guidance
DEVUP AI API keys must be kept confidential and stored in secure server-side environment variables or secret managers.
Building with the Vercel AI SDK?
While devupai is the direct first-party SDK, DEVUP AI also publishes a dedicated devupai/ai provider designed for generateText, streamText, and React UI streaming hooks.
Start Building with the Official Node.js SDK
Generate an API key in your dashboard, install the package, and connect your Node.js applications to DEVUP AI today.