benchgecko 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +90 -0
  4. data/lib/benchgecko.rb +112 -0
  5. metadata +63 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0a234487525e3495d4061bebe4ef9446f0b5db27f9c952eb798cf7c5c525573f
4
+ data.tar.gz: ee6cdb2b960c014282923d347df5f5f4093f2300a2c174c5df3543daccbe5804
5
+ SHA512:
6
+ metadata.gz: 6402dc222eb5ccd77ac562984b9bfe7d0dc9bc684177284c864e8443e0c48a5af53bf064f68576338925e6980dc451a8ea85fe0564528ff0e20cd5054b78b1dd
7
+ data.tar.gz: adff9d430fb5b7de9a48d2fc8185d44730284caa1238e9b107301de7a85a9bc1b52fad51b0926bbf84a35ee7a23395c988d1bc7f222e2c860906489cd177e820
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 BenchGecko
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # BenchGecko Ruby SDK
2
+
3
+ Official Ruby client for the [BenchGecko](https://benchgecko.ai) API. Query AI model data, benchmark scores, and run side-by-side comparisons from Ruby applications.
4
+
5
+ BenchGecko tracks every major AI model, benchmark, and provider. This gem wraps the public REST API with idiomatic Ruby patterns, zero external dependencies beyond the standard library, and clean error handling.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ gem install benchgecko
11
+ ```
12
+
13
+ Or add to your Gemfile:
14
+
15
+ ```ruby
16
+ gem "benchgecko"
17
+ ```
18
+
19
+ Requires Ruby 2.7 or later.
20
+
21
+ ## Quick Start
22
+
23
+ ```ruby
24
+ require "benchgecko"
25
+
26
+ client = BenchGecko::Client.new
27
+
28
+ # List all tracked AI models
29
+ models = client.models
30
+ puts "Tracking #{models.length} models"
31
+
32
+ # List all benchmarks
33
+ benchmarks = client.benchmarks
34
+ benchmarks.first(5).each { |b| puts b["name"] }
35
+
36
+ # Compare two models head-to-head
37
+ result = client.compare(["gpt-4o", "claude-opus-4"])
38
+ result["models"].each do |m|
39
+ puts "#{m['name']}: #{m['scores']}"
40
+ end
41
+ ```
42
+
43
+ ## API Reference
44
+
45
+ ### `BenchGecko::Client.new(base_url:, timeout:)`
46
+
47
+ Create a new client instance.
48
+
49
+ | Parameter | Type | Default | Description |
50
+ |-----------|------|---------|-------------|
51
+ | `base_url` | String | `https://benchgecko.ai` | API base URL |
52
+ | `timeout` | Integer | `30` | HTTP timeout in seconds |
53
+
54
+ ### `client.models`
55
+
56
+ Fetch all AI models tracked by BenchGecko. Returns an array of hashes, each containing model metadata like name, provider, parameter count, pricing, and benchmark scores.
57
+
58
+ ### `client.benchmarks`
59
+
60
+ Fetch all benchmarks tracked by BenchGecko. Returns an array of hashes with benchmark name, category, and description.
61
+
62
+ ### `client.compare(model_slugs)`
63
+
64
+ Compare two or more models side by side. Pass an array of model slugs (minimum 2). Returns a hash with per-model scores, pricing, and capability breakdowns.
65
+
66
+ ## Error Handling
67
+
68
+ API errors raise `BenchGecko::Error` with a message and optional HTTP status code:
69
+
70
+ ```ruby
71
+ begin
72
+ models = client.models
73
+ rescue BenchGecko::Error => e
74
+ puts "API error (#{e.status_code}): #{e.message}"
75
+ end
76
+ ```
77
+
78
+ ## Data Attribution
79
+
80
+ Data provided by [BenchGecko](https://benchgecko.ai). Model benchmark scores are sourced from official evaluation suites. Pricing data is updated daily from provider APIs.
81
+
82
+ ## Links
83
+
84
+ - [BenchGecko](https://benchgecko.ai) - AI model benchmarks, pricing, and rankings
85
+ - [API Documentation](https://benchgecko.ai/api-docs)
86
+ - [GitHub Repository](https://github.com/BenchGecko/benchgecko-ruby)
87
+
88
+ ## License
89
+
90
+ MIT
data/lib/benchgecko.rb ADDED
@@ -0,0 +1,112 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "net/http"
4
+ require "uri"
5
+ require "json"
6
+
7
+ # BenchGecko - Official Ruby SDK for the BenchGecko API.
8
+ #
9
+ # Query AI model data, benchmark scores, and run side-by-side
10
+ # model comparisons programmatically.
11
+ #
12
+ # @example Basic usage
13
+ # client = BenchGecko::Client.new
14
+ # models = client.models
15
+ # puts "Tracking #{models.length} models"
16
+ #
17
+ module BenchGecko
18
+ VERSION = "0.1.0"
19
+ DEFAULT_BASE_URL = "https://benchgecko.ai"
20
+
21
+ # Error raised when the BenchGecko API returns a non-success response.
22
+ class Error < StandardError
23
+ # @return [Integer, nil] HTTP status code.
24
+ attr_reader :status_code
25
+
26
+ def initialize(message, status_code: nil)
27
+ @status_code = status_code
28
+ super(message)
29
+ end
30
+ end
31
+
32
+ # Client for the BenchGecko API.
33
+ #
34
+ # Provides methods to query AI models, benchmarks, and perform
35
+ # side-by-side model comparisons.
36
+ class Client
37
+ # Create a new BenchGecko client.
38
+ #
39
+ # @param base_url [String] API base URL.
40
+ # @param timeout [Integer] HTTP timeout in seconds.
41
+ def initialize(base_url: DEFAULT_BASE_URL, timeout: 30)
42
+ @base_url = base_url.chomp("/")
43
+ @timeout = timeout
44
+ end
45
+
46
+ # List all AI models tracked by BenchGecko.
47
+ #
48
+ # @return [Array<Hash>] Array of model hashes with metadata,
49
+ # benchmark scores, and pricing information.
50
+ #
51
+ # @example
52
+ # models = client.models
53
+ # models.each { |m| puts m["name"] }
54
+ def models
55
+ request("/api/v1/models")
56
+ end
57
+
58
+ # List all benchmarks tracked by BenchGecko.
59
+ #
60
+ # @return [Array<Hash>] Array of benchmark hashes with name,
61
+ # category, and description.
62
+ #
63
+ # @example
64
+ # benchmarks = client.benchmarks
65
+ # benchmarks.each { |b| puts b["name"] }
66
+ def benchmarks
67
+ request("/api/v1/benchmarks")
68
+ end
69
+
70
+ # Compare two or more AI models side by side.
71
+ #
72
+ # @param model_slugs [Array<String>] Model slugs to compare (minimum 2).
73
+ # @return [Hash] Comparison result with per-model data.
74
+ # @raise [ArgumentError] if fewer than 2 models provided.
75
+ #
76
+ # @example
77
+ # result = client.compare(["gpt-4o", "claude-opus-4"])
78
+ # result["models"].each { |m| puts "#{m['name']}: #{m['scores']}" }
79
+ def compare(model_slugs)
80
+ raise ArgumentError, "At least 2 models are required" if model_slugs.length < 2
81
+
82
+ request("/api/v1/compare", models: model_slugs.join(","))
83
+ end
84
+
85
+ private
86
+
87
+ def request(path, params = {})
88
+ uri = URI("#{@base_url}#{path}")
89
+ uri.query = URI.encode_www_form(params) unless params.empty?
90
+
91
+ http = Net::HTTP.new(uri.host, uri.port)
92
+ http.use_ssl = uri.scheme == "https"
93
+ http.open_timeout = @timeout
94
+ http.read_timeout = @timeout
95
+
96
+ req = Net::HTTP::Get.new(uri)
97
+ req["User-Agent"] = "benchgecko-ruby/#{VERSION}"
98
+ req["Accept"] = "application/json"
99
+
100
+ response = http.request(req)
101
+
102
+ unless response.is_a?(Net::HTTPSuccess)
103
+ raise Error.new(
104
+ "API request failed (#{response.code}): #{response.body}",
105
+ status_code: response.code.to_i
106
+ )
107
+ end
108
+
109
+ JSON.parse(response.body)
110
+ end
111
+ end
112
+ end
metadata ADDED
@@ -0,0 +1,63 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: benchgecko
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - BenchGecko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-31 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ description: Query AI model data, benchmark scores, and run side-by-side comparisons.
28
+ BenchGecko tracks every major AI model, benchmark, and provider.
29
+ email: hello@benchgecko.ai
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - LICENSE
35
+ - README.md
36
+ - lib/benchgecko.rb
37
+ homepage: https://benchgecko.ai
38
+ licenses:
39
+ - MIT
40
+ metadata:
41
+ source_code_uri: https://github.com/BenchGecko/benchgecko-ruby
42
+ bug_tracker_uri: https://github.com/BenchGecko/benchgecko-ruby/issues
43
+ documentation_uri: https://benchgecko.ai/api-docs
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 2.7.0
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubygems_version: 3.0.3.1
60
+ signing_key:
61
+ specification_version: 4
62
+ summary: Official Ruby SDK for the BenchGecko API
63
+ test_files: []