SDK & Examples
Integrate RaksHex with a single line of code in Node.js, Python, or Go.
We provide official client libraries to intercept LLM calls, calculate costs, scan prompts, and trigger kill-switches. Our SDKs run locally with asynchronous caching to ensure sub-millisecond overhead on your application's hot path.
Node.js SDK
Install via npm:
npm install @rakshex/sdk
Usage example with OpenAI:
import { Rakshex } from '@rakshex/sdk';
import OpenAI from 'openai';
const RaksHex = new RaksHex({ apiKey: process.env.RAKSHEX_API_KEY });
const openai = RaksHex.wrap(new OpenAI());
// The wrapped client automatically reports costs, attributes usage,
// and scans for prompt injections in the background.
const response = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'What is the cost of capital?' }],
user: 'user_12938' // Essential for per-user cost tracking
});
Python SDK
Install via pip:
pip install RaksHex-sdk
Usage example with Anthropic:
from rakshex import Rakshex
from anthropic import Anthropic
RaksHex = RaksHex(api_key="your_api_key")
client = Anthropic()
# Wrap the client
wrapped_client = RaksHex.wrap(client)
response = wrapped_client.messages.create(
model="claude-3-5-sonnet-20241022",
max_tokens=1024,
messages=[{"role": "user", "content": "Analyze code security."}],
metadata={"user_id": "usr_9921"}
)
