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.
Recommended TypeScript integration
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.actiondirectly 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 inmetadata, 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:
Inspect the result
Anthale returns a runtime action plus supporting context.response.action can be allow, detect, redact, or block.
Handle each action
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 inspectsresponse.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.actionisblockand that your application stops before the model call. - If the policy is configured to
redact, send content that should be sanitized and confirm you passresponse.redacted_messagesdownstream instead of the originalmessages.
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.Related repositories
anthale-node
TypeScript SDK source, integrations, and examples.
anthale-openapi
OpenAPI contract used to generate Anthale API clients.