Ruby
Overview
Floopy is a zero-SDK gateway. The ruby-openai gem supports custom base URIs, so you can route all requests through Floopy without any extra dependencies. You get caching, rate limiting, fallbacks, and observability for free.
Installation
gem install ruby-openaiOr add to your Gemfile:
gem "ruby-openai"Configuration
require "openai"
client = OpenAI::Client.new( uri_base: "https://api.floopy.ai/v1", access_token: ENV["FLOOPY_API_KEY"], # starts with fp_)Set FLOOPY_API_KEY in your environment. You can create one in the dashboard.
Basic Request
response = client.chat( parameters: { model: "gpt-4o", messages: [ { role: "user", content: "Explain quantum computing in one sentence." } ], })
puts response.dig("choices", 0, "message", "content")Streaming
client.chat( parameters: { model: "gpt-4o", messages: [ { role: "user", content: "Write a short poem." } ], stream: proc { |chunk, _bytesize| content = chunk.dig("choices", 0, "delta", "content") print content if content }, })Custom Headers
Pass Floopy-specific headers using extra_headers:
client = OpenAI::Client.new( uri_base: "https://api.floopy.ai/v1", access_token: ENV["FLOOPY_API_KEY"], extra_headers: { "Floopy-Cache" => "semantic", "floopy-property-environment" => "production", "floopy-property-feature" => "chat", "floopy-fallback" => "claude-sonnet-4-20250514", })| Header | Description |
|---|---|
Floopy-Cache | Cache strategy: semantic or exact |
floopy-property-* | Attach custom metadata for filtering in the dashboard |
floopy-fallback | Fallback model if the primary provider fails |
floopy-session-id | Group related requests into a session |
floopy-user-id | Associate requests with an end user |
See the Headers Reference for the full list.