module RubyLLM::ActiveRecord::BatchMethods

Methods added to a batch model by acts_as_batch. A persisted batch mirrors RubyLLM::Batch: it stores the providerโ€™s batch id and the chats it is processing, so a later process can poll it and the answers land back in those conversations.

Creating the record submits the staged chats to the provider in the same step:

chats = tickets.map do |ticket|
  Chat.create!(model: "claude-haiku-4-5").ask_later(ticket.body)
end

batch = Batch.create!(chats: chats)
BatchPollJob.perform_later(batch.id)