0394GitHub
ruby_decision_model
Ruby client with standard-library transport for TypeSafe and OpenRouter decision endpoints.
obie/ruby_decision_modelREADME ↗
# ruby_decision_model
The decision-model interface for Ruby. Decision models answer typed questions
about a state with calibrated probabilities instead of generating text. This gem
talks to them through one `Client` with a provider behind it: OpenRouter by
default, Typesafe's native API as a second door, more providers as labs ship
them. No runtime dependencies beyond the standard library.
## Install
```ruby
gem "ruby_decision_model"
```
## Quick start
```ruby
require "ruby_decision_model"
client = RubyDecisionModel::Client.new
response = client.ask(
state: { title: "Server returns 500 on checkout", reporter: "support" },
questions: {
"urgent" => RubyDecisionModel::Questions.noul("Is this urgent?"),
"severity" => RubyDecisionModel::Questions.score(
"How severe is this issue?",
criteria: ["cosmetic", "minor", "major", "critical"]
)
}
)
response["urgent"].noul # => 0.87
response["severity"].score # => 2.4
response.usage.input_tokens # => 120
```
`Client.new` with no arguments reads the environment: `TYPESAFE_API_KEY` selects
Typesafe, otherwise `OPENROUTER_API_KEY` selects OpenRouter. With neither set it
raises `ConfigurationError` naming both. `RubyDecisionModel.client` memoizes one
such default client; assign `nil` to reset it.
## Providers
### OpenRouter (default)
```ruby
# ENV["OPENROUTER_API_KEY"]
client = RubyDecisionModel::Client.new(provider: :open_router)
# or pass the key directly; api_key: alone still means OpenRouter
client = RubyDecisionModel::Client.new(api_key: "sk-or-...")
```
Requests go to `https://openrouter.ai/api/alpha/decisions`. The default model is
`typesafe/jev-1.13`. Usage reports `input_tokens`, `output_tokens`, and `cost`.
### Typesafe native API
```ruby
# ENV["TYPESAFE_API_KEY"]
client =