Build

SDK

@openllmsh/sdk is the one package that holds everything a client needs to talk to OpenLLM: typed contracts, wire adapters, the device tunnel, vault crypto, the OpenAPI spec, and the MCP tools.

@openllmsh/sdk is one package with everything a client needs to talk to OpenLLM. The OpenLLM web app, the openllm CLI, and its daemon all run this code. It replaces the separate protocol, tunnel, and vault packages, and everything in it ships under one version.

You don't need the SDK to call the API. Any OpenAI or Anthropic SDK works once you change the base URL. See Any client. Use the SDK when you want typed OpenLLM contracts, the vault, or device access.

Install

bun install github:openllmsh/sdk#vX.Y.Z

Releases are tagged with the OpenLLM release version. Pin a tag.

Quickstart

import { createClient } from "@openllmsh/sdk/client";

const ollm = createClient({
  origin: "https://www.openllm.sh",
  apiKey, // sk-llm-…
  transport: { fetch, websocket: WebSocket },
});

// Streaming chat: a fetch Response whose body is the SSE stream.
const res = await ollm.chat.completions.create(
  { model: "plus", messages, stream: true },
  { signal },
);

// Any public API operation, typed from the OpenAPI spec.
await ollm.http.call("marketplace.launch", {});

ollm.close(); // zeroes key material and closes device channels

The client takes fetch, WebSocket, and an optional WebRTC factory from you, so the same code runs in the browser, Bun, and Node.

Subpaths

There is no root import. Import the subpath you need, and nothing else comes along.

SubpathContents
@openllmsh/sdk/clientThe client above: vault session, HTTP and chat, device tunnel.
@openllmsh/sdk/protocolSchema contracts for requests, responses, streaming, providers, and the daemon.
@openllmsh/sdk/wireWire-format transforms: Anthropic ↔ OpenAI adapters, SSE, token estimates.
@openllmsh/sdk/tunnelThe device tunnel: binary mux, device grants, WebRTC helpers.
@openllmsh/sdk/vaultClient-side crypto and API-key parsing. Only the barrel is public API.
@openllmsh/sdk/openapiThe OpenAPI spec, the operations table, and callOperation().
@openllmsh/sdk/openapi/spec.jsonThe OpenAPI document itself.
@openllmsh/sdk/mcpThe MCP tool definitions and createMcpServer.

License

protocol/, openapi/, mcp/, and client/ are Apache-2.0. wire/, tunnel/, and vault/ are under the Business Source License 1.1, which includes a competing-service clause.

Last updated on

On this page