Benchmarks - TypeScript SDK

Benchmarks method reference

The TypeScript SDK and docs are currently in beta. Report issues on GitHub.

Overview

Benchmarks endpoints

Available Operations

getBenchmarks

Unified benchmark endpoint that aggregates scores from multiple benchmark sources (Artificial Analysis, Design Arena). Filter by source to reproduce the exact shapes from the legacy per-source endpoints, or use task_type to find models suited for specific workloads. Authenticate with any valid OpenRouter API key. Rate-limited to 30 requests/minute per key and 500 requests/day per account.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
8});
9
10async function run() {
11 const result = await openRouter.benchmarks.getBenchmarks({
12 source: "artificial-analysis",
13 maxResults: 20,
14 });
15
16 console.log(result);
17}
18
19run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { benchmarksGetBenchmarks } from "@openrouter/sdk/funcs/benchmarksGetBenchmarks.js";
3
4// Use `OpenRouterCore` for best tree-shaking performance.
5// You can create one instance of it to use across an application.
6const openRouter = new OpenRouterCore({
7 httpReferer: "<value>",
8 appTitle: "<value>",
9 appCategories: "<value>",
10 apiKey: process.env["OPENROUTER_API_KEY"] ?? "",
11});
12
13async function run() {
14 const res = await benchmarksGetBenchmarks(openRouter, {
15 source: "artificial-analysis",
16 maxResults: 20,
17 });
18 if (res.ok) {
19 const { value: result } = res;
20 console.log(result);
21 } else {
22 console.log("benchmarksGetBenchmarks failed:", res.error);
23 }
24}
25
26run();

Parameters

ParameterTypeRequiredDescription
requestoperations.GetBenchmarksRequest✔️The request object to use for the request.
optionsRequestOptionsUsed to set various options for making HTTP requests.
options.fetchOptionsRequestInitOptions that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retriesRetryConfigEnables retrying HTTP requests under certain failure conditions.

Response

Promise<models.UnifiedBenchmarksResponse>

Errors

Error TypeStatus CodeContent Type
errors.BadRequestResponseError400application/json
errors.UnauthorizedResponseError401application/json
errors.TooManyRequestsResponseError429application/json
errors.InternalServerResponseError500application/json
errors.OpenRouterDefaultError4XX, 5XX*/*