Vector Docs

Terminal

JavaScript SDK

The Vector JavaScript SDK connects an application to vector serve. It includes typed requests, streaming events, and helpers that launch a locally installed Vector CLI. The first public @vectordevai/sdk release is awaiting publication approval.

Connect to a local server

Use Node.js 22 or newer. After the SDK package is published, install @vectordevai/sdk at the version matching your CLI. Install and sign in to the CLI separately.

vector serve --hostname 127.0.0.1 --port 4096
import { createVectorClient } from "@vectordevai/sdk/v2/client"

const client = createVectorClient({
  baseUrl: "http://127.0.0.1:4096",
  directory: process.cwd(),
  throwOnError: true,
})
const health = await client.global.health()
const session = await client.session.create({ title: "My integration" })

Launch a server from JavaScript

import { createVectorServer } from "@vectordevai/sdk/v2/server"

const server = await createVectorServer({ port: 0 })
try {
  console.log(server.url)
} finally {
  server.close()
}

The launcher finds vector on PATH. It does not install Vector or connect a provider. Pass an AbortSignal to stop the process when your application exits. Browser code should import the client entry only.

Authentication and API versions

Keep the server on loopback unless you have configured authenticated network access. The server can operate on files and run tools. With the release that ships the SDK, set VECTOR_SERVER_PASSWORD and optionally VECTOR_SERVER_USERNAME, then pass the corresponding Authorization header through the SDK client’s headers option. Never embed server credentials in a public webpage.

The root and /client exports retain grouped v1 arguments. The /v2/client export uses flat arguments. Match the SDK release to the server and consult its generated declarations for request and response types. The package includes its applicable license and third-party notices.