Integration guide

How to use Ruby on Rails with an OpenAI-compatible endpoint (Ruby)

Ruby on Rails integration guide for Ruby. Connect to an OpenAI-compatible endpoint with a base URL swap and keep the same request schema.

Updated 2026-01-06

Ruby on Rails works with OpenAI-compatible APIs by switching the base URL and API key.

This guide shows a Ruby example plus a test vector you can run to validate responses.

require "net/http"
require "json"

uri = URI("https://api.abliteration.ai/v1/chat/completions")
payload = {
  model: "abliterated-model",
  messages: [{ role: "user", content: "Respond with: Ruby on Rails Ruby ready." }],
  temperature: 0.2,
}

request = Net::HTTP::Post.new(uri)
request["Authorization"] = "Bearer #{ENV['ABLIT_KEY']}"
request["Content-Type"] = "application/json"
request.body = payload.to_json

response = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) { |http| http.request(request) }
puts response.body

Configure Ruby on Rails

Follow this checklist to point your integration at the OpenAI-compatible endpoint.

OpenAI-compatible payload

Use this request body as a known-good payload before customizing parameters.

{
  "model": "abliterated-model",
  "messages": [
    { "role": "user", "content": "Respond with: Ruby on Rails Ruby ready." }
  ],
  "temperature": 0.2
}

Streaming and tool calling readiness

If you stream responses or send tool definitions, keep the OpenAI-compatible schema and validate against the OpenAPI spec.