Major release that makes tool definitions feel like Ruby, lets you lean on Anthropic prompt caching everywhere, and turns audio transcription into a one-liner—plus better Gemini structured output and Nano Banana image responses.
🧰 JSON Schema Tooling That Feels Native
The new RubyLLM::Schemaparams DSL supports full JSON Schema for tool parameter definitions, including nested objects, arrays, enums, and nullable fields.
class Scheduler < RubyLLM::Tool
description "Books a meeting"
params do
object :window, description: "Time window to reserve" do
string :start, description: "ISO8601 start"
string :finish, description: "ISO8601 finish"
end
array :participants, of: :string, description: "Email invitees"
any_of :format, description: "Optional meeting format" do
string enum: %w[virtual in_person]
null
end
end
def execute(window:, participants:, format: nil)
Booking.reserve(window:, participants:, format:)
end
end
Powered by , the same awesome Ruby DSL we recommend to use for Structured Output's .
RubyLLM::Schema
chat.with_schema
Already handles Anthropic/Gemini quirks like nullable unions and enums - no more ad-hoc translation layers.
Prefer raw hashes? Pass params schema: { ... } to keep your existing JSON Schema verbatim.
🧱 Raw Content Blocks & Anthropic Prompt Caching Everywhere
RubyLLM::Content::Raw lets you ship provider-native payloads for content blocks.
Anthropic helpers keep cache_control hints readable while still producing the right JSON structure.
Every RubyLLM::Message now exposes cached_tokens and cache_creation_tokens, so you can see exactly what the provider pulled from cache versus what it had to recreate.
Please run rails generate ruby_llm:upgrade_to_v1_9 in your Rails app if you come from 1.8.x.
⚙️ Tool.with_params Plays Nice with Anthropic Caching
Similarly to Raw Content Blocks, .with_params lets you set arbitrary params in tool definitions. Perfect for Anthropic’s cache_control hints.
class ChangelogTool < RubyLLM::Tool
description "Formats commits into release notes"
params do
array :commits, of: :string
end
with_params cache_control: { type: "ephemeral" }
def execute(commits:)
ReleaseNotes.format(commits)
end
end
🎙️ RubyLLM.transcribe Turns Audio into Text (With Diarization)
One method call gives you transcripts, diarized segments, and consistent token tallies across providers.
transcription = RubyLLM.transcribe(
"all-hands.m4a",
model: "gpt-4o-transcribe-diarize",
language: "en",
prompt: "Focus on action items."
)
transcription.segments.each do |segment|
puts "#{segment['speaker']}: #{segment['text']} (#{segment['start']}s – #{segment['end']}s)"
end
Supports OpenAI (whisper-1, gpt-4o-transcribe, diarization variants), Gemini 2.5 Flash, and Vertex AI with the same API.
Optional speaker references map diarized voices to real names.