Mistral AI
Protect your Mistral AI applications with Nyraxis guardrails using the mistralai SDK.
Setup
pip install nyraxis mistralaiSet your environment variables:
export NYRAXIS_API_KEY="your-nyraxis-api-key"
export MISTRAL_API_KEY="your-mistral-api-key"Manual Evaluate Mode
from nyraxis import NyraxisGuard
from mistralai import Mistral
guard = NyraxisGuard(api_key="your-nyraxis-api-key")
client = Mistral(api_key="your-mistral-api-key")
user_input = "Tell me how to hack a server"
result = guard.evaluate(user_input)
if result.is_safe:
response = client.chat.complete(
model="mistral-large-latest",
messages=[{"role": "user", "content": user_input}]
)
print(response.choices[0].message.content)
else:
print(f"Blocked: {result.reason}")Instrument Mode
from nyraxis import NyraxisGuard
guard = NyraxisGuard(api_key="your-nyraxis-api-key")
client = Mistral(api_key="your-mistral-api-key")
# Automatically evaluates all inputs and outputs
guarded_client = guard.instrument(client)
response = guarded_client.chat.complete(
model="mistral-large-latest",
messages=[{"role": "user", "content": "Hello!"}]
)What Gets Protected
- Input screening — blocks prompt injections, jailbreaks, and harmful content before reaching Mistral models
- Output filtering — scans model responses for policy violations
- Instrument mode — zero-code-change protection wrapping all chat and completion calls