QVAC Logo

API Summary — v0.8.0

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: 31 functions in packages/sdk/client/api/ plus the profiler object.


Functions

cancel

Cancels an ongoing operation.

Signature:

function cancel(params): Promise<void>;

Throws:

  • INVALID_RESPONSE_TYPE — Response type does not match expected "cancel"
  • CANCEL_FAILED — The server reports cancellation failure

completion

Generates completion from a language model based on conversation history.

Signature:

function completion(params): {
  tokenStream: AsyncGenerator<string>;
  toolCallStream: AsyncGenerator<ToolCallEvent>;
  text: Promise<string>;
  toolCalls: Promise<ToolCallWithCall[]>;
  stats: Promise<CompletionStats | undefined>;
};

Throws:

  • INVALID_TOOLS_ARRAY — Invalid tools array provided
  • INVALID_TOOL_SCHEMA — A tool has an invalid schema

deleteCache

Deletes KV cache files.

Signature:

function deleteCache(params): Promise<{ success: boolean }>;

Throws:

  • INVALID_DELETE_CACHE_PARAMS — Neither all nor kvCacheKey was provided
  • DELETE_CACHE_FAILED — The server reports cache deletion failure

downloadAsset

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

Signature:

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

Throws:

  • DOWNLOAD_ASSET_FAILED — The download operation fails
  • STREAM_ENDED_WITHOUT_RESPONSE — Streaming ends without a final response (when using onProgress)
  • INVALID_RESPONSE_TYPE — Response type does not match expected "downloadAsset"

embed

Generates embeddings for a single text using a specified model.

Signature:

function embed(params: { modelId: string; text: string }): Promise<number[]>;
function embed(params: { modelId: string; text: string[] }): Promise<number[][]>;

Throws:

  • INVALID_RESPONSE_TYPE — Response type does not match expected "embed"

getModelInfo

Retrieves detailed information about a model, including cache status and loaded instances.

Signature:

function getModelInfo(params): Promise<ModelInfo>;

Throws:

  • INVALID_RESPONSE_TYPE — Response type does not match expected "getModelInfo"

invokePlugin

Invoke a non-streaming plugin handler.

Signature:

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

Throws:

  • INVALID_RESPONSE_TYPE — Response type does not match expected "pluginInvoke"

invokePluginStream

Invoke a streaming plugin handler.

Signature:

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

Throws:

  • INVALID_RESPONSE_TYPE — A chunk's type does not match expected "pluginInvokeStream"

loadModel

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

Signature:

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

// Hot-reload config on an already-loaded model
function loadModel(options: ReloadConfigOptions, rpcOptions?: RPCOptions): Promise<string>;

Throws:

  • MODEL_LOAD_FAILED — Model loading fails
  • STREAM_ENDED_WITHOUT_RESPONSE — Streaming ends without a final response (when using onProgress)
  • INVALID_RESPONSE_TYPE — Response type does not match expected "loadModel"

loggingStream

Opens a logging stream to receive real-time logs.

Signature:

function loggingStream(params): AsyncGenerator<LoggingStreamResponse>;

Throws:

  • INVALID_RESPONSE_TYPE — A chunk's type does not match expected "loggingStream"

modelRegistryGetModel

Retrieves a single model entry from the QVAC model registry by path and source.

Signature:

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

Throws:

  • QVAC_MODEL_REGISTRY_QUERY_FAILED — The registry query fails or model is not found

modelRegistryList

Returns all available models from the QVAC distributed model registry.

Signature:

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

Throws:

  • QVAC_MODEL_REGISTRY_QUERY_FAILED — The registry query fails

modelRegistrySearch

Searches the QVAC model registry with optional filters.

Signature:

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

Throws:

  • QVAC_MODEL_REGISTRY_QUERY_FAILED — The registry query fails

ocr

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

Signature:

function ocr(params): {
  blockStream: AsyncGenerator<OCRTextBlock[]>;
  blocks: Promise<OCRTextBlock[]>;
  stats: Promise<OCRStats | undefined>;
};

ping

Sends a ping request to the server and returns the pong response.

Signature:

function ping(): Promise<{ type: "pong"; number: number }>;

ragChunk

Chunks documents into smaller pieces for embedding.

Signature:

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

Throws:

  • RAG_CHUNK_FAILED — The chunking operation fails

ragCloseWorkspace

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

Signature:

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

Throws:

  • RAG_WORKSPACE_CLOSE_FAILED — The close operation fails

ragDeleteEmbeddings

Deletes document embeddings from the RAG vector database.

Signature:

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

Throws:

  • RAG_DELETE_FAILED — The delete operation fails or workspace doesn't exist

ragDeleteWorkspace

Deletes a RAG workspace and all its data.

Signature:

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

Throws:

  • RAG_DELETE_FAILED — The workspace doesn't exist or is currently loaded

ragIngest

Ingests documents into the RAG vector database.

Signature:

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

Throws:

  • RAG_SAVE_FAILED — The ingestion operation fails
  • STREAM_ENDED_WITHOUT_RESPONSE — Streaming ends unexpectedly (when using onProgress)

ragListWorkspaces

Lists all RAG workspaces with their open status.

Signature:

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

Throws:

  • RAG_LIST_WORKSPACES_FAILED — The operation fails

ragReindex

Reindexes the RAG database to optimize search performance.

Signature:

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

Throws:

  • RAG_SAVE_FAILED — The reindex operation fails or workspace doesn't exist
  • STREAM_ENDED_WITHOUT_RESPONSE — Streaming ends unexpectedly (when using onProgress)

ragSaveEmbeddings

Saves pre-embedded documents to the RAG vector database.

Signature:

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

Throws:

  • RAG_SAVE_FAILED — The save operation fails
  • STREAM_ENDED_WITHOUT_RESPONSE — Streaming ends unexpectedly (when using onProgress)

ragSearch

Searches for similar documents in the RAG vector database.

Signature:

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

Throws:

  • RAG_SEARCH_FAILED — The search operation fails

startQVACProvider

Starts a provider service that offers QVAC capabilities to remote peers.

Signature:

function startQVACProvider(params): Promise<object>;

Throws:

  • INVALID_RESPONSE_TYPE — Response type does not match expected "provide"
  • PROVIDER_START_FAILED — The server reports provider start failure

stopQVACProvider

Stops a running provider service and leaves the specified topic.

Signature:

function stopQVACProvider(params): Promise<object>;

Throws:

  • INVALID_RESPONSE_TYPE — Response type does not match expected "stopProvide"
  • PROVIDER_STOP_FAILED — The server reports provider stop failure

textToSpeech

Converts text to speech audio.

Signature:

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

transcribe

Provides a simple interface for transcribing audio by collecting all streaming results into a single string response.

Signature:

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

Throws:

  • TRANSCRIPTION_FAILED — Transcription fails

Example:

const text = await transcribe({
  modelId: "whisper-model",
  audioChunk: "/path/to/audio.wav",
});
console.log(text);

transcribeStream

Streams audio transcription results in real-time, yielding text chunks as they become available from the model.

Signature:

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

Throws:

  • TRANSCRIPTION_FAILED — Transcription fails

Example:

const stream = transcribeStream({
  modelId: "whisper-model",
  audioChunk: "/path/to/audio.wav",
});

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

translate

Translates text from one language to another using a specified translation model.

Signature:

function translate(params): {
  tokenStream: AsyncGenerator<string>;
  text: Promise<string>;
  stats: Promise<TranslationStats | undefined>;
};

Throws:

  • TRANSLATION_FAILED — Translation fails

unloadModel

Unloads a previously loaded model from the server.

Signature:

function unloadModel(params): Promise<void>;

Throws:

  • INVALID_RESPONSE_TYPE — Response type does not match expected "unloadModel"
  • MODEL_UNLOAD_FAILED — The server reports unload failure

Objects

profiler

Singleton object that collects and exports profiling data for SDK operations.

Shape:

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

Methods:

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

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.
INVALID_OPERATION_IN_RESPONSE50002Response operation didn't match the expected RAG operation.
STREAM_ENDED_WITHOUT_RESPONSE50003Streaming RPC ended without a final response.
INVALID_AUDIO_CHUNK_TYPE50004Invalid audio chunk input type provided.
INVALID_TOOLS_ARRAY50005Invalid tools array provided.
INVALID_TOOL_SCHEMA50006Invalid tool schema provided.
OCR_FAILED50007OCR operation failed.
RPC_NO_HANDLER50200No handler registered for request type.
RPC_REQUEST_NOT_SENT50201Request has not been sent yet.
RPC_RESPONSE_STREAM_NOT_CREATED50202Response stream not created.
RPC_CONNECTION_FAILED50203RPC connection failed.
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 returned an error.
DELEGATE_CONNECTION_FAILED50404Failed to connect to delegated provider.
SDK_NOT_FOUND_IN_NODE_MODULES50600QVAC SDK not found in node_modules.

Server errors

ErrorCodeSummary
MODEL_ALREADY_REGISTERED52001Model with the same ID is already registered.
MODEL_NOT_FOUND52002Model ID not found in the registry.
MODEL_NOT_LOADED52003Model exists but is not loaded.
MODEL_IS_DELEGATED52004Model is delegated and cannot be accessed as a local model.
UNKNOWN_MODEL_TYPE52005Unknown modelType in loadModel().
MODEL_LOAD_FAILED52200Failed to load model (generic).
MODEL_FILE_NOT_FOUND52201Model file not found at given path.
MODEL_FILE_NOT_FOUND_IN_DIR52202Expected model file not found in directory (e.g., by type).
MODEL_FILE_LOCATE_FAILED52203Failed to locate model file for the given modelType.
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) model artifacts are missing.
TTS_REFERENCE_AUDIO_REQUIRED52209TTS (Chatterbox) reference audio is required for voice cloning.
PARAKEET_ARTIFACTS_REQUIRED52210Parakeet model sources are missing.
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 file 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 vs provided).
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 a different embeddings model.
RAG_WORKSPACE_NOT_FOUND52806RAG workspace not found.
RAG_WORKSPACE_IN_USE52807RAG workspace is in use and can't be closed/deleted.
RAG_WORKSPACE_CLOSE_FAILED52808Failed to close RAG workspace.
RAG_LIST_WORKSPACES_FAILED52809Failed to list RAG workspaces.
RAG_CHUNK_FAILED52810Failed to chunk input into embeddings.
RAG_WORKSPACE_NOT_OPEN52811RAG workspace is not open.
FILE_NOT_FOUND53000File not found.
DOWNLOAD_CANCELLED53001Download cancelled.
CHECKSUM_VALIDATION_FAILED53002Downloaded file checksum validation failed.
HTTP_ERROR53003HTTP request failed with status code.
NO_RESPONSE_BODY53004No response body received from HTTP request.
RESPONSE_BODY_NOT_READABLE53005Response body is not readable.
NO_BLOB_FOUND53006No blob found for the requested resource.
DOWNLOAD_ASSET_FAILED53007Download failed.
SEEDING_NOT_SUPPORTED53008Seeding is only supported for Hyperdrive models.
HYPERDRIVE_DOWNLOAD_FAILED53009Hyperdrive download failed.
INVALID_SHARD_URL_PATTERN53010Invalid shard URL pattern for sharded downloads.
ARCHIVE_EXTRACTION_FAILED53011Failed to extract an archive.
ARCHIVE_UNSUPPORTED_TYPE53012Unsupported archive type.
ARCHIVE_MISSING_SHARDS53013Archive is missing required shards.
PARTIAL_DOWNLOAD_OFFLINE53014Partial download exists but offline prevents resuming.
REGISTRY_DOWNLOAD_FAILED53015Registry download failed.
DELETE_CACHE_FAILED53200Failed to delete cache.
INVALID_DELETE_CACHE_PARAMS53201Invalid parameters for deleteCache().
CACHE_DIR_NOT_ABSOLUTE53202Cache directory must be an absolute path.
CACHE_DIR_NOT_WRITABLE53203Cache directory is not writable.
SET_CONFIG_FAILED53350Failed to set config.

On this page