Observability - TypeScript SDK

Observability method reference

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

Overview

Observability endpoints

Available Operations

  • list - List observability destinations
  • get - Get an observability destination

list

List the observability destinations configured for the authenticated entity’s default workspace. Use the workspace_id query parameter to scope the result to a different workspace. Only destinations with stable release status are surfaced — destinations of other types are excluded. Management key required.

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.observability.list();
12
13 for await (const page of result) {
14 console.log(page);
15 }
16}
17
18run();

Standalone function

The standalone function version of this method:

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

Parameters

ParameterTypeRequiredDescription
requestoperations.ListObservabilityDestinationsRequest✔️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<operations.ListObservabilityDestinationsResponse>

Errors

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

get

Fetch a single observability destination by its UUID. Defaults to the authenticated entity’s default workspace — use workspace_id to override. Management key required.

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.observability.get({
12 id: "99999999-aaaa-bbbb-cccc-dddddddddddd",
13 });
14
15 console.log(result);
16}
17
18run();

Standalone function

The standalone function version of this method:

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

Parameters

ParameterTypeRequiredDescription
requestoperations.GetObservabilityDestinationRequest✔️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.GetObservabilityDestinationResponse>

Errors

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