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.ZReleases 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 channelsThe 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.
| Subpath | Contents |
|---|---|
@openllmsh/sdk/client | The client above: vault session, HTTP and chat, device tunnel. |
@openllmsh/sdk/protocol | Schema contracts for requests, responses, streaming, providers, and the daemon. |
@openllmsh/sdk/wire | Wire-format transforms: Anthropic ↔ OpenAI adapters, SSE, token estimates. |
@openllmsh/sdk/tunnel | The device tunnel: binary mux, device grants, WebRTC helpers. |
@openllmsh/sdk/vault | Client-side crypto and API-key parsing. Only the barrel is public API. |
@openllmsh/sdk/openapi | The OpenAPI spec, the operations table, and callOperation(). |
@openllmsh/sdk/openapi/spec.json | The OpenAPI document itself. |
@openllmsh/sdk/mcp | The 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.
Related
- API reference
- Connect with OpenLLM: add OpenLLM to your own app without the SDK
- MCP server
Last updated on
Brand assets
Download the OpenLLM wordmark and icon as SVG or PNG for light and dark backgrounds, and the rules for using them in articles, integrations, and talks.
API reference
Reference for the OpenLLM API at https://www.openllm.sh/v1: authentication, OpenAI and Anthropic endpoints, streaming, idempotency, and response headers.