·Docs

Rakshak

Getting started

Create an API key, install the SDK, and place Rakshak around your LLM calls.

1. Create a key

Open the Rakshak dashboard, create an API key, and store it in your server environment. The raw key is shown once.

RAKSHAK_API_KEY=rsk_your_key

2. Install the SDK

pip install rakshak

3. Guard user input

import os
import rakshak

client = rakshak.Client(
    api_key=os.environ["RAKSHAK_API_KEY"],
)

def handle_user_message(user_message: str) -> str:
    result = client.guard(user_message)
    if result.blocked:
        return "I can't help with that."

    return call_your_llm(user_message)

4. Guard model output

llm_response = call_your_llm(user_message)

result = client.sanitize(llm_response)
if result.blocked:
    return "[Response blocked]"

return result.safe_text