SDK

Typescript SDK

Typescript / Javascript SDK

Source Code

https://github.com/orquestadev/orquesta-javascript/tree/main/packages/js

Installation

npm install @orquesta/js-sdk
yarn add @orquesta/js-sdk

Creating a client instance

You can get your workspace API key from the settings section in your Orquesta workspace.

https://my.orquesta.dev/<workspace>/settings/developers

Initialize Orquesta module using your API Key.

import { createClient } from '@orquesta/js-sdk';

const client = createClient({
  api_key: '__API_KEY__',
  ttl: 3600,
});

When creating a client instance, the following connection settings can be adjusted using the OrquestaClientOptions class:

  • api_key: string - your workspace API key to use for authentication.

  • ttl?: number - the time to live in seconds for the local cache. Default is 3600 seconds (1 hour).

Usage - Remote Configurations

Important Note: If you want to use the Prompts API reach out to us.

Orquesta has a powerful Remote Configurations API that allows you to configure and run all your environments and services remotely. Orquesta supports different types of remote configurations, and we recommend always typing the query method to help Typescript infer the correct type.

The useOrquestaRemoteConfig hook receives an object of type OrquestaRemoteConfigQuery as parameter.

Supported types: booleannumberstring, JSON, array

Example: Querying a configuration of type boolean

const config: OrquestaRemoteConfig<boolean> =
  await client.remoteConfigs.query<boolean>({
    key: 'boolean_config',
    default_value: false,
    context: { environments: 'production', role: 'admin' },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type string

const config: OrquestaRemoteConfig<string> = await client.remoteConfigs.query<string>(
  {
    key: 'string_config',
    default_value: 'string_value',
    context: { environments: 'production', 'country': 'NL' },
    metadata: { timestamp: Date.now() },
  }
);

Example: Querying a configuration of type number

const config: OrquestaRemoteConfig<number> =
  await client.remoteConfigs.query<number>({
    key: 'number_config',
    default_value: 1990,
    context: { environments: 'production', market: 'US', domain: 'ecommerce' },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type array

const config: OrquestaRemoteConfig<string[]> = await client.remoteConfigs.query<
  string[]
>({
  key: 'array_config',
  default_value: ['value1', 'value2'],
  context: { environments: 'acceptance', isEnable: true },
  metadata: { timestamp: Date.now() },
});

Example: Querying a configuration of type JSON

It's recommended to add an interface to the JSON configuration to help Typescript infer the correct type.

const config: OrquestaRemoteConfig<object> =
  await client.remoteConfigs.query<object>({
    key: 'json_config',
    default_value: { dashboardEnabled: false, theme: 'dark' },
    context: { environments: 'develop', platform: 'mobile' },
    metadata: { timestamp: Date.now() },
  });

Additional metadata logging

After every query, Orquesta will generate a log with data about the request. You can add metadata to the log using the addMetrics method anytime.

metadata is a set of custom key-value pairs that you can use to add custom information to each log.

Example: Add metrics to your request log

config.addMetrics({
  metadata: {
    custom: 'custom_metadata',
    user_clicks: 20,
    selected_option: 'option1',
  },
});

Remote Configurations API

OrquestaRemoteConfigQuery

key string
Key of remote configuration to retrieve

default_value T
The value to be used in case there is an error during evaluation or the remote configuration does not exist

context Record<string, unknown> optional
Set of key-value pairs from your data model that should be compared against the values in the configuration matrix

metadata Record<string, unknown> optional
Set of key-value pairs of metadata to attach to the generated log after the evaluation


OrquestaRemoteConfig

value T
The value of the remote configuration

type OrquestaRemoteConfigType
Return type of the remote configuration

trace_id string
race ID of the request log to use to report metadata to the API if the method addMetrics is not used

addMetrics (payload: OrquestaRemoteConfigMetrics) => Promise<void>
A method that reports metadata to the request log after the configuration value is returned. At least one of the properties is required


OrquestaRemoteConfigMetrics

metadata Record<string, unknown> optional
Set of key-value pairs of metadata you want to attach to the request log

Typescript / Javascript SDK

Source Code

https://github.com/orquestadev/orquesta-javascript/tree/main/packages/js

Installation

npm install @orquesta/js-sdk
yarn add @orquesta/js-sdk

Creating a client instance

You can get your workspace API key from the settings section in your Orquesta workspace.

https://my.orquesta.dev/<workspace>/settings/developers

Initialize Orquesta module using your API Key.

import { createClient } from '@orquesta/js-sdk';

const client = createClient({
  api_key: '__API_KEY__',
  ttl: 3600,
});

When creating a client instance, the following connection settings can be adjusted using the OrquestaClientOptions class:

  • api_key: string - your workspace API key to use for authentication.

  • ttl?: number - the time to live in seconds for the local cache. Default is 3600 seconds (1 hour).

Usage - Remote Configurations

Important Note: If you want to use the Prompts API reach out to us.

Orquesta has a powerful Remote Configurations API that allows you to configure and run all your environments and services remotely. Orquesta supports different types of remote configurations, and we recommend always typing the query method to help Typescript infer the correct type.

The useOrquestaRemoteConfig hook receives an object of type OrquestaRemoteConfigQuery as parameter.

Supported types: booleannumberstring, JSON, array

Example: Querying a configuration of type boolean

const config: OrquestaRemoteConfig<boolean> =
  await client.remoteConfigs.query<boolean>({
    key: 'boolean_config',
    default_value: false,
    context: { environments: 'production', role: 'admin' },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type string

const config: OrquestaRemoteConfig<string> = await client.remoteConfigs.query<string>(
  {
    key: 'string_config',
    default_value: 'string_value',
    context: { environments: 'production', 'country': 'NL' },
    metadata: { timestamp: Date.now() },
  }
);

Example: Querying a configuration of type number

const config: OrquestaRemoteConfig<number> =
  await client.remoteConfigs.query<number>({
    key: 'number_config',
    default_value: 1990,
    context: { environments: 'production', market: 'US', domain: 'ecommerce' },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type array

const config: OrquestaRemoteConfig<string[]> = await client.remoteConfigs.query<
  string[]
>({
  key: 'array_config',
  default_value: ['value1', 'value2'],
  context: { environments: 'acceptance', isEnable: true },
  metadata: { timestamp: Date.now() },
});

Example: Querying a configuration of type JSON

It's recommended to add an interface to the JSON configuration to help Typescript infer the correct type.

const config: OrquestaRemoteConfig<object> =
  await client.remoteConfigs.query<object>({
    key: 'json_config',
    default_value: { dashboardEnabled: false, theme: 'dark' },
    context: { environments: 'develop', platform: 'mobile' },
    metadata: { timestamp: Date.now() },
  });

Additional metadata logging

After every query, Orquesta will generate a log with data about the request. You can add metadata to the log using the addMetrics method anytime.

metadata is a set of custom key-value pairs that you can use to add custom information to each log.

Example: Add metrics to your request log

config.addMetrics({
  metadata: {
    custom: 'custom_metadata',
    user_clicks: 20,
    selected_option: 'option1',
  },
});

Remote Configurations API

OrquestaRemoteConfigQuery

key string
Key of remote configuration to retrieve

default_value T
The value to be used in case there is an error during evaluation or the remote configuration does not exist

context Record<string, unknown> optional
Set of key-value pairs from your data model that should be compared against the values in the configuration matrix

metadata Record<string, unknown> optional
Set of key-value pairs of metadata to attach to the generated log after the evaluation


OrquestaRemoteConfig

value T
The value of the remote configuration

type OrquestaRemoteConfigType
Return type of the remote configuration

trace_id string
race ID of the request log to use to report metadata to the API if the method addMetrics is not used

addMetrics (payload: OrquestaRemoteConfigMetrics) => Promise<void>
A method that reports metadata to the request log after the configuration value is returned. At least one of the properties is required


OrquestaRemoteConfigMetrics

metadata Record<string, unknown> optional
Set of key-value pairs of metadata you want to attach to the request log

Typescript / Javascript SDK

Source Code

https://github.com/orquestadev/orquesta-javascript/tree/main/packages/js

Installation

npm install @orquesta/js-sdk
yarn add @orquesta/js-sdk

Creating a client instance

You can get your workspace API key from the settings section in your Orquesta workspace.

https://my.orquesta.dev/<workspace>/settings/developers

Initialize Orquesta module using your API Key.

import { createClient } from '@orquesta/js-sdk';

const client = createClient({
  api_key: '__API_KEY__',
  ttl: 3600,
});

When creating a client instance, the following connection settings can be adjusted using the OrquestaClientOptions class:

  • api_key: string - your workspace API key to use for authentication.

  • ttl?: number - the time to live in seconds for the local cache. Default is 3600 seconds (1 hour).

Usage - Remote Configurations

Important Note: If you want to use the Prompts API reach out to us.

Orquesta has a powerful Remote Configurations API that allows you to configure and run all your environments and services remotely. Orquesta supports different types of remote configurations, and we recommend always typing the query method to help Typescript infer the correct type.

The useOrquestaRemoteConfig hook receives an object of type OrquestaRemoteConfigQuery as parameter.

Supported types: booleannumberstring, JSON, array

Example: Querying a configuration of type boolean

const config: OrquestaRemoteConfig<boolean> =
  await client.remoteConfigs.query<boolean>({
    key: 'boolean_config',
    default_value: false,
    context: { environments: 'production', role: 'admin' },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type string

const config: OrquestaRemoteConfig<string> = await client.remoteConfigs.query<string>(
  {
    key: 'string_config',
    default_value: 'string_value',
    context: { environments: 'production', 'country': 'NL' },
    metadata: { timestamp: Date.now() },
  }
);

Example: Querying a configuration of type number

const config: OrquestaRemoteConfig<number> =
  await client.remoteConfigs.query<number>({
    key: 'number_config',
    default_value: 1990,
    context: { environments: 'production', market: 'US', domain: 'ecommerce' },
    metadata: { timestamp: Date.now() },
  });

Example: Querying a configuration of type array

const config: OrquestaRemoteConfig<string[]> = await client.remoteConfigs.query<
  string[]
>({
  key: 'array_config',
  default_value: ['value1', 'value2'],
  context: { environments: 'acceptance', isEnable: true },
  metadata: { timestamp: Date.now() },
});

Example: Querying a configuration of type JSON

It's recommended to add an interface to the JSON configuration to help Typescript infer the correct type.

const config: OrquestaRemoteConfig<object> =
  await client.remoteConfigs.query<object>({
    key: 'json_config',
    default_value: { dashboardEnabled: false, theme: 'dark' },
    context: { environments: 'develop', platform: 'mobile' },
    metadata: { timestamp: Date.now() },
  });

Additional metadata logging

After every query, Orquesta will generate a log with data about the request. You can add metadata to the log using the addMetrics method anytime.

metadata is a set of custom key-value pairs that you can use to add custom information to each log.

Example: Add metrics to your request log

config.addMetrics({
  metadata: {
    custom: 'custom_metadata',
    user_clicks: 20,
    selected_option: 'option1',
  },
});

Remote Configurations API

OrquestaRemoteConfigQuery

key string
Key of remote configuration to retrieve

default_value T
The value to be used in case there is an error during evaluation or the remote configuration does not exist

context Record<string, unknown> optional
Set of key-value pairs from your data model that should be compared against the values in the configuration matrix

metadata Record<string, unknown> optional
Set of key-value pairs of metadata to attach to the generated log after the evaluation


OrquestaRemoteConfig

value T
The value of the remote configuration

type OrquestaRemoteConfigType
Return type of the remote configuration

trace_id string
race ID of the request log to use to report metadata to the API if the method addMetrics is not used

addMetrics (payload: OrquestaRemoteConfigMetrics) => Promise<void>
A method that reports metadata to the request log after the configuration value is returned. At least one of the properties is required


OrquestaRemoteConfigMetrics

metadata Record<string, unknown> optional
Set of key-value pairs of metadata you want to attach to the request log

Start powering your SaaS with LLMs

Start

powering

your SaaS

with LLMs

Start powering your SaaS with LLMs