For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
ModelsChatRankingsDocs
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
DocsAPI ReferenceClient SDKsAgent SDKCookbookChangelog
    • Overview
    • Usage for Agents
  • TypeScript SDK
    • Overview
      • Analytics
      • APIKeys
      • Byok
      • Chat
      • Credits
      • Embeddings
      • Endpoints
      • Generations
      • Guardrails
        • Models
      • OAuth
      • Observability
      • Organization
      • Presets
      • Providers
      • Rerank
      • Beta.Responses
      • Transcriptions
      • Speech
      • VideoGeneration
      • Workspaces
  • Python SDK
    • Overview
  • Go SDK
  • DevTools
    • Overview
    • Migrating to @openrouter/agent
LogoLogo
ModelsChatRankingsDocs
On this page
  • Overview
  • Available Operations
  • list
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • count
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
  • listForUser
  • Example Usage
  • Standalone function
  • Parameters
  • Response
  • Errors
TypeScript SDKAPI ReferenceModels

Models - TypeScript SDK

Models method reference
Was this page helpful?
Previous

OAuth - TypeScript SDK

OAuth method reference
Next
Built with

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

Overview

Model information endpoints

Available Operations

  • list - List all models and their properties
  • count - Get total count of available models
  • listForUser - List models filtered by user provider preferences, privacy settings, and guardrails

list

List all models and their properties

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.models.list();
12
13 console.log(result);
14}
15
16run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { modelsList } from "@openrouter/sdk/funcs/modelsList.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 modelsList(openRouter);
15 if (res.ok) {
16 const { value: result } = res;
17 console.log(result);
18 } else {
19 console.log("modelsList failed:", res.error);
20 }
21}
22
23run();

Parameters

ParameterTypeRequiredDescription
requestoperations.GetModelsRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options 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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.ModelsListResponse>

Errors

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

count

Get total count of available models

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.models.count();
12
13 console.log(result);
14}
15
16run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { modelsCount } from "@openrouter/sdk/funcs/modelsCount.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 modelsCount(openRouter);
15 if (res.ok) {
16 const { value: result } = res;
17 console.log(result);
18 } else {
19 console.log("modelsCount failed:", res.error);
20 }
21}
22
23run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListModelsCountRequest✔️The request object to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options 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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.ModelsCountResponse>

Errors

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

listForUser

List models filtered by user provider preferences, privacy settings, and guardrails. If requesting through eu.openrouter.ai/api/v1/... the results will be filtered to models that satisfy EU in-region routing.

Example Usage

1import { OpenRouter } from "@openrouter/sdk";
2
3const openRouter = new OpenRouter({
4 httpReferer: "<value>",
5 appTitle: "<value>",
6 appCategories: "<value>",
7});
8
9async function run() {
10 const result = await openRouter.models.listForUser({
11 bearer: process.env["OPENROUTER_BEARER"] ?? "",
12 });
13
14 console.log(result);
15}
16
17run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { modelsListForUser } from "@openrouter/sdk/funcs/modelsListForUser.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});
11
12async function run() {
13 const res = await modelsListForUser(openRouter, {
14 bearer: process.env["OPENROUTER_BEARER"] ?? "",
15 });
16 if (res.ok) {
17 const { value: result } = res;
18 console.log(result);
19 } else {
20 console.log("modelsListForUser failed:", res.error);
21 }
22}
23
24run();

Parameters

ParameterTypeRequiredDescription
requestoperations.ListModelsUserRequest✔️The request object to use for the request.
securityoperations.ListModelsUserSecurity✔️The security requirements to use for the request.
optionsRequestOptions➖Used to set various options for making HTTP requests.
options.fetchOptionsRequestInit➖Options 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.retriesRetryConfig➖Enables retrying HTTP requests under certain failure conditions.

Response

Promise<models.ModelsListResponse>

Errors

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