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
  • create - Create an observability destination
  • delete - Delete an observability destination
  • get - Get an observability destination
  • update - Update 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*/*

create

Create a new observability destination. A maximum of 5 destinations per type is allowed. Defaults to the authenticated entity’s default workspace; use the workspace_id body field to scope to a different workspace. 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.create({
12 createObservabilityDestinationRequest: {
13 config: {
14 "baseUrl": "https://us.cloud.langfuse.com",
15 "publicKey": "pk-l...EfGh",
16 "secretKey": "sk-l...AbCd",
17 },
18 name: "Production Langfuse",
19 type: "langfuse",
20 },
21 });
22
23 console.log(result);
24}
25
26run();

Standalone function

The standalone function version of this method:

1import { OpenRouterCore } from "@openrouter/sdk/core.js";
2import { observabilityCreate } from "@openrouter/sdk/funcs/observabilityCreate.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 observabilityCreate(openRouter, {
15 createObservabilityDestinationRequest: {
16 config: {
17 "baseUrl": "https://us.cloud.langfuse.com",
18 "publicKey": "pk-l...EfGh",
19 "secretKey": "sk-l...AbCd",
20 },
21 name: "Production Langfuse",
22 type: "langfuse",
23 },
24 });
25 if (res.ok) {
26 const { value: result } = res;
27 console.log(result);
28 } else {
29 console.log("observabilityCreate failed:", res.error);
30 }
31}
32
33run();

Parameters

ParameterTypeRequiredDescription
requestoperations.CreateObservabilityDestinationRequest✔️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.CreateObservabilityDestinationResponse>

Errors

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

delete

Delete an existing observability destination. This performs a soft delete. 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.delete({
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 { observabilityDelete } from "@openrouter/sdk/funcs/observabilityDelete.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 observabilityDelete(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("observabilityDelete failed:", res.error);
22 }
23}
24
25run();

Parameters

ParameterTypeRequiredDescription
requestoperations.DeleteObservabilityDestinationRequest✔️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.DeleteObservabilityDestinationResponse>

Errors

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

get

Fetch a single observability destination by its UUID. 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*/*

update

Update an existing observability destination. Only the fields provided in the request body are updated. 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.update({
12 id: "99999999-aaaa-bbbb-cccc-dddddddddddd",
13 updateObservabilityDestinationRequest: {
14 enabled: false,
15 name: "Updated Langfuse",
16 },
17 });
18
19 console.log(result);
20}
21
22run();

Standalone function

The standalone function version of this method:

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

Parameters

ParameterTypeRequiredDescription
requestoperations.UpdateObservabilityDestinationRequest✔️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.UpdateObservabilityDestinationResponse>

Errors

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