Repolode
OlympiaAI

OlympiaAI/raix

A Ruby library for adding discrete LLM components to Ruby apps, with chat completions, tool calling, prompt chains and structured output.

Stars
329
Forks
30
Open issues
11
Last commit
2 months ago

What is it?

Raix is a Ruby gem for adding large language model features to ordinary Ruby classes. You mix in modules such as ChatCompletion to get a transcript and chat_completion method, then call models from OpenAI, Anthropic, Google Gemini and other providers through OpenRouter. The library is built on RubyLLM for provider connections and works in non-Rails apps as long as ActiveSupport is available.

Beyond basic completions, Raix supports automatic tool (function) calling with a declarative function DSL, where tool results are fed back to the model until it returns a text reply. It also offers a PromptDeclarations module for running ordered prompt chains, a Predicate module for yes/no/maybe questions, experimental MCP client support for remote tool servers, and a ResponseFormat class for JSON schema outputs. Hooks let you adjust requests before they are sent, for example to choose models per tenant or redact personal data.

The code was extracted from Olympia, a virtual AI team platform, and the author documents the design approach in a related book on application patterns using AI.

Key features

  • 01Chat completions with a transcript that accepts abbreviated or OpenAI-style message hashes.
  • 02Automatic tool function calling with a declarative DSL and a configurable call limit.
  • 03Prompt chains via PromptDeclarations, with conditions, callbacks and looping.
  • 04JSON mode and JSON Schema response formats for structured output.
  • 05Anthropic-style prompt caching and before_completion hooks for request modification.

Use cases

  • Adding an AI summarization or classification step to a Rails model or service object.
  • Building a multi-step pipeline where each LLM call feeds the next prompt.
  • Letting an LLM call your application's Ruby methods to fetch data or trigger workflows.
  • Connecting a Ruby app to remote MCP tool servers for experimentation.

Quick start

  1. 1

    Add the gem to your Gemfile

    bundle add raix
  2. 2

    Include Raix::ChatCompletion in a Ruby class and call chat_completion

Things to know

  • Raix 3.0 relies on RubyLLM and OpenRouter, so you need API keys from a provider such as OpenAI or Anthropic.
  • Non-Rails applications must include ActiveSupport as a dependency.

In collections

Topics

FAQ

What is raix?
A Ruby library for adding discrete LLM components to Ruby apps, with chat completions, tool calling, prompt chains and structured output. Raix is a Ruby gem for adding large language model features to ordinary Ruby classes. You mix in modules such as ChatCompletion to get a transcript and chat_completion method, then call models from OpenAI, Anthropic, Google Gemini and other providers through OpenRouter. The library is built on RubyLLM for provider connections and works in non-Rails apps as long as ActiveSupport is available.
Is raix free to use? What license does it have?
raix is open source under the MIT license. Check the license terms before using it in commercial products.
Is raix still maintained?
Updated within 6 months. The last commit to raix was on Sep 22, 2026.
What can I use raix for?
Adding an AI summarization or classification step to a Rails model or service object. Building a multi-step pipeline where each LLM call feeds the next prompt. Letting an LLM call your application's Ruby methods to fetch data or trigger workflows. Connecting a Ruby app to remote MCP tool servers for experimentation.
How do I install raix?
Add the gem to your Gemfile: bundle add raix Include Raix::ChatCompletion in a Ruby class and call chat_completion
Where can I get raix?
The source code and installation instructions are on GitHub: https://github.com/OlympiaAI/raix

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects