QVAC Logo

Quickstart

Run your first example using the JS/TS SDK. At the end, you'll find instructions to run any example in this documentation.

Requirements

  • Node.js \geq v22.17
  • npm \geq v10.9

Step-by-step

Create the examples workspace:

mkdir qvac-examples
cd qvac-examples
npm init -y && npm pkg set type=module

Install the SDK:

npm i @qvac/sdk

Create the quickstart script:

quickstart.js
import { loadModel, LLAMA_3_2_1B_INST_Q4_0, completion, unloadModel, } from "@qvac/sdk";
try {
    // Load a model into memory
    const modelId = await loadModel({
        modelSrc: LLAMA_3_2_1B_INST_Q4_0,
        modelType: "llm",
        onProgress: (progress) => {
            console.log(progress);
        },
    });
    // You can use the loaded model multiple times
    const history = [
        {
            role: "user",
            content: "Explain quantum computing in one sentence",
        },
    ];
    const result = completion({ modelId, history, stream: true });
    for await (const token of result.tokenStream) {
        process.stdout.write(token);
    }
    // Unload model to free up system resources
    await unloadModel({ modelId });
}
catch (error) {
    console.error("❌ Error:", error);
    process.exit(1);
}

Run the quickstart script:

node quickstart.js

Running examples

Follow these instructions to run any example in this documentation:

  • All examples are self-contained, runnable JavaScript scripts. Use the qvac-examples workspace created in this quickstart to store and run them as you explore this documentation.
  • Run each example with the indicated compatible JavaScript environment. QVAC supports multiple environments (Node.js, Bare, and Expo), but some examples might use Node-specific APIs (e.g., process or fs) and won't run on Bare or Expo. Each example notes its compatible environment.
  • Some examples also provide a TypeScript version. If you want to run TS directly, install the required dev dependencies:
    npm i -D tsx typescript

On this page