ActiveAgent Rails framework for Agent Apps
0
stars
355
commits
Ruby
primary language
Nov 19, 2025
updated
Build AI in Rails
Now Agents are Controllers
Makes code TonsOfFun!
Active Agent provides that missing AI layer in the Rails framework, offering a structured approach to building AI-powered applications through Agent Oriented Programming. Now Agents are Controllers! Designing applications using agents allows developers to create modular, reusable components that can be easily integrated into existing systems. This approach promotes code reusability, maintainability, and scalability, making it easier to build complex AI-driven applications with the Object Oriented Ruby code you already use today.
docs.activeagents.ai - The official documentation site for Active Agent.
Use bundler to add activeagent to your Gemfile and install:
bundle add activeagent
Add the generation provider gem you want to use:
# OpenAI
bundle add openai
# Anthropic
bundle add anthropic
# Ollama (uses OpenAI-compatible API)
bundle add openai
# OpenRouter (uses OpenAI-compatible API)
bundle add openai
Run the install generator to create the necessary configuration files:
rails generate active_agent:install
This creates:
config/active_agent.yml: Configuration file for generation providersapp/agents/application_agent.rb: Base agent classDefine an application agent:
class ApplicationAgent < ActiveAgent::Base
generate_with :openai, model: "gpt-4o-mini"
end
Use your agent:
response = ApplicationAgent.prompt(message: "Hello, world!").generate_now
puts response.message
# => "Hello! How can I help you today?"
Generate a new agent:
rails generate active_agent:agent TravelAgent search book confirm
This creates an agent with actions that can be called:
class TravelAgent < ApplicationAgent
def search
# Your search logic here
prompt
end
def book
# Your booking logic here
prompt
end
def confirm
# Your confirmation logic here
prompt
end
end
Configure generation providers in config/active_agent.yml:
development:
openai:
service: "OpenAI"
access_token: <%= Rails.application.credentials.dig(:openai, :access_token) %>
model: "gpt-4o-mini"
anthropic:
service: "Anthropic"
access_token: <%= Rails.application.credentials.dig(:anthropic, :access_token) %>
model: "claude-sonnet-4.5"
ollama:
service: "Ollama"
model: "llama3.2"
Extract structured data from images, PDFs, and text:
prompt = DataExtractionAgent.with(
image_path: Rails.root.join("sales_chart.png")
).parse_content.generate_now
Translate text between languages:
response = TranslationAgent.with(
message: "Hi, I'm Justin",
locale: "japanese"
).translate.generate_now
Agents can use tools to perform actions:
# Agent with tool support
prompt = SupportAgent.prompt(message: "Show me a cat")
response = prompt.generate_now
# Response includes tool call results
We welcome contributions! Please see our Contributing Guide for details.
Active Agent is released under the MIT License.
Ruby
95.7%
HTML
4.2%
ActiveAgent Rails framework for Agent Apps
0
stars
355
commits
Ruby
primary language
Nov 19, 2025
updated
Build AI in Rails
Now Agents are Controllers
Makes code TonsOfFun!
Active Agent provides that missing AI layer in the Rails framework, offering a structured approach to building AI-powered applications through Agent Oriented Programming. Now Agents are Controllers! Designing applications using agents allows developers to create modular, reusable components that can be easily integrated into existing systems. This approach promotes code reusability, maintainability, and scalability, making it easier to build complex AI-driven applications with the Object Oriented Ruby code you already use today.
docs.activeagents.ai - The official documentation site for Active Agent.
Use bundler to add activeagent to your Gemfile and install:
bundle add activeagent
Add the generation provider gem you want to use:
# OpenAI
bundle add openai
# Anthropic
bundle add anthropic
# Ollama (uses OpenAI-compatible API)
bundle add openai
# OpenRouter (uses OpenAI-compatible API)
bundle add openai
Run the install generator to create the necessary configuration files:
rails generate active_agent:install
This creates:
config/active_agent.yml: Configuration file for generation providersapp/agents/application_agent.rb: Base agent classDefine an application agent:
class ApplicationAgent < ActiveAgent::Base
generate_with :openai, model: "gpt-4o-mini"
end
Use your agent:
response = ApplicationAgent.prompt(message: "Hello, world!").generate_now
puts response.message
# => "Hello! How can I help you today?"
Generate a new agent:
rails generate active_agent:agent TravelAgent search book confirm
This creates an agent with actions that can be called:
class TravelAgent < ApplicationAgent
def search
# Your search logic here
prompt
end
def book
# Your booking logic here
prompt
end
def confirm
# Your confirmation logic here
prompt
end
end
Configure generation providers in config/active_agent.yml:
development:
openai:
service: "OpenAI"
access_token: <%= Rails.application.credentials.dig(:openai, :access_token) %>
model: "gpt-4o-mini"
anthropic:
service: "Anthropic"
access_token: <%= Rails.application.credentials.dig(:anthropic, :access_token) %>
model: "claude-sonnet-4.5"
ollama:
service: "Ollama"
model: "llama3.2"
Extract structured data from images, PDFs, and text:
prompt = DataExtractionAgent.with(
image_path: Rails.root.join("sales_chart.png")
).parse_content.generate_now
Translate text between languages:
response = TranslationAgent.with(
message: "Hi, I'm Justin",
locale: "japanese"
).translate.generate_now
Agents can use tools to perform actions:
# Agent with tool support
prompt = SupportAgent.prompt(message: "Show me a cat")
response = prompt.generate_now
# Response includes tool call results
We welcome contributions! Please see our Contributing Guide for details.
Active Agent is released under the MIT License.
Ruby
95.7%
HTML
4.2%