QVAC Logo

API Summary — v0.9.1 (latest)

One-page reference of all public functions and objects exported by @qvac/sdk

Auto-generated from .d.ts declarations and TSDoc comments.

For per-parameter and per-field details, hover symbols in your IDE or open node_modules/@qvac/sdk/dist. This page is intentionally a high-level index.

Fields shown: description, signature, throws, examples, deprecation. Fields intentionally omitted: parameter descriptions, return field descriptions (covered by IDE hover and .d.ts declarations).

Scope: 36 functions in packages/sdk/client/api/ plus the profiler object.


Functions

cancel

Cancels an ongoing operation.

Signature:

function cancel(params: CancelParams): Promise<void>;

Throws:

  • QvacErrorBase — When the response type is invalid or when the cancellation fails

Examples:

// Cancel inference
await cancel({ operation: "inference", modelId: "model-123" });
// Pause download (preserves partial file for automatic resume)
await cancel({ operation: "downloadAsset", downloadKey: "download-key" });
// Cancel download completely (deletes partial file)
await cancel({ operation: "downloadAsset", downloadKey: "download-key", clearCache: true });
// Cancel delegated remote download
await cancel({
  operation: "downloadAsset",
  downloadKey: "download-key",
  delegate: { topic: "topicHex", providerPublicKey: "peerHex" },
});
// Cancel RAG operation on default workspace
await cancel({ operation: "rag" });
// Cancel RAG operation on specific workspace
await cancel({ operation: "rag", workspace: "my-workspace" });

completion

Generates completion from a language model based on conversation history.

Returns a CompletionRun whose canonical surfaces are:

  • eventsAsyncIterable<CompletionEvent> of ordered, typed events.
  • finalPromise<CompletionFinal> with aggregated results once the stream ends (content, thinking, tool calls, stats, raw text).

Legacy convenience fields (tokenStream, text, toolCallStream, toolCalls, stats) are still available but deprecated — they derive from events / final internally.

Signature:

function completion(params: CompletionParams): CompletionRun;

Example:

import { z } from "zod";

const run = completion({
  modelId: "llama-2",
  history: [
    { role: "user", content: "What's the weather in Tokyo?" }
  ],
  stream: true,
  captureThinking: true,
  tools: [{
    name: "get_weather",
    description: "Get current weather",
    parameters: z.object({
      city: z.string().describe("City name"),
    }),
    handler: async (args) => {
      return { temperature: 22, condition: "sunny" };
    }
  }]
});

for await (const event of run.events) {
  if (event.type === "contentDelta") process.stdout.write(event.text);
  if (event.type === "toolCall") console.log(event.call.name, event.call.arguments);
}

const result = await run.final;
for (const toolCall of await result.toolCalls) {
  if (toolCall.invoke) {
    const toolResult = await toolCall.invoke();
    console.log(toolResult);
  }
}

deleteCache

Deletes KV cache files.

Signature:

function deleteCache(params: { all: true } | { kvCacheKey: string; modelId?: string }): Promise<{ success: boolean }>;

Throws:

  • QvacErrorBase — When the cache parameters are invalid (InvalidDeleteCacheParamsError) or the server reports a delete failure (DeleteCacheFailedError).

Example:

// Delete all caches
await deleteCache({ all: true });

// Delete entire cache key (all models)
await deleteCache({ kvCacheKey: "my-session" });

// Delete only specific model within cache key
await deleteCache({ kvCacheKey: "my-session", modelId: "model-abc123" });

diffusion

Generates images using a loaded diffusion model.

Signature:

function diffusion(params: DiffusionClientParams): DiffusionResult;

Example:

// txt2img
const { outputs, stats } = diffusion({ modelId, prompt: "a cat" });
const buffers = await outputs;
fs.writeFileSync("output.png", buffers[0]);

// img2img (SD/SDXL — SDEdit)
const initImage = fs.readFileSync("input.png");
const { outputs } = diffusion({ modelId, prompt: "oil painting style", init_image: initImage, strength: 0.7 });

// img2img (FLUX.2 — in-context conditioning)
// IMPORTANT: FLUX img2img requires `prediction: "flux2_flow"` to be set on the
// model config at loadModel time (e.g. `loadModel(src, { modelType: "diffusion",
// modelConfig: { prediction: "flux2_flow" } })`).
const { outputs } = diffusion({ modelId, prompt: "turn into watercolor", init_image: initImage });

// With progress tracking
const { progressStream, outputs } = diffusion({ modelId, prompt: "a cat" });
for await (const { step, totalSteps } of progressStream) {
  console.log(`${step}/${totalSteps}`);
}
const buffers = await outputs;

downloadAsset

Downloads an asset (model file) without loading it into memory.

This function is specifically designed for download-only operations and doesn't accept runtime configuration options like modelConfig or delegate. Use this for download-only operations instead of loadModel for better semantic clarity.

Signature:

function downloadAsset(options: DownloadAssetOptions, rpcOptions?: RPCOptions): Promise<string>;

Throws:

  • QvacErrorBase — When asset download fails, with details in the error message
  • QvacErrorBase — When streaming ends unexpectedly (only when using onProgress)
  • QvacErrorBase — When receiving an invalid response type from the server

Example:

// Download model without loading
const assetId = await downloadAsset({
  assetSrc: "/path/to/model.gguf",
  seed: true
});

// Download with progress tracking
const assetId = await downloadAsset({
  assetSrc: "pear://key123/model.gguf",
  onProgress: (progress) => {
    console.log(`Downloaded: ${progress.percentage}%`);
  }
});

embed

Has 2 overloads.

Overload 1 — Single text

Generates embeddings for a single text using a specified model.

Signature:

function embed(params: { modelId: string; text: string }, options?: RPCOptions): Promise<{ embedding: number[]; stats?: EmbedStats }>;

Throws:

  • QvacErrorBase — When the response type is invalid or when the embedding fails

Overload 2 — Multiple texts

Generates embeddings for multiple texts using a specified model.

Signature:

function embed(params: { modelId: string; text: string[] }, options?: RPCOptions): Promise<{ embedding: number[][]; stats?: EmbedStats }>;

Throws:

  • QvacErrorBase — When the response type is invalid or when the embedding fails

finetune

Has 2 overloads.

Overload 1 — Run / start / resume

Run / start / resume a finetune job. Returns a handle with a streaming progressStream and a terminal result promise.

Signature:

function finetune(params: FinetuneRunParams, rpcOptions?: RPCOptions): FinetuneHandle;

Overload 2 — Stop / getState / pause / cancel

Stop / pause / cancel an in-flight finetune, or query its current state.

Signature:

function finetune(params: FinetuneReplyParams, rpcOptions?: RPCOptions): Promise<FinetuneResult>;

getModelInfo

Returns status information for a catalog model, including cache state and loaded instances.

Signature:

function getModelInfo(params: GetModelInfoParams): Promise<{ actualSize?: number; addon: "llm" | "whisper" | "embeddings" | "nmt" | "vad" | "tts" | "ocr" | "parakeet" | "diffusion" | "other"; blobBlockLength?: number; blobBlockOffset?: number; blobByteOffset?: number; blobCoreKey?: string; cachedAt?: Date; cacheFiles: { actualSize?: number; cachedAt?: Date; expectedSize: number; filename: string; isCached: boolean; path: string; sha256Checksum: string }[]; engine?: string; expectedSize: number; isCached: boolean; isLoaded: boolean; loadedInstances?: { config?: unknown; loadedAt: Date; registryId: string }[]; modelId: string; name: string; params?: string; quantization?: string; registryPath?: string; registrySource?: string; sha256Checksum: string }>;

Throws:

  • QvacErrorBase — When the response type is invalid (InvalidResponseError) or the RPC layer fails.

heartbeat

Checks if a delegated provider is online by sending a heartbeat round-trip. Can also be used to check if the local SDK worker is responsive.

Signature:

function heartbeat(params?: { delegate?: { healthCheckTimeout?: number; providerPublicKey: string; timeout?: number; topic: string } }): Promise<HeartbeatResponse>;

Throws:

  • QvacErrorBase — When the provider is unreachable or the response is invalid.

Examples:

// Check if a delegated provider is online
try {
  await heartbeat({
    delegate: { topic: "topicHex", providerPublicKey: "peerHex", timeout: 3000 },
  });
  console.log("Provider is online");
} catch {
  console.log("Provider is offline");
}
// Check if the local SDK worker is responsive
await heartbeat();

invokePlugin

Invoke a non-streaming plugin handler.

Signature:

function invokePlugin(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): Promise<TResponse>;

Throws:

  • QvacErrorBase — When the response type is invalid (InvalidResponseError) or the RPC layer fails.

invokePluginStream

Invoke a streaming plugin handler.

Signature:

function invokePluginStream(options: InvokePluginOptions<TParams>, rpcOptions?: RPCOptions): AsyncGenerator<TResponse>;

Throws:

  • QvacErrorBase — When an intermediate response has the wrong type (InvalidResponseError) or the RPC layer fails.

loadModel

Has 2 overloads.

Overload 1 — Load new model

Loads a machine learning model from a local path, remote URL, or Hyperdrive key.

This function supports multiple model types: LLM (Large Language Model), Whisper (speech recognition), embeddings, NMT (translation), and TTS. It can handle both local file paths and Hyperdrive URLs (pear://).

When onProgress is provided, the function uses streaming to provide real-time download progress. Otherwise, it uses a simple request-response pattern for faster execution.

Signature:

function loadModel(options: LoadModelOptions, rpcOptions?: RPCOptions): Promise<string>;

Throws:

  • QvacErrorBase — When model loading fails, with details in the error message
  • QvacErrorBase — When streaming ends unexpectedly (only when using onProgress)
  • QvacErrorBase — When receiving an invalid response type from the server

Example:

// Local file path - absolute path
const localModelId = await loadModel({
  modelSrc: "/home/user/models/llama-7b.gguf",
  modelType: "llm",
  modelConfig: { contextSize: 2048 }
});

// Local file path - relative path
const relativeModelId = await loadModel({
  modelSrc: "./models/whisper-base.gguf",
  modelType: "whisper"
});

// Hyperdrive URL with key and path
const hyperdriveId = await loadModel({
  modelSrc: "pear://<hyperdrive-key>/llama-7b.gguf",
  modelType: "llm",
  modelConfig: { contextSize: 2048 }
});

// Remote HTTP/HTTPS URL with progress tracking
const remoteId = await loadModel({
  modelSrc: "https://huggingface.co/TheBloke/Llama-2-7B-Chat-GGUF/resolve/main/llama-2-7b-chat.Q4_K_M.gguf",
  modelType: "llm",
  onProgress: (progress) => {
    console.log(`Downloaded: ${progress.percentage}%`);
  }
});

// Multimodal model with projection
const multimodalId = await loadModel({
  modelSrc: "https://huggingface.co/.../main-model.gguf",
  modelType: "llm",
  modelConfig: {
    ctx_size: 512,
    projectionModelSrc: "https://huggingface.co/.../projection-model.gguf"
  },
  onProgress: (progress) => {
    console.log(`Loading: ${progress.percentage}%`);
  }
});

// Whisper with VAD model
const whisperId = await loadModel({
  modelSrc: "https://huggingface.co/.../whisper-model.gguf",
  modelType: "whisper",
  modelConfig: {
    mode: "caption",
    output_format: "plaintext",
    min_seconds: 2,
    max_seconds: 6,
    vadModelSrc: "https://huggingface.co/.../vad-model.bin"
  }
});

// Load with automatic logging - logs from the model will be forwarded to your logger
import { getLogger } from "@/logging";
const logger = getLogger("my-app");

const modelId = await loadModel({
  modelSrc: "/path/to/model.gguf",
  modelType: "llm",
  logger // Pass logger in options
});

Overload 2 — Hot-reload config

Hot-reloads configuration on an already loaded model.

Signature:

function loadModel(options: ReloadConfigOptions, rpcOptions?: RPCOptions): Promise<string>;

Throws:

  • QvacErrorBase — When model reload fails, with details in the error message
  • QvacErrorBase — When receiving an invalid response type from the server

Example:

// Load new model
const modelId = await loadModel({
  modelSrc: "pear://<hyperdrive-key>/whisper-tiny.gguf",
  modelType: "whisper",
  modelConfig: { language: "en" },
});

// Later, update the config without reloading the model
await loadModel({
  modelId,
  modelType: "whisper",
  modelConfig: { language: "es" },
});

loggingStream

Opens a logging stream to receive real-time logs.

Signature:

function loggingStream(params: LoggingParams): AsyncGenerator<LoggingStreamResponse>;

Throws:

  • QvacErrorBase — When the response type is invalid or when the stream fails

Example:

// Open a logging stream for a model
const logStream = loggingStream({ id: 'my-model-id' });

// Or stream SDK server logs
const sdkLogs = loggingStream({ id: SDK_LOG_ID });

for await (const logMessage of logStream) {
  console.log(`[${logMessage.level}] ${logMessage.namespace}: ${logMessage.message}`);
}

modelRegistryGetModel

Fetches a single model entry from the registry by its path and source.

Signature:

function modelRegistryGetModel(registryPath: string, registrySource: string): Promise<ModelRegistryEntry>;

Throws:

  • ModelRegistryQueryFailedError — When the model cannot be located or the registry query fails.

modelRegistryList

Returns all available models from the QVAC distributed model registry.

Signature:

function modelRegistryList(): Promise<ModelRegistryEntry[]>;

Throws:

  • ModelRegistryQueryFailedError — When the registry query fails.

modelRegistrySearch

Searches the model registry with optional filters for model type, engine, and quantization.

Signature:

function modelRegistrySearch(params: ModelRegistrySearchParams): Promise<ModelRegistryEntry[]>;

Throws:

  • ModelRegistryQueryFailedError — When the registry query fails.

ocr

Performs Optical Character Recognition (OCR) on an image to extract text.

Signature:

function ocr(params: OCRClientParams): { blocks: Promise<{ bbox?: [number, number, number, number]; confidence?: number; text: string }[]>; blockStream: AsyncGenerator<{ bbox?: [number, number, number, number]; confidence?: number; text: string }[]>; stats: Promise<{ detectionTime?: number; recognitionTime?: number; totalTime?: number } | undefined> };

Example:

// Non-streaming mode (default) - get all blocks at once
const { blocks } = ocr({ modelId, image: "/path/to/image.png" });
for (const block of await blocks) {
  console.log(block.text, block.bbox, block.confidence);
}

// Streaming mode - process blocks as they arrive
const { blockStream } = ocr({ modelId, image: imageBuffer, stream: true });
for await (const blocks of blockStream) {
  console.log("Detected:", blocks);
}

ragChunk

Chunks documents into smaller pieces for embedding. Part of the segregated flow: ragChunk() → embed() → ragSaveEmbeddings()

Signature:

function ragChunk(params: RagChunkParams, options?: RPCOptions): Promise<RagDoc[]>;

Throws:

  • RAGChunkFailedError — When the operation fails

Example:

const chunks = await ragChunk({
  documents: ["Long document text here..."],
  chunkOpts: {
    chunkSize: 256,
    chunkOverlap: 50,
    chunkStrategy: "paragraph",
  },
});

ragCloseWorkspace

Closes a RAG workspace, releasing in-memory resources (Corestore, HyperDB adapter, RAG instance).

Workspace lifecycle: Workspaces are implicitly opened. This function explicitly closes them, releasing memory and file locks. The workspace data remains on disk unless deleteOnClose is set to true.

Signature:

function ragCloseWorkspace(params?: RagCloseWorkspaceParams, options?: RPCOptions): Promise<void>;

Throws:

  • RAGCloseWorkspaceFailedError — When the operation fails

Example:

// Close a specific workspace
await ragCloseWorkspace({ workspace: "my-docs" });

// Close and delete in one call
await ragCloseWorkspace({ workspace: "my-docs", deleteOnClose: true });

ragDeleteEmbeddings

Deletes document embeddings from the RAG vector database.

Workspace lifecycle: This operation requires an existing workspace.

Signature:

function ragDeleteEmbeddings(params: RagDeleteEmbeddingsParams, options?: RPCOptions): Promise<void>;

Throws:

  • RAGDeleteFailedError — When the operation fails or workspace doesn't exist

Example:

await ragDeleteEmbeddings({
  ids: ["doc-1", "doc-2"],
  workspace: "my-docs",
});

ragDeleteWorkspace

Deletes a RAG workspace and all its data. The workspace must not be currently loaded/in-use.

Signature:

function ragDeleteWorkspace(params: RagDeleteWorkspaceParams, options?: RPCOptions): Promise<void>;

Throws:

  • RAGDeleteFailedError — When the workspace doesn't exist or is currently loaded

Example:

await ragDeleteWorkspace({ workspace: "my-docs" });

ragIngest

Ingests documents into the RAG vector database. Full pipeline: chunk → embed → save

Workspace lifecycle: This operation implicitly opens (or creates) the workspace. The workspace remains open until closed.

Signature:

function ragIngest(params: RagIngestParams, options?: RPCOptions): Promise<{ processed: RagSaveEmbeddingsResult[]; droppedIndices: number[] }>;

Throws:

  • RAGSaveFailedError — When the operation fails
  • StreamEndedError — When streaming ends unexpectedly (only when using onProgress)

Example:

// Simple ingest
const result = await ragIngest({
  modelId,
  documents: ["Document 1", "Document 2"],
});

// With progress tracking
const result = await ragIngest({
  modelId,
  documents: ["Document 1", "Document 2"],
  workspace: "my-docs",
  onProgress: (stage, current, total) => {
    console.log(`[${stage}] ${current}/${total}`);
  },
});

ragListWorkspaces

Lists all RAG workspaces with their open status.

Returns all workspaces that exist on disk. The open field indicates whether the workspace is currently loaded in memory and holding active resources (Corestore, HyperDB adapter, and possibly a RAG instance).

Signature:

function ragListWorkspaces(options?: RPCOptions): Promise<RagWorkspaceInfo[]>;

Throws:

  • RAGListWorkspacesFailedError — When the operation fails

Example:

const workspaces = await ragListWorkspaces();
// [{ name: "default", open: true }, { name: "my-docs", open: false }]

ragReindex

Reindexes the RAG database to optimize search performance. For HyperDB, this rebalances centroids using k-means clustering.

Workspace lifecycle: This operation requires an existing workspace.

Note: Reindex requires a minimum number of documents to perform clustering. For HyperDB, this is 16 documents by default. If there are insufficient documents, reindexed will be false with details explaining the reason.

Signature:

function ragReindex(params: RagReindexParams, options?: RPCOptions): Promise<RagReindexResult>;

Throws:

  • RAGSaveFailedError — When the operation fails or workspace doesn't exist
  • StreamEndedError — When streaming ends unexpectedly (only when using onProgress)

Example:

// Simple reindex
const result = await ragReindex({
  workspace: "my-docs",
});

// Check result
if (!result.reindexed) {
  console.log("Reindex skipped:", result.details?.reason);
}

// With progress tracking
const result = await ragReindex({
  workspace: "my-docs",
  onProgress: (stage, current, total) => {
    console.log(`[${stage}] ${current}/${total}`);
  },
});

ragSaveEmbeddings

Saves pre-embedded documents to the RAG vector database. Part of the segregated flow: chunk() → embed() → saveEmbeddings()

Workspace lifecycle: This operation implicitly opens (or creates) the workspace. The workspace remains open until closed.

Signature:

function ragSaveEmbeddings(params: RagSaveEmbeddingsParams, options?: RPCOptions): Promise<RagSaveEmbeddingsResult[]>;

Throws:

  • RAGSaveFailedError — When the operation fails
  • StreamEndedError — When streaming ends unexpectedly (only when using onProgress)

Example:

// Segregated flow
const chunks = await ragChunk({ documents: ["text1", "text2"] });
const { embedding: embeddings } = await embed({ modelId, text: chunks.map(c => c.content) });
const embeddedDocs = chunks.map((chunk, i) => ({
  ...chunk,
  embedding: embeddings[i],
  embeddingModelId: modelId,
}));
const result = await ragSaveEmbeddings({
  documents: embeddedDocs,
  workspace: "my-workspace",
});

ragSearch

Searches for similar documents in the RAG vector database.

Workspace lifecycle: This operation requires an existing workspace. If the workspace doesn't exist, returns an empty array.

Signature:

function ragSearch(params: RagSearchParams, options?: RPCOptions): Promise<RagSearchResult[]>;

Throws:

  • RAGSearchFailedError — When the operation fails

Example:

const results = await ragSearch({
  modelId,
  query: "AI and machine learning",
  topK: 5,
  workspace: "my-docs",
});

resume

Resumes the SDK runtime: restores all suspended Hyperswarm and Corestore resources and releases the lifecycle gate so all SDK operations are allowed again.

Safe to call from any lifecycle state — resume() is never blocked by the lifecycle gate (along with suspend() and state()). Idempotent. Also serves as the recovery path after a partial suspend failure.

After resume() resolves successfully, runtime state is "active" and non-lifecycle SDK operations are accepted normally.

Behavior of in-flight operations from before the previous suspend():

  • P2P / Hyperdrive downloads: continue automatically once their underlying swarm/corestore is restored
  • Delegated reply RPCs: auto-recover once the swarm reconnects (subject to delegate timeout)
  • Delegated stream RPCs: not recovered — re-issue after resume() works normally.

Signature:

function resume(): Promise<void>;

Throws:

  • RPCError — When one or more resources fail to resume. On partial failure the runtime stays "suspended" (operations remain blocked) so callers can retry resume().

Example:

// Foreground handler
await resume();
console.log(await state()); // "active"

startQVACProvider

Starts a provider service that offers QVAC capabilities to remote peers. The provider's keypair can be controlled via the seed option or QVAC_HYPERSWARM_SEED environment variable.

Signature:

function startQVACProvider(params: ProvideParams): Promise<{ error?: string; publicKey?: string; success: boolean; type: "provide" }>;

Throws:

  • QvacErrorBase — When the response type is not "provide" or the request fails.

state

Returns the current runtime lifecycle state.

Safe to call from any lifecycle state — state() is never blocked by the lifecycle gate (along with suspend() and resume()).

Signature:

function state(): Promise<LifecycleState>;

Throws:

  • InvalidResponseError — When the response envelope does not match the request type.

Example:

// Branch on lifecycle state before issuing work
const current = await state();
if (current !== "active") {
  await resume();
}

stopQVACProvider

Stops a running provider service and leaves the specified topic.

Signature:

function stopQVACProvider(params: StopProvideParams): Promise<{ error?: string; success: boolean; type: "stopProvide" }>;

Throws:

  • QvacErrorBase — When the response type is not "stopProvide" or the request fails.

suspend

Suspends the SDK runtime: pauses all registered Hyperswarm and Corestore resources and engages the lifecycle gate so non-lifecycle operations are blocked until resume() is called.

Safe to call from any lifecycle state — suspend() is never blocked by the lifecycle gate (along with resume() and state()). Idempotent.

After suspend() resolves, runtime state is "suspended" and any non- lifecycle SDK operation throws LifecycleOperationBlockedError until resume() is called.

In-flight operations started before suspend:

  • P2P / Hyperdrive downloads: stall cleanly, continue after resume()
  • HTTP downloads: bypass suspend entirely (bytes keep flowing)
  • Local native inference: runs to completion regardless
  • Delegated reply RPCs: stall, then auto-recover after resume() (subject to delegate timeout)
  • Delegated stream RPCs: severed, consumer iterator hangs silently; re-issue after resume() works normally.

Signature:

function suspend(): Promise<void>;

Throws:

  • RPCError — When one or more resources fail to suspend. The runtime still commits to "suspended" so callers can recover with resume().

Example:

// Background handler
await suspend();
console.log(await state()); // "suspended"

textToSpeech

Converts text to speech audio using a loaded TTS model.

Signature:

function textToSpeech(params: TtsClientParams, options?: RPCOptions): { buffer: Promise<number[]>; bufferStream: AsyncGenerator<number>; done: Promise<boolean> };

transcribe

Transcribe audio and return the complete text. Accepts either a file path or an audio buffer.

Signature:

function transcribe(params: TranscribeClientParams, options?: RPCOptions): Promise<string>;

transcribeStream

⚠️ Deprecated: Pass audio via transcribe() instead. This overload will be removed in the next major version.

Streaming transcription with upfront audio: sends full audio, yields text chunks as they arrive.

Has 2 overloads.

Overload 1 — Upfront audio (deprecated)

⚠️ Deprecated: Pass audio via transcribe() instead. This overload will be removed in the next major version.

Streaming transcription with upfront audio: sends full audio, yields text chunks as they arrive.

Signature:

function transcribeStream(params: TranscribeClientParams, options?: RPCOptions): AsyncGenerator<string>;

Overload 2 — Bidirectional session

Opens a bidirectional streaming transcription session. Audio is streamed in via write(), and transcription text is yielded as the model's VAD detects complete speech segments.

The returned session is single-use. Attempting to iterate a second time will throw a TranscriptionFailedError.

Signature:

function transcribeStream(params: TranscribeStreamClientParams, options?: RPCOptions): Promise<TranscribeStreamSession>;

translate

Translates text from one language to another using a specified translation model. Supports both NMT (Neural Machine Translation) and LLM models.

Signature:

function translate(params: TranslateClientParams, options?: RPCOptions): { stats: Promise<{ cacheTokens?: number; decodeTime?: number; encodeTime?: number; timeToFirstToken?: number; tokensPerSecond?: number; totalTime?: number; totalTokens?: number } | undefined>; text: Promise<string>; tokenStream: AsyncGenerator<string> };

Throws:

  • QvacErrorBase — When translation fails with an error message or when language detection fails

Example:

// Streaming mode (default)
const result = translate({
  modelId: "modelId",
  text: "Hello world",
  from: "en",
  to: "es"
  modelType: "llm",
});

for await (const token of result.tokenStream) {
  console.log(token);
}

// Non-streaming mode
const response = translate({
  modelId: "modelId",
  text: "Hello world",
  from: "en",
  to: "es"
  modelType: "llm",
  stream: false,
});

console.log(await response.text);

unloadModel

Unloads a previously loaded model from the server.

When the last model is unloaded (no more models remain), this function automatically closes the RPC connection, allowing the process to exit naturally without requiring manual cleanup.

Signature:

function unloadModel(params: UnloadModelParams): Promise<void>;

Throws:

  • QvacErrorBase — When the response type is invalid or when the unload operation fails

Objects

profiler

QVAC SDK Profiler

Shape:

const profiler: {
  clear(): void;
  disable(): void;
  enable(options?: ProfilerRuntimeOptions): void;
  exportJSON(options?: { includeRecentEvents?: boolean }): ProfilerExport;
  exportSummary(): string;
  exportTable(): string;
  getAggregates(): Record<string, AggregatedStats>;
  getConfig(): ResolvedProfilerConfig;
  isEnabled(): boolean;
  onRecord(callback: (event: ProfilingEvent) => void): () => void;
};

Methods:

  • clear() — Clears all aggregated data and the recent-events ring buffer.
  • disable() — Disables profiling.
  • enable(options?) — Enables profiling and resets all previously aggregated data.
  • exportJSON(options?) — Exports profiling data as a structured JSON object suitable for machine consumption.
  • exportSummary() — Exports a short, human-readable summary string of the aggregated stats.
  • exportTable() — Exports aggregated stats as a formatted ASCII table suitable for terminal output.
  • getAggregates() — Returns all aggregated stats keyed by operation name.
  • getConfig() — Returns the current effective profiler configuration.
  • isEnabled() — Returns whether profiling is currently enabled.
  • onRecord(callback) — Registers a listener for profiling events; returns an unsubscribe function.

Example:

import { profiler } from "@qvac/sdk";

profiler.enable({ mode: "summary" });
// ... run SDK operations ...
console.log(profiler.exportTable());
profiler.disable();

Errors

Public error codes thrown across the SDK. Catch via instanceof QvacErrorBase and read error.code / error.cause. Code ranges: 50,001–52,000 (client) and 52,001–54,000 (server).

Client errors

ErrorCodeSummary
INVALID_RESPONSE_TYPE50001Invalid response type received, expected: …
INVALID_OPERATION_IN_RESPONSE50002Invalid operation type in response
STREAM_ENDED_WITHOUT_RESPONSE50003Stream ended without receiving final response
INVALID_AUDIO_CHUNK_TYPE50004Invalid audio chunk type received
INVALID_TOOLS_ARRAY50005Invalid tools array provided
INVALID_TOOL_SCHEMA50006Invalid tool schema: …
OCR_FAILED50007OCR operation failed…
RPC_NO_HANDLER50200No handler function registered for request type: …
RPC_REQUEST_NOT_SENT50201Cannot perform operation - request has not been sent yet
RPC_RESPONSE_STREAM_NOT_CREATED50202Cannot perform operation - response stream not created
RPC_CONNECTION_FAILED50203RPC connection failed: …
RPC_INIT_TIMEOUT50204RPC initialization timed out after …ms — the worker process may have failed to start
PROVIDER_START_FAILED50400Failed to start provider…
PROVIDER_STOP_FAILED50401Failed to stop provider…
DELEGATE_NO_FINAL_RESPONSE50402No final response received from delegated provider
DELEGATE_PROVIDER_ERROR50403Delegated provider error: …
DELEGATE_CONNECTION_FAILED50404Failed to connect to delegated provider: …
SDK_NOT_FOUND_IN_NODE_MODULES50600QVAC SDK not found in node_modules. Checked: @qvac/sdk, @tetherto/sdk-mono, @tetherto/sdk-dev
WORKER_FILE_NOT_FOUND50601Worker file not found at …
CONFIG_FILE_NOT_FOUND50602Config file not found. Searched: …. Create qvac.config.json, qvac.config.js, or qvac.config.ts in your project root.
CONFIG_FILE_INVALID50603Config file at … is invalid: …
CONFIG_FILE_PARSE_FAILED50604Failed to parse config file at …: …
CONFIG_VALIDATION_FAILED50605Config validation failed: …
PEAR_WORKER_ENTRY_REQUIRED50606No plugins registered. Pear apps must spawn … as the worker entry. Run \
MULTIPLE_SDK_INSTALLATIONS50607Multiple QVAC SDK installations found: …. Remove all but one to avoid conflicts.
PROFILER_INVALID_CAPACITY50800Ring buffer capacity must be at least …

Server errors

ErrorCodeSummary
MODEL_ALREADY_REGISTERED52001Model with ID "…" is already registered
MODEL_NOT_FOUND52002Model with ID "…" not found
MODEL_NOT_LOADED52003Model with ID "…" is not loaded
MODEL_IS_DELEGATED52004Model "…" is a delegated model and cannot be accessed directly
UNKNOWN_MODEL_TYPE52005Unknown model type: …. If using a custom worker bundle, ensure the plugin for "…" is included in your qvac.config plugins array and rebuild with "npx qvac bundle sdk".
MODEL_LOAD_FAILED52200Failed to load model…
MODEL_FILE_NOT_FOUND52201Model file not found: …
MODEL_FILE_NOT_FOUND_IN_DIR52202… model file … not found in directory …
MODEL_FILE_LOCATE_FAILED52203Failed to locate … model file: …
PROJECTION_MODEL_REQUIRED52204Projection model source is required for multimodal LLM models
VAD_MODEL_REQUIRED52205VAD model source is required for this configuration
TTS_ARTIFACTS_REQUIRED52208TTS (Chatterbox) requires ttsTokenizerSrc, ttsSpeechEncoderSrc, ttsEmbedTokensSrc, ttsConditionalDecoderSrc, and ttsLanguageModelSrc
TTS_REFERENCE_AUDIO_REQUIRED52209TTS (Chatterbox) requires referenceAudioSrc (path or URL to a WAV file for voice cloning)
PARAKEET_ARTIFACTS_REQUIRED52210Parakeet model sources are missing. TDT requires parakeetEncoderSrc, parakeetDecoderSrc, parakeetVocabSrc, parakeetPreprocessorSrc. CTC requires parakeetCtcModelSrc, parakeetTokenizerSrc. Sortformer requires parakeetSortformerSrc.
MODEL_UNLOAD_FAILED52400Failed to unload model…
EMBED_FAILED52401Failed to generate embeddings…
EMBED_NO_EMBEDDINGS52402No embeddings returned from model
TRANSCRIPTION_FAILED52403Transcription failed…
AUDIO_FILE_NOT_FOUND52404Audio file not found or not accessible: …
TRANSLATION_FAILED52405Translation failed…
COMPLETION_FAILED52406Completion failed…
ATTACHMENT_NOT_FOUND52407Attachment not found at path: …
CANCEL_FAILED52408Failed to cancel operation…
TEXT_TO_SPEECH_FAILED52409Text-to-speech operation failed…
CONFIG_RELOAD_NOT_SUPPORTED52410Model "…" does not support hot config reload
MODEL_TYPE_MISMATCH52411Model type mismatch: expected "…", got "…"
OCR_FAILED52412OCR operation failed…
IMAGE_FILE_NOT_FOUND52413Image file not found or not accessible: …
INVALID_IMAGE_INPUT52414Invalid image input type provided
RAG_SAVE_FAILED52800Failed to save embeddings…
RAG_SEARCH_FAILED52801Failed to search embeddings…
RAG_DELETE_FAILED52802Failed to delete embeddings…
RAG_UNKNOWN_OPERATION52803Unknown RAG operation: …
RAG_HYPERDB_FAILED52804HyperDB RAG operation failed: …
RAG_WORKSPACE_MODEL_MISMATCH52805Workspace "…" is configured for model "…", but you're trying to use model "…". Use a different workspace or the same model
RAG_WORKSPACE_NOT_FOUND52806RAG workspace not found: …
RAG_WORKSPACE_IN_USE52807RAG workspace '…' is currently in use. Close it first.
RAG_WORKSPACE_CLOSE_FAILED52808Failed to close RAG workspace…
RAG_LIST_WORKSPACES_FAILED52809Failed to list RAG workspaces…
RAG_CHUNK_FAILED52810Failed to chunk documents…
RAG_WORKSPACE_NOT_OPEN52811RAG workspace '…' is not open
FILE_NOT_FOUND53000File not found: …
DOWNLOAD_CANCELLED53001Download was cancelled
CHECKSUM_VALIDATION_FAILED53002Checksum validation failed for …
HTTP_ERROR53003HTTP error: … …
NO_RESPONSE_BODY53004No response body received from HTTP request
RESPONSE_BODY_NOT_READABLE53005Response body is not readable
NO_BLOB_FOUND53006No blob found for …
DOWNLOAD_ASSET_FAILED53007Failed to download asset…
SEEDING_NOT_SUPPORTED53008Seeding is only supported for hyperdrive models
HYPERDRIVE_DOWNLOAD_FAILED53009Hyperdrive download failed: …
INVALID_SHARD_URL_PATTERN53010URL does not contain a valid sharded model pattern: …
ARCHIVE_EXTRACTION_FAILED53011Failed to extract archive: …
ARCHIVE_UNSUPPORTED_TYPE53012Unsupported archive type: …
ARCHIVE_MISSING_SHARDS53013Archive is missing required shard file: …
PARTIAL_DOWNLOAD_OFFLINE53014Cannot resume partial download (… bytes downloaded) - unable to connect. URL: …
REGISTRY_DOWNLOAD_FAILED53015Registry download failed: …
DELETE_CACHE_FAILED53200Failed to delete cache…
INVALID_DELETE_CACHE_PARAMS53201Invalid deleteCache parameters - provide either modelId or cacheKey
CACHE_DIR_NOT_ABSOLUTE53202Cache directory must be an absolute path
CACHE_DIR_NOT_WRITABLE53203Cache directory is not writable: ……
SET_CONFIG_FAILED53350Failed to set config…
CONFIG_ALREADY_SET53351Config has already been set and is immutable. Config can only be set once during SDK initialization.
FFMPEG_NOT_AVAILABLE53500FFmpeg is not available on this system
AUDIO_PLAYER_FAILED53501Audio player failed: …
INVALID_AUDIO_CHUNK_TYPE53502Invalid audio chunk type
DELEGATE_NO_FINAL_RESPONSE53700No final response received from delegated provider
DELEGATE_CONNECTION_FAILED53701Failed to connect to delegated provider: …
DELEGATE_PROVIDER_ERROR53702Delegated provider error: …
RPC_NO_DATA_RECEIVED53703No data received from request
RPC_UNKNOWN_REQUEST_TYPE53704Unknown request type received: …
PLUGIN_NOT_FOUND53850Plugin not found for model type "…". If using a custom worker bundle, ensure the plugin is included in your qvac.config plugins array and rebuild with "npx qvac bundle sdk".
PLUGIN_HANDLER_NOT_FOUND53851Handler "…" not found in plugin "…"
PLUGIN_REQUEST_VALIDATION_FAILED53852Request validation failed for handler "…"…
PLUGIN_RESPONSE_VALIDATION_FAILED53853Response validation failed for handler "…"…
PLUGIN_ALREADY_REGISTERED53854Plugin already registered for modelType: …
PLUGIN_HANDLER_TYPE_MISMATCH53855Handler "…" is …, but was called as …. Use invokePlugin() for reply handlers and invokePluginStream() for streaming handlers.
PLUGIN_LOGGING_INVALID53856Plugin "…" has invalid logging configuration: …
PLUGIN_DEFINITION_INVALID53857Plugin definition invalid for "…": …
PLUGIN_MODEL_TYPE_RESERVED53858modelType "…" is reserved for built-in plugins
PLUGIN_LOAD_CONFIG_VALIDATION_FAILED53859modelConfig validation failed for "…": …
LIFECYCLE_SUSPEND_FAILED53600Runtime suspend failed…
LIFECYCLE_RESUME_FAILED53601Runtime resume failed…
LIFECYCLE_OPERATION_BLOCKED53602Operation "…" is blocked while runtime state is "…"
PATH_TRAVERSAL53900Path traversal detected: "…" escapes base directory "…"
QVAC_MODEL_REGISTRY_QUERY_FAILED53950QVAC model registry query failed…

On this page