Back to projects

AI infrastructure gem

Rails AI Gateway

Mount one OpenAI-compatible endpoint inside Rails with ordered model fallbacks, encrypted provider keys, streaming, and built-in usage tracking.

Outcome

Provides chat completions, embeddings, model routes, and usage tracking inside the host Rails application.

My role

Open-Source Developer

How I helped

  • Built and published the open-source project.

Product

The workflow in context

Generated product visualization, not a live screenshot.

Generated visualization of Rails AI Gateway showing model routes, fallbacks, and token metrics.
Generated product visualization

The solution

Mount one OpenAI-compatible endpoint inside Rails with ordered model fallbacks, encrypted provider keys, streaming, and built-in usage tracking.

What changed

Provides chat completions, embeddings, model routes, and usage tracking inside the host Rails application.

Source

Explore repository.

AI system implementation

The gem is an OpenAI-compatible routing layer, not a model. Rails mounts chat completion, embedding, and model-list endpoints; ordered routes choose provider fallbacks. SSE forwards streaming responses. ActiveRecord encryption protects provider keys and metadata records status, latency, attempts, and reported token usage without storing prompts or responses. Native provider APIs and semantic caching are outside the documented scope.

Could a similar approach help your business?

Tell me where work gets stuck. We can identify a practical first improvement and what success should look like.

Discuss your challenge