benchgecko 1.0.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.
package/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.
package/README.md ADDED
@@ -0,0 +1,99 @@
1
+ # BenchGecko JavaScript SDK
2
+
3
+ Official JavaScript/TypeScript client for the [BenchGecko](https://benchgecko.ai) API. Query AI model data, benchmark scores, and run side-by-side comparisons from Node.js or any JavaScript runtime.
4
+
5
+ BenchGecko tracks every major AI model, benchmark, and provider. This SDK wraps the public REST API so you can integrate AI model intelligence into your applications, dashboards, and developer tools.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install benchgecko
11
+ ```
12
+
13
+ Works with Node.js 14+ and any runtime that supports the Fetch API.
14
+
15
+ ## Quick Start
16
+
17
+ ```javascript
18
+ const { BenchGecko } = require('benchgecko');
19
+
20
+ const client = new BenchGecko();
21
+
22
+ // List all tracked AI models
23
+ const models = await client.models();
24
+ console.log(`Tracking ${models.length} models`);
25
+
26
+ // List all benchmarks
27
+ const benchmarks = await client.benchmarks();
28
+ benchmarks.forEach(b => console.log(b.name));
29
+
30
+ // Compare two models head-to-head
31
+ const comparison = await client.compare(['gpt-4o', 'claude-opus-4']);
32
+ comparison.models.forEach(m => {
33
+ console.log(m.name, m.scores);
34
+ });
35
+ ```
36
+
37
+ ## TypeScript Support
38
+
39
+ Full TypeScript definitions are included out of the box:
40
+
41
+ ```typescript
42
+ import { BenchGecko, Model, Benchmark, ComparisonResult } from 'benchgecko';
43
+
44
+ const client = new BenchGecko();
45
+ const models: Model[] = await client.models();
46
+ const result: ComparisonResult = await client.compare(['gpt-4o', 'claude-opus-4']);
47
+ ```
48
+
49
+ ## API Reference
50
+
51
+ ### `new BenchGecko(options?)`
52
+
53
+ Create a client instance.
54
+
55
+ | Option | Type | Default | Description |
56
+ |--------|------|---------|-------------|
57
+ | `baseUrl` | string | `https://benchgecko.ai` | API base URL |
58
+ | `timeout` | number | `30000` | Request timeout in ms |
59
+
60
+ ### `client.models()`
61
+
62
+ Fetch all AI models tracked by BenchGecko. Returns an array of model objects containing name, provider, parameter count, pricing tiers, and benchmark scores.
63
+
64
+ ### `client.benchmarks()`
65
+
66
+ Fetch all benchmarks tracked by BenchGecko. Returns an array of benchmark objects with name, category, and description.
67
+
68
+ ### `client.compare(models)`
69
+
70
+ Compare two or more models side by side. Pass an array of model slugs. Returns a structured comparison with per-model scores, pricing, and capability breakdowns.
71
+
72
+ ## Error Handling
73
+
74
+ ```javascript
75
+ const { BenchGecko, BenchGeckoError } = require('benchgecko');
76
+
77
+ const client = new BenchGecko();
78
+ try {
79
+ const models = await client.models();
80
+ } catch (error) {
81
+ if (error instanceof BenchGeckoError) {
82
+ console.error(`API error: ${error.message} (status: ${error.statusCode})`);
83
+ }
84
+ }
85
+ ```
86
+
87
+ ## Data Attribution
88
+
89
+ Data provided by [BenchGecko](https://benchgecko.ai). Benchmark scores sourced from official evaluation suites. Pricing data updated daily from provider APIs.
90
+
91
+ ## Links
92
+
93
+ - [BenchGecko](https://benchgecko.ai) - AI model benchmarks, pricing, and rankings
94
+ - [API Documentation](https://benchgecko.ai/api-docs)
95
+ - [GitHub Repository](https://github.com/BenchGecko/benchgecko-js)
96
+
97
+ ## License
98
+
99
+ MIT
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "benchgecko",
3
+ "version": "1.0.0",
4
+ "description": "Official JavaScript/TypeScript SDK for the BenchGecko API. Compare AI models, benchmarks, and pricing.",
5
+ "main": "src/index.js",
6
+ "types": "src/index.d.ts",
7
+ "files": [
8
+ "src/",
9
+ "README.md",
10
+ "LICENSE"
11
+ ],
12
+ "keywords": [
13
+ "ai",
14
+ "benchmarks",
15
+ "llm",
16
+ "models",
17
+ "pricing",
18
+ "machine-learning",
19
+ "gpt",
20
+ "claude",
21
+ "gemini",
22
+ "api-client"
23
+ ],
24
+ "author": "BenchGecko <hello@benchgecko.ai>",
25
+ "license": "MIT",
26
+ "homepage": "https://benchgecko.ai",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "https://github.com/BenchGecko/benchgecko-js"
30
+ },
31
+ "bugs": {
32
+ "url": "https://github.com/BenchGecko/benchgecko-js/issues"
33
+ },
34
+ "engines": {
35
+ "node": ">=14.0.0"
36
+ }
37
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * BenchGecko - Official TypeScript SDK for the BenchGecko API.
3
+ */
4
+
5
+ export interface BenchGeckoOptions {
6
+ /** API base URL. Defaults to https://benchgecko.ai */
7
+ baseUrl?: string;
8
+ /** Request timeout in milliseconds. Defaults to 30000. */
9
+ timeout?: number;
10
+ }
11
+
12
+ export interface Model {
13
+ id: string;
14
+ name: string;
15
+ slug: string;
16
+ provider: string;
17
+ parameters?: number;
18
+ context_window?: number;
19
+ pricing?: {
20
+ input_per_million?: number;
21
+ output_per_million?: number;
22
+ };
23
+ scores?: Record<string, number>;
24
+ [key: string]: unknown;
25
+ }
26
+
27
+ export interface Benchmark {
28
+ id: string;
29
+ name: string;
30
+ slug: string;
31
+ category: string;
32
+ description?: string;
33
+ [key: string]: unknown;
34
+ }
35
+
36
+ export interface ComparisonResult {
37
+ models: Array<{
38
+ name: string;
39
+ slug: string;
40
+ provider: string;
41
+ scores: Record<string, number>;
42
+ pricing?: {
43
+ input_per_million?: number;
44
+ output_per_million?: number;
45
+ };
46
+ [key: string]: unknown;
47
+ }>;
48
+ [key: string]: unknown;
49
+ }
50
+
51
+ export class BenchGeckoError extends Error {
52
+ statusCode: number | null;
53
+ constructor(message: string, statusCode?: number);
54
+ }
55
+
56
+ export class BenchGecko {
57
+ constructor(options?: BenchGeckoOptions);
58
+
59
+ /** List all AI models tracked by BenchGecko. */
60
+ models(): Promise<Model[]>;
61
+
62
+ /** List all benchmarks tracked by BenchGecko. */
63
+ benchmarks(): Promise<Benchmark[]>;
64
+
65
+ /** Compare two or more AI models side by side. */
66
+ compare(models: string[]): Promise<ComparisonResult>;
67
+ }
package/src/index.js ADDED
@@ -0,0 +1,124 @@
1
+ /**
2
+ * BenchGecko - Official JavaScript SDK for the BenchGecko API.
3
+ *
4
+ * Compare AI models, benchmarks, and pricing programmatically.
5
+ *
6
+ * @example
7
+ * const { BenchGecko } = require('benchgecko');
8
+ * const client = new BenchGecko();
9
+ * const models = await client.models();
10
+ */
11
+
12
+ class BenchGeckoError extends Error {
13
+ constructor(message, statusCode) {
14
+ super(message);
15
+ this.name = 'BenchGeckoError';
16
+ this.statusCode = statusCode || null;
17
+ }
18
+ }
19
+
20
+ class BenchGecko {
21
+ /**
22
+ * Create a BenchGecko API client.
23
+ *
24
+ * @param {Object} [options]
25
+ * @param {string} [options.baseUrl='https://benchgecko.ai'] - API base URL.
26
+ * @param {number} [options.timeout=30000] - Request timeout in milliseconds.
27
+ */
28
+ constructor(options = {}) {
29
+ this.baseUrl = (options.baseUrl || 'https://benchgecko.ai').replace(/\/+$/, '');
30
+ this.timeout = options.timeout || 30000;
31
+ }
32
+
33
+ /**
34
+ * Send a request to the BenchGecko API.
35
+ * @private
36
+ */
37
+ async _request(path, params = {}) {
38
+ const url = new URL(path, this.baseUrl);
39
+ Object.entries(params).forEach(([key, value]) => {
40
+ url.searchParams.set(key, value);
41
+ });
42
+
43
+ const controller = new AbortController();
44
+ const timeoutId = setTimeout(() => controller.abort(), this.timeout);
45
+
46
+ try {
47
+ const response = await fetch(url.toString(), {
48
+ method: 'GET',
49
+ headers: {
50
+ 'User-Agent': 'benchgecko-js/1.0.0',
51
+ 'Accept': 'application/json',
52
+ },
53
+ signal: controller.signal,
54
+ });
55
+
56
+ if (!response.ok) {
57
+ throw new BenchGeckoError(
58
+ `API request failed with status ${response.status}: ${response.statusText}`,
59
+ response.status
60
+ );
61
+ }
62
+
63
+ return await response.json();
64
+ } catch (error) {
65
+ if (error instanceof BenchGeckoError) throw error;
66
+ if (error.name === 'AbortError') {
67
+ throw new BenchGeckoError(`Request timed out after ${this.timeout}ms`);
68
+ }
69
+ throw new BenchGeckoError(`Request failed: ${error.message}`);
70
+ } finally {
71
+ clearTimeout(timeoutId);
72
+ }
73
+ }
74
+
75
+ /**
76
+ * List all AI models tracked by BenchGecko.
77
+ *
78
+ * @returns {Promise<Array<Object>>} Array of model objects with metadata,
79
+ * benchmark scores, and pricing information.
80
+ *
81
+ * @example
82
+ * const models = await client.models();
83
+ * console.log(`Tracking ${models.length} models`);
84
+ */
85
+ async models() {
86
+ return this._request('/api/v1/models');
87
+ }
88
+
89
+ /**
90
+ * List all benchmarks tracked by BenchGecko.
91
+ *
92
+ * @returns {Promise<Array<Object>>} Array of benchmark objects with name,
93
+ * category, and description.
94
+ *
95
+ * @example
96
+ * const benchmarks = await client.benchmarks();
97
+ * benchmarks.forEach(b => console.log(b.name));
98
+ */
99
+ async benchmarks() {
100
+ return this._request('/api/v1/benchmarks');
101
+ }
102
+
103
+ /**
104
+ * Compare two or more AI models side by side.
105
+ *
106
+ * @param {string[]} models - Array of model slugs to compare.
107
+ * @returns {Promise<Object>} Comparison result with per-model scores and pricing.
108
+ * @throws {Error} If fewer than 2 models are provided.
109
+ *
110
+ * @example
111
+ * const result = await client.compare(['gpt-4o', 'claude-opus-4']);
112
+ * result.models.forEach(m => console.log(m.name, m.scores));
113
+ */
114
+ async compare(models) {
115
+ if (!Array.isArray(models) || models.length < 2) {
116
+ throw new Error('At least 2 models are required for comparison.');
117
+ }
118
+ return this._request('/api/v1/compare', {
119
+ models: models.join(','),
120
+ });
121
+ }
122
+ }
123
+
124
+ module.exports = { BenchGecko, BenchGeckoError };