SILMARIL DOCUMENTATION

Developer First

Built for frontier AI labs running long-horizon agent systems. Secure a system in three steps by installing the SDK, initializing one Silmaril firewall instance, and classifying the execution boundaries that matter.

Languages
Cloud Providers
AI Gateways
Overview

Build With The Firewall

Silmaril is an AI application firewall that protects agent execution.

Silmaril evaluates intent, application context, tool calls, and accumulated execution state together before harmful outcomes materialize. Personalized security comes from the firewall lifecycle. Traces, data flows, and threat-hunting discoveries feed defenses tuned to the system they protect.

We recommend one Silmaril firewall instance per system. Send classification requests from the layer that controls model execution. Use an SDK, a framework handler, a LiteLLM guardrail, or an AI gateway.

Silmaril Firewall is not self-serve yet. Book a call with the Silmaril team to provision credentials, choose a deployment path, and receive the endpoint used by these examples.

Language SDKs

Quick Start

Pick the runtime that owns the inference call. Each panel shows the direct SDK path first, then the framework and gateway integrations that apply to that language.

Use the TypeScript SDK from services that own inference, tool execution, or orchestration boundaries.

Install

Install the core SDK for direct classify calls.

Install
npm install @silmaril-security/sdk
Initialize

Create one firewall client with the API key and classify endpoint issued by Silmaril.

Client
import { Firewall } from "@silmaril-security/sdk";

const fw = new Firewall({
  apiKey: process.env.SILMARIL_API_KEY!,
  apiUrl: process.env.SILMARIL_API_URL!,
});
Classify

Send the hook and tool name with each call so the firewall sees the execution state in context.

Hooks
import { HookLabel } from "@silmaril-security/sdk";

const result = await fw.classify(userInput, {
  hook: HookLabel.USER_INPUT,
});

await fw.classify(toolOutput, {
  hook: HookLabel.TOOL_RESPONSE,
  toolName: "read_file",
});
Vercel

Add the AI SDK packages only when Vercel owns model execution. Gateway routing and middleware can share the same firewall client.

Vercel AI SDK
npm install ai@^5
npm install @ai-sdk/openai
Vercel middleware
import { wrapLanguageModel, generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const model = wrapLanguageModel({
  model: openai("gpt-5.4"),
  middleware: fw.asMiddleware({ scanOutput: true }),
});

await generateText({ model, prompt: userInput });
Vercel AI Gateway
import { gateway, generateText, wrapLanguageModel } from "ai";

const model = wrapLanguageModel({
  model: gateway("anthropic/claude-sonnet-4.6"),
  middleware: fw.asMiddleware({ scanOutput: true }),
});

await generateText({
  model,
  prompt: userInput,
  providerOptions: {
    gateway: { tags: ["surface:assistant"] },
  },
});
LangChain / LangGraph

LangGraph.js can use the same LangChain callback handler through graph invocation config.

LangChain.js
npm install @langchain/core @langchain/openai
Callback handler
import { ChatOpenAI } from "@langchain/openai";

const handler = await fw.asLangChainHandler();
const model = new ChatOpenAI({ callbacks: [handler] });

await model.invoke("Hello");
LangGraph.js
const handler = await fw.asLangChainHandler();

await graph.invoke(state, {
  callbacks: [handler],
});
Shadow mode

Use shadow mode to measure would-block decisions with the same thresholds while traffic continues. Override individual adapters when a surface is ready to enforce. Direct classify calls return verdicts either way.

Observe before enforce
const fw = new Firewall({
  apiKey: process.env.SILMARIL_API_KEY!,
  apiUrl: process.env.SILMARIL_API_URL!,
  shadowMode: true,
});

const handler = await fw.asLangChainHandler({
  onClassify: (event) => {
    if (event.blocked && event.shadowMode) {
      telemetry.track("firewall.would_block", {
        hook: event.hook,
        score: event.result.score,
      });
    }
  },
});

const enforcingHandler = await fw.asLangChainHandler({
  shadowMode: false,
});
Errors

Framework adapters throw typed block exceptions in enforcement mode.

Block Handling
import { PromptBlockedException } from "@silmaril-security/sdk";

try {
  await generateText({ model, prompt: userInput });
} catch (err) {
  if (err instanceof PromptBlockedException) {
    audit({ score: err.score, threshold: err.threshold });
    return;
  }
  throw err;
}
AI Gateway

LiteLLM Guardrails

If LiteLLM already routes model traffic, add Silmaril as a guardrail on the proxy. Pre-call and post-call checks cover requests, responses, messages, and tool activity without changing application code.

Use warn mode while validating proxy coverage. Silmaril still evaluates the payload and returns warning metadata for would-block traffic, but LiteLLM keeps the call moving. Switch to enforcement when the gateway path is ready to stop unsafe traffic.

litellm config
guardrails:
  - guardrail_name: silmaril-firewall
    litellm_params:
      guardrail: generic_guardrail_api
      mode: [pre_call, post_call]
      api_base: os.environ/SILMARIL_GUARDRAIL_URL
      headers:
        x-api-key: os.environ/SILMARIL_API_KEY
      default_on: true
      unreachable_fallback: fail_open
      additional_provider_specific_params:
        on_error: warn
Self-hosting

Container Deployments

For customer-controlled deployments, run the firewall service and model as containers in the cloud account that holds the protected workload. SDKs use the deployed classify endpoint. LiteLLM uses the guardrail endpoint from the same stage.

Book a Call