NylorunDocsBeta
BuildRunDeployReferenceMore

Connect clients

Talk to Runtime from a trusted application backend.

Application clients use the server credential. Browser applications need an authorized backend; do not put NYLORUN_SERVER_KEY in the browser.

import { createClient } from "@nylorun/agents";

const client = createClient({
  url: process.env.NYLORUN_RUNTIME_URL,
  key: process.env.NYLORUN_SERVER_KEY,
});

await client.saveAgent(assistant, { implementationVersion: "app-1" });

const session = await client.createSession({
  agentId: assistant.id,
  ownerUserId: authenticatedUser.id,
});

await session.input("Look up item 123", { idempotencyKey: requestId });
const history = await session.history();

createClient reads NYLORUN_RUNTIME_URL and NYLORUN_SERVER_KEY when you omit options. There is no implicit URL default in the SDK.

MethodRole
saveAgent(agent, { implementationVersion })PUT /v1/agents/:id with the complete manifest. Rejects middleware closures.
createSession({ agentId, ownerUserId, ... })PUT /v1/sessions/:id. Trusted ownerUserId.
listAgents() / listSessions({ agentId? })Local discovery conveniences.
session(id)Reattach a SessionClient.
Vault CRUDSee Vault.

Session helpers (input, approve, respond, cancel, history, observe, inspect) are on Sessions. Every user command requires a stable idempotencyKey.

ownerUserId must come from trusted server authentication. Application credentials are not browser credentials.

Next step

On this page