📈 GH Trending Explorer 🎲 Surprise me

← all repos

openai / openai-ruby

git clone https://github.com/openai/openai-ruby.git v0.107.0 · today 🔥 on GitHub Trending today

Official Ruby SDK for the OpenAI API

—
stars, 24h
+1
stars, 7 days · #1,642
+10
stars, 30 days · #10,005
468
★ total · +0% this week
67
forks · 0 open issues

Star history starts 2026-10-20; the chart appears after the second daily snapshot.

LanguageRuby
LicenseApache-2.0
Created2025-03-05 (1y ago)
Last pushtoday
Watchers10
OwnerOrganization

Seen on GitHub Trending

  • 2026-10-20 — #21 monthly in ruby · +10 ★
  • 2026-10-20 — #6 weekly in ruby · +1 ★

Links

README excerpt
# OpenAI Ruby API library
The OpenAI Ruby library provides convenient access to the OpenAI REST API from any Ruby 3.3.0+ application. It ships with comprehensive types & docstrings in Yard, RBS, and RBI – see below for usage with Sorbet. The standard library's `net/http` is used as the HTTP transport, with connection pooling via the `connection_pool` gem.
## Documentation
Documentation for releases of this gem can be found on RubyDoc.
The REST API documentation can be found on platform.openai.com.
## Installation
To use this gem, install via Bundler by adding the following to your application's `Gemfile`:
 [code] 
## Usage
 [code] 
### Streaming
We provide support for streaming responses using Server-Sent Events (SSE).
 [code] 
### Agents final output (beta)
Collect final output from an Agents creation stream:
 [code] 
Use the same getter for follow-ups; to display progress first, call
`stream.with_result_collection` before iterating:
 [code] 
The beta result includes `turn` metadata and final `messages`; unsuccessful or
incomplete collection raises `OpenAI::Helpers::Beta::Agents::ResultError`.
### Typed Agents output (beta)
Use an `OpenAI::BaseModel` with `output_type` to configure and parse a structured answer:
 [code] 
`prepare_directory(directory, destination:, include:)` stages an explicitly selected snapshot. Local path and directory helpers assume stable, application-owned source paths; they are not a filesystem sandbox for arbitrary user-supplied paths or hostile local writers. Downloads select the exact result turn and stream to an application-owned local path or the writer you supply. An interrupted transfer may leave partial contents.
### Local audio
Record a clip and play generated speech with optional FFmpeg/FFplay helpers.
See the local audio guide for setup, device selection and examples.
### Realtime WebSockets
The SDK supports block-scoped, typed Realtime WebSocket sessions for
server-side text, committed-turn transcription, one-turn voice, WebRTC call
creation, and sideband control of existing WebRTC or SIP calls. Add the
optional `async-websocket` gem for WebSocket connections, then use
`client.realtime.connect`:
 [code] 
WebRTC calls can be created with `client.realtime.calls.create`; its HTTP
response preserves the SDP answer and the `Location` header needed to attach a
sideband connection. See the Realtime WebSocket guide and the runnable
text, transcription, voice, and sideband examples
for lifecycle, authentication, proxy, TLS, and custom transport details.
### Responses WebSockets
The Responses API also supports a persistent, block-scoped WebSocket for
sequential and multiplexed response creation. Add the optional
`async-websocket` gem, then send `response.create` events through
`client.responses.connect`:
 [code] 
The connection is intentionally single-owner: callers serialize writes and
use one reader (`receive` or `each`). The SDK forwards response fields and
`stream_id` values without imposing additional client-side p