Project

blazer-ai

0.01
The project is in a healthy, maintained state
A Rails engine that adds AI-powered natural language to SQL generation for the Blazer analytics dashboard. Uses RubyLLM to support multiple AI providers (OpenAI, Anthropic, Gemini, etc.).
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

>= 3.0
>= 7.1
>= 1.0
 Project Readme

Blazer AI

AI-powered SQL generation for Blazer

Gem Version CI

Installation

Add this line to your application's Gemfile:

gem "blazer-ai"

Run:

bundle install
rails generate blazer_ai:install

And set your API key:

export OPENAI_API_KEY=your_key_here

Usage

Visit /blazer/queries/new and click Generate SQL (AI).

Keyboard shortcut: Cmd+Shift+G (Mac) or Ctrl+Shift+G

Configuration

Blazer::Ai.configure do |config|
  config.default_model = "gpt-5.1-codex"
  config.temperature = 0.2
  config.rate_limit_per_minute = 20
end

For other providers, update the initializer:

# Anthropic
RubyLLM.configure do |config|
  config.anthropic_api_key = ENV["ANTHROPIC_API_KEY"]
end

Blazer::Ai.configure do |config|
  config.default_model = "claude-sonnet-4-20250514"
end
# Google
RubyLLM.configure do |config|
  config.gemini_api_key = ENV["GEMINI_API_KEY"]
end

Blazer::Ai.configure do |config|
  config.default_model = "gemini-2.0-flash"
end

API

Invalidate schema cache:

Blazer::Ai::SchemaCache.invalidate(data_source_id: "main")

Validate SQL:

Blazer::Ai::SqlValidator.new.safe?("SELECT * FROM users")

Security

Only SELECT and WITH statements are allowed. Use a read-only database user.

Development

bundle install
bundle exec rake test

License

MIT