← Back to Leaderboard
Oopenai

openai/openai-ruby

Official Ruby SDK for typed OpenAI API calls, streaming, and realtime sessions

View on GitHub ↗
AI FrameworkQuickstart ↓
Engineering Health (Methodology)
A+ · 92/100
Maintenance Activity
● Updated yesterday
Latest Release
v1.5.0
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption17/25
Release Cadence20/20
License Clarity20/20
API
Total Stars
★ 481
24h Growth
+0
7d Growth
+2
Forks
68

GitHub Star History

Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.

openai/openai-ruby Star History (2025-03-12 - 2026-12-03) ALL-TIME STAR HISTORY (2025-03 – 2026-12) +480 in 631d · avg +1/day 508 254 0 2025-03-12: ★ 12025-04-26: ★ 1202025-06-07: ★ 2132025-07-19: ★ 2742025-08-30: ★ 3112025-10-11: ★ 3492025-11-22: ★ 3742026-01-03: ★ 3862026-02-14: ★ 3972026-03-28: ★ 4152026-05-09: ★ 4242026-06-20: ★ 4342026-08-01: ★ 4432026-09-12: ★ 4552026-10-24: ★ 4702026-12-03: ★ 481 ★ 481 2025-03 2026-01 2026-12

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

openai-ruby is an external-API client, not an inference runtime. Ruby applications use OpenAI::Client to submit requests through resource methods such as responses.create. The default OpenAI::NetHTTPClient wraps standard-library Net::HTTP with connection_pool. YARD docstrings, RBS signatures, and RBI definitions serve different parts of the Ruby tooling ecosystem, while generated models represent known server events.

The transport boundary is explicit: an injected http_client implements execute(request) and returns an OpenAI::HTTPClient::Response whose body can be enumerated in byte chunks. The SDK owns authentication, redirects, and API-level retries; the adapter owns deadlines at the transport level, pooling, and connection lifecycle. The SDK does not close injected transports. For persistent sessions, block-scoped responses.connect and realtime.connect expose WebSocket interfaces with the optional async-websocket dependency.

Key Capabilities & Differentiators

Responses supports regular requests, SSE streaming, structured output through OpenAI::BaseModel, and function calls whose execution and result submission are handled by the application. A persistent Responses WebSocket supports sequential and multiplexed turns with stream_id; unrecognized event types remain visible as UnknownServerEvent. Realtime covers server-side text, committed-turn transcription, one-turn voice, and sideband control of WebRTC or SIP calls. WebRTC call creation preserves the SDP answer and the Location header used to attach a sideband connection.

List methods offer automatic or explicit pagination. Uploads can use paths or in-memory values, with OpenAI::FilePart supplying filenames and MIME types for format-sensitive endpoints. Vector-store helpers can upload concurrently and check the 2,000-file batch limit before sending requests. Polling defaults to a 30-minute deadline and falls back to a five-second interval when the API does not recommend one. Beta Agents helpers collect final results, parse typed output, and download hosted artifacts from the exact result turn.

Trade-offs & Limitations

Compared with calling REST through a general-purpose Ruby HTTP client, the SDK reduces integration work around typed responses, pagination, polling, and streaming. Direct HTTP gives a team tighter control over transport behavior if it is willing to maintain those pieces. Compared with a local inference stack, the gem removes model-serving hardware and runtime work from the Ruby host, but introduces a dependency on API availability, network latency, and service pricing. Its Apache-2.0 license covers the SDK, not API entitlements or data-processing terms.

Failure handling still belongs partly to the application. Responses WebSockets require one reader and serialized writes; they do not automatically reconnect or retry an ambiguous write. Raw IO uploads disable retries because the SDK cannot assume they are rewindable. Vector-store batches are not transactional, so an upload failure can leave earlier successful uploads behind. Helpers may return terminal failed or cancelled resources without raising. Hosted file helpers are not a filesystem sandbox, and interrupted downloads may leave partial output.

Hardware & Deployment Guide

Run Ruby 3.3 or later, add gem "openai", "~> 1.4.0" through Bundler, and configure API credentials. OpenAI::Client reads OPENAI_API_KEY by default; Kubernetes deployments can instead configure OpenAI::Auth::WorkloadIdentity with a service-account token provider. Install async-websocket only if using WebSockets. FFmpeg and FFplay are optional for local audio capture and playback, not prerequisites for ordinary API calls.

Deploy this gem inside the application rather than as a standalone model server. It requires network access to the API, not local model weights or a GPU. Size the host for concurrent requests, open streams, file buffers, and connection usage. The v1.3.0 release added spend alerts and response compaction fields; v1.3.1 documented Evals and saved-prompt deprecations; v1.4.0 added health alert rules and notification retrieval. Check those changes against the API features your application uses when upgrading.

Transport: Pooled Net::HTTP by default; injectable execute(request) transport with enumerable response bodies.
Streaming: SSE for Responses and optional async-websocket for persistent Responses and Realtime sessions.
Typing: RBS and RBI support Ruby type tooling; OpenAI::BaseModel defines structured output schemas.
WebSocket lifecycle: Responses supports multiplexed turns, preserves unrecognized event types, and leaves reconnection and replay to callers.
Ingestion: Vector-store helpers support concurrent uploads, check the 2,000-file batch limit before starting, and default to a 30-minute polling deadline.
Hosted artifacts: Beta Agents helpers select artifacts from an exact result turn and stream downloads to a local path or writer.
Best For

Ruby 3.3+ services that call the OpenAI API and need typed responses, streaming, or file ingestion without maintaining a low-level client.

Skip If

You need offline or self-hosted inference, cannot upgrade an older Ruby runtime, or require WebSocket reconnect and replay to be managed by the client.

Reviewed on 2026-12-02 · Grounded in GitHub README, root file tree & releases · Newer release v1.5.0 (2026-12-03) shipped after this reviewMethodology

Quick Start & Installation

API
export OPENAI_CLIENT_CERTIFICATE_CHAIN=/secure/path/client-chain.pem
export OPENAI_CLIENT_KEY=/secure/path/client-key.pem
export IDENTITY_PROVIDER_ID=idp_example
export SERVICE_ACCOUNT_ID=svc_acct_example

ruby examples/x509_workload_identity.rb

Comparison vs. Top LLMs & Inference Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
openai-ruby ★481+2RubyApache-2.0Official Ruby SDK for typed OpenAI API calls, streaming, and realtime sessions
transformers169.6k+337PythonApache-2.0A PyTorch model-definition SDK for unified inference and training across modalit
pytorch105.9k+299Python—Python-first tensor SDK for GPU-accelerated training and inference
qlib50.8k+197PythonMITModular Python framework for quant research, from market data to backtests

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/openai/openai-ruby.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

openai/openai-ruby Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about openai-ruby

How should a Ruby service choose between a regular request, SSE, and a WebSocket?

Create an OpenAI::Client and use responses.create for a complete response or responses.stream for SSE. Use responses.connect with the optional async-websocket gem when you need a persistent connection. Assign one reader per connection, serialize writes, and handle disconnects explicitly: the SDK does not reconnect or replay a write whose delivery is uncertain.

Does the SDK require a GPU, and what determines host resource usage?

No local GPU or model VRAM is required for API inference. The Ruby process handles networking, parsing, and I/O rather than running the model. Size it for concurrent requests, open streams and sockets, and buffered payloads. Prefer path-backed uploads or streaming to an application-owned file when large payloads do not need to be held in memory.

Can we use the gem commercially and deploy it on our own infrastructure?

The Apache-2.0 license permits commercial use and redistribution subject to its conditions, including applicable license and notice requirements. You can deploy the Ruby application on your own infrastructure, but the gem does not provide a self-hosted inference server. API access, billing, and data-handling terms are separate from the SDK license.

When should we call the REST API directly instead of using the gem?

The SDK supplies typed objects, pooling, pagination, polling, and streaming helpers. A direct HTTP client offers finer control over transport behavior and request timing, but your application must maintain the endpoint bindings, response parsing, and failure handling it needs. If transport is the only mismatch, inject an http_client instead: the SDK retains API authentication, redirects, and API-level retries, while your adapter enforces timeouts and manages its own connections.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining openai/openai-ruby? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature openai/openai-ruby on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare