Skip to main content

Quickstarts

Node SDK quickstart - Bijak Cloud Docs

Install the Bijak Cloud Node SDK, authenticate, and run your first inference call from Node.js.

Prerequisites

  • Node.js 18 or later
  • A Bijak Cloud API key (create one in the dashboard under Settings โ†’ API keys)
  • A package manager: npm, pnpm, or yarn

Install the SDK

npm install @bijakcloud/node-sdk

The SDK ships with TypeScript types and is compatible with Node 18+, Bun, and Deno.

Authenticate

Create a .env.local file in your project root:

BIJAK_API_KEY=sk-bijak-your-key-here
BIJAK_REGION=my-cyberjaya

The SDK reads both variables on construction. Keep BIJAK_API_KEY out of source control โ€” the SDK does not load it from process.env at runtime; pass it explicitly to the client.

Run an inference call

import { BijakClient } from '@bijakcloud/node-sdk';

const client = new BijakClient({
  apiKey: process.env.BIJAK_API_KEY!,
  region: 'my-cyberjaya',
});

const response = await client.inference.chat({
  model: 'bijak-merlion-13b',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is PDPA in one sentence?' },
  ],
  temperature: 0.2,
});

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

Streaming responses

For longer completions, stream tokens as they arrive:

const stream = await client.inference.chatStream({
  model: 'bijak-merlion-13b',
  messages: [{ role: 'user', content: 'Summarise the seven PDPA principles.' }],
});

for await (const chunk of stream) {
  process.stdout.write(chunk.delta);
}

Streaming is server-sent-event based and works in Node 18+, Bun, and edge runtimes.

Error handling

The SDK throws typed errors. Catch them by class name:

import { BijakRateLimitError, BijakAuthError } from '@bijakcloud/node-sdk';

try {
  await client.inference.chat({ ... });
} catch (error) {
  if (error instanceof BijakRateLimitError) {
    // retry with backoff
  } else if (error instanceof BijakAuthError) {
    // rotate the API key
  }
}

Next steps