Documentation / typescript
SDK Reference

TypeScript / Node.js SDK

The official SupraWall TypeScript library for securing AI agents in Node.js and Edge environments. Built for performance, type safety, and seamless integration with Vercel AI SDK and LangChain.js.

Installation

Note: Requires Node.js 18+ or any modern Edge runtime.
npm install @suprawall/sdk

Quickstart

Initialize the SupraWall client and wrap your agentic functions to enable deterministic runtime enforcement.

import { SupraWall } from "@suprawall/sdk";

// 1. Initialize with your API Key
const supra = new SupraWall({
  apiKey: process.env.SUPRAWALL_API_KEY
});

// 2. Protect any tool or function
const protectedTool = supra.protect(async (params) => {
  // Your tool logic here
  return { success: true };
});

// 3. Executing the tool triggers policy evaluation
const result = await protectedTool.run({ amount: 500, target: "account_A" });

Framework Integrations

Vercel AI SDK

SupraWall integrates directly with Vercel's generateText and streamText tool execution pipelines.

import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { SupraWall } from "@suprawall/sdk";

const supra = new SupraWall({ apiKey: "ag_..." });

const { text } = await generateText({
  model: openai("gpt-4o"),
  tools: supra.wrapTools({
    transferFunds: {
      description: "Transfer money between accounts",
      execute: async ({ amount }) => ({ success: true }),
    }
  }),
  prompt: "Transfer 500 dollars."
});

LangChain.js

Protect any LangChain Runnable or StructuredTool.

import { SupraWall } from "@suprawall/sdk";
import { ChatOpenAI } from "@langchain/openai";

const supra = new SupraWall({ apiKey: "ag_..." });
const model = new ChatOpenAI({ modelName: "gpt-4o" });

// Wrap tools for LangChain execution
const tools = supra.wrapLangChainTools([myTool, myOtherTool]);

const response = await model.invoke(prompt, { tools });

Zero-Trust Vault

Ensure your agents never see plaintext secrets. Inject credentials directly into tool calls at the runtime layer.

// Use vault tokens in your prompt or tool arguments
const result = await supra.protect(myTool).run({
  token: "$SUPRAWALL_VAULT_STRIPE_KEY", // Resolved by SDK, never seen by LLM
  userId: "user_789"
});

Advanced Configuration

const supra = new SupraWall({
  apiKey: "ag_...",
  environment: "production",
  timeout: 3000, // 3s timeout for policy evaluation
  failOpen: false, // Set to true to allow actions if SupraWall is unreachable
  debug: false
});

TypeScript Questions?

Join our developer community for implementation advice and best practices.