In Elixir land we have Instructor. It hits AI endpoints cleanly, and then validates the returned JSON using Ecto Changesets. Very powerful, clean abstraction. Love it!
https://hexdocs.pm/instructor/Instructor.html
Someone in Rails land could build similar and voila.