The TypeScript SDK is a zero-dependency wrapper around the Horizons HTTP API.
baseUrl points to your self-hosted horizons_server instance (or your own server built on horizons_core).
It uses:
fetch for HTTP
ReadableStream parsing for server-sent events (SSE)
Install
npm install @horizons-ai/sdk
Create a client
import { HorizonsClient, OnboardAPI } from "@horizons-ai/sdk";
const orgId = "00000000-0000-0000-0000-000000000000";
const client = new HorizonsClient("http://localhost:8000", orgId, {
agentId: "agent:demo",
// apiKey: process.env.HORIZONS_API_KEY,
});
const onboard = new OnboardAPI(client);
const handle = await onboard.createProject();
console.log(handle.project_id);
Publish events
import { EventsAPI } from "@horizons-ai/sdk";
const events = new EventsAPI(client);
await events.publish({
topic: "demo.hello",
source: "demo",
payload: { hello: "world" },
dedupe_key: "demo:1",
});
Stream agent runs (SSE)
import { AgentsAPI } from "@horizons-ai/sdk";
const agents = new AgentsAPI(client);
for await (const event of agents.chatStream("dev.noop", { prompt: "hello" })) {
console.log(event);
}
Propose and approve actions
import { ActionsAPI } from "@horizons-ai/sdk";
const actions = new ActionsAPI(client);
const actionId = await actions.propose({
agent_id: "agent:demo",
action_type: "demo.notify",
payload: { message: "hello from ts sdk" },
risk_level: "low",
context: { source: "docs" },
dedupe_key: "ts-sdk-action-1",
});
await actions.approve(actionId, "docs demo");
const pending = await actions.pending(20, 0);
console.log("pending:", pending.length);