Skip to main content
This tutorial shows the direct Anthale TypeScript SDK path. Use it when you want explicit control over enforcement handling or when your stack does not match an existing Anthale integration.
Before you start, create an Anthale API key and a policy. Use Create an API Key for the key and First Policy for the policy setup.
If your application already uses the OpenAI Node client, start with the integration guide instead of wiring the direct SDK first.

OpenAI Integration

Wrap the OpenAI Node client with Anthale before you build a custom enforcement layer.

Use the direct SDK path when

  • You need to guard a custom model client, internal abstraction, or unsupported framework.
  • You want your application to inspect response.action directly instead of handling integration exceptions.
  • You want full control over where Anthale runs in your request pipeline.

Install

Send an enforcement request

Add metadata

Add your own request context in metadata, such as tenant, user, conversation, or request ID. That makes Anthale decisions easier to trace later. The keys below are examples. metadata can contain any fields your team uses for tracing and investigation. With the direct SDK, you attach metadata to each enforcement request:
For guidance on what belongs there, read Metadata & Logs.

Inspect the result

Anthale returns a runtime action plus supporting context. response.action can be allow, detect, redact, or block.

Handle each action

For the policy-side explanation of allow, detect, redact, and block, read Actions and Evaluation Flow.

What to expect

This blocked example still returns a normal SDK response. Anthale does not raise a policy-violation exception in the direct SDK path. Your code inspects response.action and decides what happens next.

Verify the direct SDK path

  • Send one benign request. The SDK should return a normal response object. In a starter policy, that usually means allow.
  • Send one request that your policy should block. Confirm response.action is block and that your application stops before the model call.
  • If the policy is configured to redact, send content that should be sanitized and confirm you pass response.redacted_messages downstream instead of the original messages.
The direct SDK path is wired correctly when your service can continue on allow or detect, stop on block, and swap to sanitized content on redact.

anthale-node

TypeScript SDK source, integrations, and examples.

anthale-openapi

OpenAPI contract used to generate Anthale API clients.

Next steps

From here, compare this with OpenAI Integration for TypeScript, the Python Direct SDK Path, or Policies.
Last modified on April 25, 2026