Skip to content

Installation

Prerequisites

vgi-rpc-typescript requires Bun runtime.

Install the package

Terminal window
bun add vgi-rpc-typescript

Optional: Python CLI

The vgi-rpc CLI is useful for testing and introspecting your servers:

Terminal window
pip install vgi-rpc[cli]

The CLI can describe services, call unary methods, and interact with streaming methods from the command line.

Verify installation

Create a minimal server to verify everything works:

import { Protocol, VgiRpcServer, str } from "vgi-rpc-typescript";
const protocol = new Protocol("Hello");
protocol.unary("hello", {
params: { name: str },
result: { greeting: str },
handler: async ({ name }) => ({ greeting: `Hello, ${name}!` }),
});
const server = new VgiRpcServer(protocol, { enableDescribe: true });
server.run();

Save this as server.ts and test with:

Terminal window
vgi-rpc --cmd "bun run server.ts" call hello name=World
# {"greeting": "Hello, World!"}