RubyLLM (gateway)
RubyLLM (gateway)
Setup
Set environment variables
No provider key needed. The Respan gateway handles provider authentication.
View your trace
Open the Traces page to see your gateway-routed calls with prompts, tokens, and cost.
Switch models
Use another OpenAI model ID that Respan exposes through the same OpenAI-compatible endpoint.
RubyLLM’s OpenAI-compatible adapter does not provide a provider-neutral way to show Claude or Gemini model switches in this setup. Use the Respan API or OpenAI SDK gateway pages for provider-neutral Claude and Gemini examples.
See the full model list.
Streaming
Responses API (reasoning, tools, and prompts)
RubyLLM’s default OpenAI provider uses the Chat Completions API. OpenAI blocks reasoning together with function tools on that endpoint (Function tools with reasoning_effort are not supported ... use /v1/responses instead). To combine reasoning and tool calls, route through the OpenAI Responses API with the ruby_llm-responses_api provider, pointed at the Respan gateway.
OpenAI reasoning models (gpt-5.x, o-series) only accept temperature = 1 and reject top_p. Set with_temperature(1) on Responses chats that use these models, otherwise RubyLLM’s default temperature is rejected.
Reasoning with tool calls
Define a tool as usual, then combine with_thinking and with_tools. RubyLLM runs the tool loop for you.
Prompt management
Pass a Respan-managed prompt under respan_params with with_params. Do not use a top-level prompt key on the Responses path: the OpenAI Responses API has its own native prompt parameter, so a top-level prompt collides with it and the request fails.
Prompt, tools, and reasoning together
The Responses path forwards the prompt’s stored parameters. When the prompt is used with a reasoning model, drop the stored top_p (which reasoning models reject) with a schema v2 patch.
respan_params also accepts every other gateway field (customer_identifier, metadata, fallback_models, and so on). Prompt evaluation reruns stay on the Chat Completions path, but production traffic sent through the Responses API is still logged and can be evaluated as production data.
Multi-tenancy with contexts
Use RubyLLM contexts to isolate per-tenant configuration.
Rails integration
Set your Respan config in an initializer.
Use acts_as_chat as normal, and all LLM calls will be routed through Respan.