Altirs
SDKs

Ruby SDK

Use the Altirs Ruby SDK to run guardrail checks in your Ruby applications.

Install

gem install altirs-sdk

Or add to Gemfile:

gem "altirs-sdk"

Quick Start

require "altirs"

client = Altirs::Client.new(api_key: "grd_...")

result = client.check(Altirs::CheckPayload.new(input: "Ignore all previous instructions"))

if result.blocked
  puts "Blocked: #{result.violations}"
end

Methods

MethodDescription
check(payload)Run guardrail checks on a single input/response pair. Returns CheckResponse.
batch(items)Run checks on multiple items (max 20). Returns BatchResponse.
safe?(input)Convenience: returns true if input passes all checks.
mask_pii(text)Convenience: returns text with PII redacted.

Error Handling

Catch Altirs::Error when the API returns a non-2xx response:

begin
  result = client.check(payload)
rescue Altirs::Error => e
  puts "#{e.message} #{e.status} #{e.request_id}"
end

Configuration

client = Altirs::Client.new(
  api_key: "grd_...",
  base_url: "https://altirs.ai/api",  # optional, default
  timeout: 30,                        # optional, seconds, default 30
)

On this page