A practical guide to AI in Rails with RubyLLM: structured text, tools, images
I wrote up the code behind the AI-generated cover images on my blog: a text model summarizes a post, an image model draws the summary, and Active Storage keeps the result. AI with Ruby and Rails: A Practical Guide with RubyLLM goes through it in nine steps with RubyLLM 2.1 and Gemini: a service object for the first call, structured output with with_schema, tool calling, RubyLLM.paint, and moving generation to a background job before Kamal’s proxy times out. It also covers rescuing provider errors and catching the content-filtered reply that comes back empty without raising. The last steps treat user content as data rather than instructions and test without touching the network.
Post a comment