Ruby gateway beta quickstart

Ruby developers can use the ruby-openai gem against VerticalAPI by overriding the URI base. Works in Rails, Sinatra, or plain scripts.

From beta docs to a verified test

  1. Read the gateway beta documentation

    Confirm current access, supported providers, compatibility and limits.

  2. Prepare scoped credentials

    Follow your provider's current key-handling guidance and avoid production credentials during evaluation.

  3. Install the Ruby SDK

    gem install ruby-openai

  4. Run the example below

    Use the documented base URL and required headers, then verify the returned shape for this beta path.

  5. Validate the result

    Check response shape, model behavior, limits and total cost against the provider before production.

Ruby — first call

quickstart.rubyRuby
require 'openai'

client = OpenAI::Client.new(
  access_token: 'vapi_...',
  uri_base: 'https://api.verticalapi.com',
  request_timeout: 240,
  extra_headers: { 'X-Provider-Key' => 'sk-...' }
)

response = client.chat(
  parameters: {
    model: 'gpt-4o',
    messages: [{ role: 'user', content: 'Hello, world' }]
  }
)
puts response.dig('choices', 0, 'message', 'content')

Model IDs and provider support can drift. Check the source-dated model directory and current beta documentation before changing the model or provider header.

Common errors and fixes

Faraday::TimeoutError
Increase request_timeout in OpenAI::Client.new. For streaming long responses, use the stream: lambda do |chunk|... pattern with a long timeout.
wrong number of arguments (given 2, expected 1)
ruby-openai changed its signature in v6. Pass parameters: keyword. Upgrade with gem update ruby-openai.
JSON::ParserError on streaming
Streaming returns SSE chunks — each starts with 'data: '. Strip the prefix before JSON.parse. The gem's streaming helper does this automatically — use the official lambda interface.

Where to go from here

Pick a model in the source-dated directory. Compare two in the decision comparisons. Review the benchmark evidence policy before trusting performance claims.