TypeScript SDK
Install
Section titled “Install”npm install @runplex/sylonew SyloClient(options)
Section titled “new SyloClient(options)”import { SyloClient } from "@runplex/sylo";
const sylo = new SyloClient({ apiUrl: "https://sylo.runplex.dev", developerSecret: process.env.SYLO_SECRET, gatewayHost: "sylo.runplex.dev:8443", // optional, derived from apiUrl});| Option | Type | Required | Description |
|---|---|---|---|
apiUrl | string | Yes | Platform API URL |
developerSecret | string | Yes | Developer secret (sylo_sk_...) |
gatewayHost | string | No | Gateway tunnel host (default: {apiUrl hostname}:8443) |
fetch | typeof fetch | No | Custom fetch implementation |
createSandboxToken(request)
Section titled “createSandboxToken(request)”Create a session with credentials, policies, and configuration.
const session = await sylo.createSandboxToken({ tenantId: "acme", userId: "user_123", expiresIn: "10m", credentials: [ { name: "openai", envVar: "OPENAI_API_KEY", domain: "api.openai.com", header: "Authorization", value: `Bearer ${process.env.OPENAI_API_KEY}`, }, ], mitm: ["api.openai.com"], passthrough: ["your-api.com"], policies: { default: "deny", rules: [{ domain: "api.openai.com" }], rateLimit: { "api.openai.com": "20/min" }, }, pii: { action: "redact", patterns: ["ssn", "credit_card"] }, limits: { maxRequests: 1000, maxDuration: "30m" }, shadowMode: false,});// Returns: { token: "sylo_stk_...", expiresAt: "2026-...", credentials: [...] }sandboxEnv(session)
Section titled “sandboxEnv(session)”Get environment variables for tunnel mode:
const env = sylo.sandboxEnv(session);// {// SYLO_TOKEN: "sylo_stk_...",// SYLO_GATEWAY: "sylo.runplex.dev:8443",// SYLO_GATEWAY_API: "https://sylo.runplex.dev",// NODE_EXTRA_CA_CERTS: "/etc/sylo/ca.crt",// SSL_CERT_FILE: "/etc/sylo/ca.crt",// REQUESTS_CA_BUNDLE: "/etc/sylo/ca.crt",// OPENAI_API_KEY: "sylo_cred:openai", // from credentials[].envVar// }proxyEnv(session)
Section titled “proxyEnv(session)”Get environment variables for proxy mode:
const env = sylo.proxyEnv(session);// {// HTTPS_PROXY: "https://sylo_stk_...:x@sylo.runplex.dev:8443",// HTTP_PROXY: "https://sylo_stk_...:x@sylo.runplex.dev:8443",// ...same as sandboxEnv// }revokeSession(token)
Section titled “revokeSession(token)”Immediately revoke a session:
await sylo.revokeSession("sylo_stk_...");listSessions(options?)
Section titled “listSessions(options?)”const { sessions, total } = await sylo.listSessions({ status: "active", limit: 50, offset: 0,});queryAudit(options?)
Section titled “queryAudit(options?)”const { events, total } = await sylo.queryAudit({ tenantId: "acme", destination: "api.openai.com", policyDecision: "allow", limit: 100, offset: 0,});Error handling
Section titled “Error handling”import { SyloError } from "@runplex/sylo";
try { await sylo.createSandboxToken({ tenantId: "acme" });} catch (err) { if (err instanceof SyloError) { console.error(err.status); // HTTP status console.error(err.code); // "unauthorized", "invalid_request", etc. console.error(err.message); }}