Skip to content
FeedbackDashboard
Codegen targets

Ruby

Generate production-ready Ruby SDKs from your OpenAPI specification

The Stainless Ruby SDK generator creates idiomatic, type-safe Ruby client libraries from your OpenAPI specification. Generated Ruby SDKs include modern type system support (Sorbet, RBS, YARD) and a minimal-dependency design.

Example repositories:

To generate a Ruby SDK, add the ruby target to your Stainless configuration file:

targets:
ruby:
gem_name: my_company_client
edition: ruby.2025-10-08
targets:
ruby:
gem_name: my_company_client
# Specify the edition
edition: ruby.2025-10-08
# Configure publishing
publish:
rubygems: true

For a complete list of configuration options, see the Ruby target reference.

Editions allow Stainless to make improvements to SDKs that aren’t backwards-compatible. You can explicitly opt in to new editions when you’re ready. See the SDK and config editions reference for more information.

ruby.2025-10-08

  • Initial edition for Ruby (used by default if no edition is specified)

Publish your Ruby SDK to RubyGems for distribution.

Get an API token
  1. Log in or sign up at RubyGems.
  2. Select your profile picture on the top right to open a dropdown.
  3. Navigate to Settings.
  4. If you have MFA enabled, set the level to “UI and gem signin”.
  5. Navigate to API keys.
  6. Create a new API key with the “Push rubygems” privilege. If you have MFA enabled, make sure “Enable MFA” is unchecked.
Add the token to your production repo
  1. In your production repo, navigate to Secrets and variables > Actions > New repository secret. The URL should look like https://github.com/<org>/<repo>/settings/secrets/actions/new.
  2. Add a new secret named GEM_HOST_API_KEY with your API token.
Choose a package name and update your Stainless config
  1. Choose an available package name. Suggested names are:

    • <company-name>
    • <company-name>-client

    You can check whether the name is available by testing the link at https://rubygems.org/gems/<package-name>.

  2. Update the Stainless config with your package name and save.

    targets:
    ruby:
    gem_name: <package-name>
    publish:
    rubygems: true