# OpenAI Ruby SDK

> Official Ruby SDK for the OpenAI API

Source: https://talira.ai/catalog/openai-ruby-sdk-8bnqs7b1
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library
- Categories: [ai / llm / client libraries](https://talira.ai/categories/ai/llm/client-libraries), [languages / ruby](https://talira.ai/categories/languages/ruby)
- Licence: Apache-2.0[^3][^4]
- Pricing: Free and open source[^3]
- Free tier: yes[^3]
- Self-hostable: yes[^1]
- Backed by: [OpenAI](https://talira.ai/orgs/openai.md)

The OpenAI Ruby SDK is OpenAI's official Ruby library for the [OpenAI API](https://talira.ai/catalog/openai-api-t57ph5ck.md), published as the `openai` gem (OpenAI took over the gem name in 2025; versions 0.3.0 and older are an unrelated earlier client). It covers the Responses and Chat Completions APIs with Server-Sent Events streaming, structured outputs and function calling from `OpenAI::BaseModel` classes whose results come back parsed into Ruby objects, a chat completions tool runner, Realtime and Responses WebSockets, files, pagination and webhook verification. It ships Yard, RBS and RBI types for [Sorbet](https://talira.ai/catalog/sorbet-7qt3f670.md), retries and timeouts, uses net/http with connection pooling, and can reach OpenAI models through Azure OpenAI, [Amazon Bedrock](https://talira.ai/catalog/amazon-bedrock-b6xkh16b.md) and Google Vertex AI. It's generated from the API spec and released often, still under 0.x version numbers.

## Links

- GitHub: https://github.com/openai/openai-ruby

## Problems it solves

- send prompts to GPT from a background job in Ruby
- stream chat completion tokens to the browser from a Ruby backend
- get JSON back from the model that matches a Ruby class and parse it into objects
- let the model call my Ruby methods as tools and loop until it answers
- verify that a webhook really came from OpenAI in my Rails controller
- type-check my OpenAI calls in Ruby with Sorbet or RBS
- use OpenAI models through Azure or Amazon Bedrock from Ruby with the same client
- a Ruby client for OpenAI's realtime voice API over WebSockets
- upload files and wait for vector store ingestion from a Ruby script
- which Ruby gem is OpenAI's own and not a community wrapper

## Features

- Responses API and Chat Completions
- SSE streaming (responses.stream, chat.completions.stream)
- structured outputs and function calling with OpenAI::BaseModel, ArrayOf, EnumOf and UnionOf, parsed results
- structured-output models from Sorbet T::Struct classes
- automatic chat completions tool runner
- Realtime WebSocket sessions and WebRTC calls; Responses WebSockets
- auto-paginating list methods
- file uploads and vector store ingestion polling
- webhook unwrap and signature verification
- configurable retries and timeouts, request IDs and request logging
- Yard, RBS and RBI type definitions
- providers for Azure OpenAI, Amazon Bedrock and Google Vertex AI; workload identity authentication
- fiber scheduler support and custom HTTP clients
- beta Agents sessions with typed final output

## Limitations

- Doesn't run on Ruby versions before 3.3[^1][^2]
- Doesn't stream structured outputs built from Sorbet models: that integration supports non-streaming requests only[^1]

## Trust

Overall: 0.27 out of 1.
Signals: backing 0.30, extensibility 0.00.

- backed by OpenAI

Warnings:

- GitHub activity not fetched yet

## Related

- Works with [OpenAI API](https://talira.ai/catalog/openai-api-t57ph5ck.md)

## Alternatives

- [RubyLLM](https://talira.ai/catalog/rubyllm-2fxp4hmn.md): The Ruby AI framework
- [ruby-openai](https://talira.ai/catalog/ruby-openai-3ac0fca8.md): Use the OpenAI API with Ruby

## Sources

[^1]: https://github.com/openai/openai-ruby (checked 20 Nov 2026)
[^2]: https://github.com/openai/openai-ruby/blob/main/VERSIONING.md (checked 20 Nov 2026)
[^3]: https://github.com/openai/openai-ruby/blob/main/LICENSE (checked 20 Nov 2026)
[^4]: https://rubygems.org/gems/openai (checked 20 Nov 2026)
