Docs / Recipes / Ruby

// LANGUAGE SDK · RUBY

Ruby — OpenAI-compatible base-URL swap

Pattern A · full governance

Use the ruby-openai gem and set uri_base to the gateway. One option changes.

Pattern A — routed through the gateway. Your call travels through Agentics via a base-URL swap, so it is governed (routing, budgets, guardrails) inline and the Proof Ledger writes one verifiable receipt server-side. The receipt hash comes back in the x-agentics-receipt response header.

Install

shell
gem install ruby-openai

Swap the base URL

Point your OpenAI-compatible Ruby client at https://agentics.you/api/v1 with your AGENTICS_API_KEY as the key. That is the only change.

Ruby
require "openai" client = OpenAI::Client.new( access_token: "ak_…", # AGENTICS_API_KEY uri_base: "https://agentics.you/api/v1", # the only change extra_headers: { "x-agentics-user" => "alice@acme.com" }, )

Run one call → see the receipt

No OpenAI-compatible library for your stack? A raw HTTP request works and returns the same header:

cURL
curl https://agentics.you/api/v1/chat/completions -i \ -H "Authorization: Bearer ak_…" \ -H "Content-Type: application/json" \ -H "x-agentics-user: alice@acme.com" \ -d '{"model":"@anthropic/claude-opus-4-8", "messages":[{"role":"user","content":"hi"}]}' # response header: x-agentics-receipt: <receipt_hash>