FlareStart
HomeNewsHow ToSources
FlareStart

Where developers start their day. All the tech news & tutorials that matter, in one place.

Quick Links

  • Home
  • News
  • Tutorials
  • Sources
  • Privacy Policy

Connect

© 2026 FlareStart. All rights reserved.

Back to articles
Rails + OpenAI API — Build a Streaming Chat Interface with Turbo
How-ToWeb Development

Rails + OpenAI API — Build a Streaming Chat Interface with Turbo

via Dev.toAgentQ2h ago

You've got Rails down. You've got Hotwire, Stimulus, and background jobs wired up. Now let's wire in actual AI. This post builds a working chat interface that streams OpenAI responses in real-time using Turbo Streams. No JavaScript frameworks. No React. Just Rails doing what Rails does best. What We're Building A simple chat UI where users type messages and get AI responses streamed word-by-word. The kind of thing you'd see in ChatGPT, but built with Rails in under 100 lines of code. Setup Add the OpenAI gem: gem 'ruby-openai' bundle install Set your API key: export OPENAI_API_KEY = sk-... Or use Rails credentials: bin/rails credentials:edit Add to the file: openai : api_key : sk-... The Chat Model We need to store messages. Keep it simple: bin/rails g model Chat message:text response:text db:migrate The Controller Here's where the magic happens. We're using ruby-openai with streaming enabled, and piping each chunk through Turbo Streams: class ChatsController < ApplicationController de

Continue reading on Dev.to

Opens in a new tab

Read Full Article
0 views

Related Articles

Web Color "Wheel" Chart
How-To

Web Color "Wheel" Chart

Dev.to • 3h ago

Im looking for indie apps and tools built by solo developers, their stories and perspectives for a newsletter I’m starting. If you know a solo maker or use an overlooked gem built by one please let me know! 🙏
How-To

Im looking for indie apps and tools built by solo developers, their stories and perspectives for a newsletter I’m starting. If you know a solo maker or use an overlooked gem built by one please let me know! 🙏

Dev.to • 15h ago

Building a DIY OpenClaw
How-To

Building a DIY OpenClaw

Lobsters • 17h ago

go-typedpipe: A Typed, Context-Aware Pipe for Go
How-To

go-typedpipe: A Typed, Context-Aware Pipe for Go

Dev.to • 1d ago

What I've Learned Scaling Engineering Organisations
How-To

What I've Learned Scaling Engineering Organisations

Dev.to • 1d ago

Discover More Articles