opik
Version:
Opik TypeScript and JavaScript SDK
2,083 lines (1,914 loc) • 561 kB
TypeScript
import * as stream_web from 'stream/web';
import * as stream from 'stream';
import * as buffer from 'buffer';
import { Logger as Logger$1 } from 'tslog';
import { z } from 'zod';
export { z } from 'zod';
import { ModelMessage, SystemModelMessage, UserModelMessage, AssistantModelMessage, ToolModelMessage, LanguageModel } from 'ai';
import { OpenAIProviderSettings } from '@ai-sdk/openai';
import { OpenAIChatModelId } from '@ai-sdk/openai/internal';
import { AnthropicProviderSettings } from '@ai-sdk/anthropic';
import { AnthropicMessagesModelId } from '@ai-sdk/anthropic/internal';
import { GoogleGenerativeAIProviderSettings } from '@ai-sdk/google';
import { GoogleGenerativeAIModelId } from '@ai-sdk/google/internal';
/**
* The raw response from the fetch call excluding the body.
*/
type RawResponse = Omit<{
[K in keyof Response as Response[K] extends Function ? never : K]: Response[K];
}, "ok" | "body" | "bodyUsed">;
/**
* Creates a `RawResponse` from a standard `Response` object.
*/
interface WithRawResponse<T> {
readonly data: T;
readonly rawResponse: RawResponse;
}
type Supplier<T> = T | Promise<T> | (() => T | Promise<T>);
declare const Supplier: {
get: <T>(supplier: Supplier<T>) => Promise<T>;
};
declare const LogLevel: {
readonly Debug: "debug";
readonly Info: "info";
readonly Warn: "warn";
readonly Error: "error";
};
type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
interface ILogger {
/**
* Logs a debug message.
* @param message - The message to log
* @param args - Additional arguments to log
*/
debug(message: string, ...args: unknown[]): void;
/**
* Logs an info message.
* @param message - The message to log
* @param args - Additional arguments to log
*/
info(message: string, ...args: unknown[]): void;
/**
* Logs a warning message.
* @param message - The message to log
* @param args - Additional arguments to log
*/
warn(message: string, ...args: unknown[]): void;
/**
* Logs an error message.
* @param message - The message to log
* @param args - Additional arguments to log
*/
error(message: string, ...args: unknown[]): void;
}
/**
* Configuration for logger initialization.
*/
interface LogConfig {
/**
* Minimum log level to output.
* @default LogLevel.Info
*/
level?: LogLevel;
/**
* Logger implementation to use.
* @default new ConsoleLogger()
*/
logger?: ILogger;
/**
* Whether logging should be silenced.
* @default true
*/
silent?: boolean;
}
/**
* Logger class that provides level-based logging functionality.
*/
declare class Logger {
private readonly level;
private readonly logger;
private readonly silent;
/**
* Creates a new logger instance.
* @param config - Logger configuration
*/
constructor(config: Required<LogConfig>);
/**
* Checks if a log level should be output based on configuration.
* @param level - The log level to check
* @returns True if the level should be logged
*/
shouldLog(level: LogLevel): boolean;
/**
* Checks if debug logging is enabled.
* @returns True if debug logs should be output
*/
isDebug(): boolean;
/**
* Logs a debug message if debug logging is enabled.
* @param message - The message to log
* @param args - Additional arguments to log
*/
debug(message: string, ...args: unknown[]): void;
/**
* Checks if info logging is enabled.
* @returns True if info logs should be output
*/
isInfo(): boolean;
/**
* Logs an info message if info logging is enabled.
* @param message - The message to log
* @param args - Additional arguments to log
*/
info(message: string, ...args: unknown[]): void;
/**
* Checks if warning logging is enabled.
* @returns True if warning logs should be output
*/
isWarn(): boolean;
/**
* Logs a warning message if warning logging is enabled.
* @param message - The message to log
* @param args - Additional arguments to log
*/
warn(message: string, ...args: unknown[]): void;
/**
* Checks if error logging is enabled.
* @returns True if error logs should be output
*/
isError(): boolean;
/**
* Logs an error message if error logging is enabled.
* @param message - The message to log
* @param args - Additional arguments to log
*/
error(message: string, ...args: unknown[]): void;
}
/**
* A promise that returns the parsed response and lets you retrieve the raw response too.
*/
declare class HttpResponsePromise<T> extends Promise<T> {
private innerPromise;
private unwrappedPromise;
private constructor();
/**
* Creates an `HttpResponsePromise` from a function that returns a promise.
*
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
* @param args - Arguments to pass to the function.
* @returns An `HttpResponsePromise` instance.
*/
static fromFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T>(fn: F, ...args: Parameters<F>): HttpResponsePromise<T>;
/**
* Creates a function that returns an `HttpResponsePromise` from a function that returns a promise.
*
* @param fn - A function that returns a promise resolving to a `WithRawResponse` object.
* @returns A function that returns an `HttpResponsePromise` instance.
*/
static interceptFunction<F extends (...args: never[]) => Promise<WithRawResponse<T>>, T = Awaited<ReturnType<F>>["data"]>(fn: F): (...args: Parameters<F>) => HttpResponsePromise<T>;
/**
* Creates an `HttpResponsePromise` from an existing promise.
*
* @param promise - A promise resolving to a `WithRawResponse` object.
* @returns An `HttpResponsePromise` instance.
*/
static fromPromise<T>(promise: Promise<WithRawResponse<T>>): HttpResponsePromise<T>;
/**
* Creates an `HttpResponsePromise` from an executor function.
*
* @param executor - A function that takes resolve and reject callbacks to create a promise.
* @returns An `HttpResponsePromise` instance.
*/
static fromExecutor<T>(executor: (resolve: (value: WithRawResponse<T>) => void, reject: (reason?: unknown) => void) => void): HttpResponsePromise<T>;
/**
* Creates an `HttpResponsePromise` from a resolved result.
*
* @param result - A `WithRawResponse` object to resolve immediately.
* @returns An `HttpResponsePromise` instance.
*/
static fromResult<T>(result: WithRawResponse<T>): HttpResponsePromise<T>;
private unwrap;
/** @inheritdoc */
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
/** @inheritdoc */
catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
/** @inheritdoc */
finally(onfinally?: (() => void) | null): Promise<T>;
/**
* Retrieves the data and raw response.
*
* @returns A promise resolving to a `WithRawResponse` object.
*/
withRawResponse(): Promise<WithRawResponse<T>>;
}
/**
* A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.),
* a path to a file, or an object with a file-like object and metadata.
*/
type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata;
declare namespace Uploadable {
/**
* Various file-like objects that can be used to upload a file.
*/
type FileLike = ArrayBuffer | ArrayBufferLike | ArrayBufferView | Uint8Array | buffer.Buffer | buffer.Blob | buffer.File | stream.Readable | stream_web.ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
/**
* A file path with optional metadata, used for uploading a file from the file system.
*/
type FromPath = {
/** The path to the file to upload */
path: string;
/**
* Optional override for the file name (defaults to basename of path).
* This is used to set the `Content-Disposition` header in upload requests.
*/
filename?: string;
/**
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
* This is used to set the `Content-Type` header in upload requests.
*/
contentType?: string;
/**
* Optional file size in bytes.
* If not provided, the file size will be determined from the file system.
* The content length is used to set the `Content-Length` header in upload requests.
*/
contentLength?: number;
};
/**
* A file-like object with metadata, used for uploading files.
*/
type WithMetadata = {
/** The file data */
data: FileLike;
/**
* Optional override for the file name (defaults to basename of path).
* This is used to set the `Content-Disposition` header in upload requests.
*/
filename?: string;
/**
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
* This is used to set the `Content-Type` header in upload requests.
*
* If not provided, the content type may be determined from the data itself.
* * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set.
* * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead.
*/
contentType?: string;
/**
* Optional file size in bytes.
* The content length is used to set the `Content-Length` header in upload requests.
* If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead.
*
* If not provided, the file size will be determined depending on the data type.
* * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system.
* * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself.
* * If the data is a `Readable` or `ReadableStream`, the size will not be determined.
*/
contentLength?: number;
};
}
/**
* @example
* {
* blueprintName: "blueprint_name"
* }
*/
interface AgentConfigEnvSetByName {
blueprintName: string;
}
/**
* @example
* {
* projectId: "project_id",
* envs: [{
* envName: "env_name",
* blueprintId: "blueprint_id"
* }]
* }
*/
interface AgentConfigEnvUpdate {
projectId: string;
envs: AgentConfigEnv[];
}
/**
* @example
* {
* keys: ["keys"]
* }
*/
interface AgentConfigRemoveValues {
/** Project ID. Either project_id or project_name must be provided */
projectId?: string;
/** Project name. Either project_id or project_name must be provided */
projectName?: string;
keys: string[];
}
/**
* @example
* {}
*/
type CreateBlueprintFromMaskRequest = {};
/**
* @example
* {}
*/
type DeleteEnvRequest = {};
/**
* @example
* {}
*/
interface GetBlueprintByEnvRequest {
maskId?: string;
}
/**
* @example
* {}
*/
interface GetBlueprintByIdRequest {
maskId?: string;
}
/**
* @example
* {}
*/
interface GetBlueprintByNameRequest {
maskId?: string;
}
/**
* @example
* {}
*/
interface GetBlueprintHistoryRequest {
page?: number;
size?: number;
}
/**
* @example
* {}
*/
type GetDeltaByIdRequest = {};
/**
* @example
* {}
*/
interface GetLatestBlueprintRequest {
maskId?: string;
}
/**
* @example
* {}
*/
interface FindAlertsRequest {
page?: number;
size?: number;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
type GetAlertByIdRequest = {};
/**
* @example
* {}
*/
interface GetWebhookExamplesRequest {
alertType?: GetWebhookExamplesRequestAlertType;
}
/**
* @example
* {
* body: {
* webhook: {
* url: "url"
* }
* }
* }
*/
interface UpdateAlertRequest {
body: AlertWrite;
}
declare const GetWebhookExamplesRequestAlertType: {
readonly General: "general";
readonly Slack: "slack";
readonly Pagerduty: "pagerduty";
};
type GetWebhookExamplesRequestAlertType = (typeof GetWebhookExamplesRequestAlertType)[keyof typeof GetWebhookExamplesRequestAlertType];
/**
* @example
* {
* body: {
* ids: ["ids"]
* }
* }
*/
interface AddItemsToAnnotationQueueRequest {
body: AnnotationQueueItemIds;
}
/**
* @example
* {
* annotationQueues: [{
* projectId: "project_id",
* name: "name",
* scope: "trace"
* }]
* }
*/
interface AnnotationQueueBatchWrite {
/** List of annotation queues to create */
annotationQueues: AnnotationQueueWrite[];
}
/**
* @example
* {}
*/
interface AnnotationQueueUpdate {
name?: string;
description?: string;
instructions?: string;
commentsEnabled?: boolean;
feedbackDefinitionNames?: string[];
}
/**
* @example
* {}
*/
interface FindAnnotationQueuesRequest {
page?: number;
size?: number;
name?: string;
filters?: string;
sorting?: string;
}
/**
* @example
* {}
*/
type GetAnnotationQueueByIdRequest = {};
/**
* @example
* {
* body: {
* ids: ["ids"]
* }
* }
*/
interface RemoveItemsFromAnnotationQueueRequest {
body: AnnotationQueueItemIds;
}
/**
* @example
* {
* entityType: "TRACE",
* assertionResults: [{
* entityId: "entity_id",
* name: "name",
* status: "passed",
* source: "ui"
* }]
* }
*/
interface AssertionResultBatch {
entityType: AssertionResultBatchEntityType;
assertionResults: AssertionResultBatchItem[];
}
declare const AssertionResultBatchEntityType: {
readonly Trace: "TRACE";
readonly Span: "SPAN";
readonly Thread: "THREAD";
};
type AssertionResultBatchEntityType = (typeof AssertionResultBatchEntityType)[keyof typeof AssertionResultBatchEntityType];
/**
* @example
* {
* projectId: "project_id",
* entityType: "trace",
* entityId: "entity_id",
* path: "path"
* }
*/
interface AttachmentListRequest {
page?: number;
size?: number;
projectId: string;
entityType: AttachmentListRequestEntityType;
entityId: string;
path: string;
}
/**
* @example
* {
* containerId: "container_id",
* entityType: "trace",
* entityId: "entity_id",
* fileName: "x",
* mimeType: "x"
* }
*/
interface DownloadAttachmentRequest {
workspaceName?: string;
containerId: string;
entityType: DownloadAttachmentRequestEntityType;
entityId: string;
fileName: string;
mimeType: string;
}
/**
* @example
* {
* fileName: "file_name",
* numOfFileParts: 1,
* entityType: "trace",
* entityId: "entity_id",
* path: "path"
* }
*/
interface StartMultipartUploadRequest {
fileName: string;
numOfFileParts: number;
mimeType?: string;
/** If null, the default project is used */
projectName?: string;
entityType: StartMultipartUploadRequestEntityType;
entityId: string;
path: string;
}
/**
* @example
* {
* fileName: "file_name",
* entityType: "trace",
* entityId: "entity_id",
* body: {
* "key": "value"
* }
* }
*/
interface UploadAttachmentRequest {
fileName: string;
projectName?: string;
mimeType?: string;
entityType: UploadAttachmentRequestEntityType;
entityId: string;
body: Record<string, unknown>;
}
declare const AttachmentListRequestEntityType: {
readonly Trace: "trace";
readonly Span: "span";
};
type AttachmentListRequestEntityType = (typeof AttachmentListRequestEntityType)[keyof typeof AttachmentListRequestEntityType];
declare const DownloadAttachmentRequestEntityType: {
readonly Trace: "trace";
readonly Span: "span";
};
type DownloadAttachmentRequestEntityType = (typeof DownloadAttachmentRequestEntityType)[keyof typeof DownloadAttachmentRequestEntityType];
declare const StartMultipartUploadRequestEntityType: {
readonly Trace: "trace";
readonly Span: "span";
};
type StartMultipartUploadRequestEntityType = (typeof StartMultipartUploadRequestEntityType)[keyof typeof StartMultipartUploadRequestEntityType];
declare const UploadAttachmentRequestEntityType: {
readonly Trace: "trace";
readonly Span: "span";
};
type UploadAttachmentRequestEntityType = (typeof UploadAttachmentRequestEntityType)[keyof typeof UploadAttachmentRequestEntityType];
/**
* @example
* {
* body: {
* ids: ["ids"]
* }
* }
*/
interface DeleteAutomationRuleEvaluatorBatchRequest {
projectId?: string;
body: BatchDelete;
}
/**
* @example
* {}
*/
interface FindEvaluatorsRequest {
projectId?: string;
id?: string;
name?: string;
filters?: string;
sorting?: string;
page?: number;
size?: number;
}
/**
* @example
* {}
*/
interface GetEvaluatorByIdRequest {
projectId?: string;
}
/**
* @example
* {}
*/
interface GetEvaluatorLogsByIdRequest {
size?: number;
}
/**
* @example
* {
* body: {
* type: "llm_as_judge",
* name: "string",
* action: "evaluator"
* }
* }
*/
interface UpdateAutomationRuleEvaluatorRequest {
body: AutomationRuleEvaluatorUpdate;
}
/**
* @example
* {}
*/
interface ChatCompletionRequest {
model?: string;
messages?: Message[];
temperature?: number;
topP?: number;
n?: number;
stream?: boolean;
streamOptions?: StreamOptions;
stop?: string[];
maxTokens?: number;
maxCompletionTokens?: number;
presencePenalty?: number;
frequencyPenalty?: number;
logitBias?: Record<string, number>;
user?: string;
responseFormat?: ResponseFormat;
seed?: number;
tools?: Tool[];
toolChoice?: Record<string, unknown>;
parallelToolCalls?: boolean;
store?: boolean;
metadata?: Record<string, string>;
reasoningEffort?: string;
serviceTier?: string;
logprobs?: boolean;
topLogprobs?: number;
functions?: Function$1[];
functionCall?: FunctionCall;
}
/**
* @example
* {}
*/
type DeleteDashboardRequest = {};
/**
* @example
* {}
*/
interface FindDashboardsRequest {
page?: number;
size?: number;
name?: string;
projectId?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
type GetDashboardByIdRequest = {};
/**
* @example
* {
* body: {}
* }
*/
interface UpdateDashboardRequest {
body: DashboardUpdatePublic;
}
/**
* @example
* {
* body: {
* "key": "value"
* }
* }
*/
interface ApplyDatasetItemChangesRequest {
override?: boolean;
body: DatasetItemChangesPublic;
}
/**
* @example
* {}
*/
type CompareDatasetVersionsRequest = {};
/**
* @example
* {
* file: {
* "key": "value"
* },
* datasetId: "dataset_id"
* }
*/
interface CreateDatasetItemsFromCsvRequest {
file: Record<string, unknown>;
datasetId: string;
}
/**
* @example
* {
* spanIds: ["span_ids"],
* enrichmentOptions: {}
* }
*/
interface CreateDatasetItemsFromSpansRequest {
/** Set of span IDs to add to the dataset */
spanIds: string[];
enrichmentOptions: SpanEnrichmentOptions;
/** Optional evaluators to apply to the created items */
evaluators?: EvaluatorItem[];
executionPolicy?: ExecutionPolicy$1;
}
/**
* @example
* {
* traceIds: ["trace_ids"],
* enrichmentOptions: {}
* }
*/
interface CreateDatasetItemsFromTracesRequest {
/** Set of trace IDs to add to the dataset */
traceIds: string[];
enrichmentOptions: TraceEnrichmentOptions;
/** Optional evaluators to apply to the created items */
evaluators?: EvaluatorItem[];
executionPolicy?: ExecutionPolicy$1;
}
/**
* @example
* {
* model: "gpt-4"
* }
*/
interface DatasetExpansionWrite {
/** The model to use for synthetic data generation */
model: string;
/** Number of synthetic samples to generate */
sampleCount?: number;
/** Fields to preserve patterns from original data */
preserveFields?: string[];
/** Additional instructions for data variation */
variationInstructions?: string;
/** Custom prompt to use for generation instead of auto-generated one */
customPrompt?: string;
/** Maximum number of tokens for the LLM response. Required by Anthropic, used as maxOutputTokens for Gemini. If not provided, defaults to 4000 for Anthropic models only. */
maxCompletionTokens?: number;
}
/**
* @example
* {
* datasetName: "dataset_name"
* }
*/
interface DatasetIdentifier {
datasetName: string;
projectName?: string;
}
/**
* @example
* {
* datasetName: "dataset_name"
* }
*/
interface DatasetIdentifierPublic {
datasetName: string;
projectName?: string;
}
/**
* @example
* {
* update: {}
* }
*/
interface DatasetItemBatchUpdate {
/** List of dataset item IDs to update (max 1000). Mutually exclusive with 'filters'. */
ids?: string[];
filters?: DatasetItemFilter[];
/** Dataset ID. Required when using 'filters', optional when using 'ids'. */
datasetId?: string;
update: DatasetItemUpdate;
/** If true, merge tags with existing tags instead of replacing them. Default: false. When using 'filters', this is automatically set to true. */
mergeTags?: boolean;
}
/**
* @example
* {
* items: [{
* source: "manual",
* data: {
* "key": "value"
* }
* }]
* }
*/
interface DatasetItemBatchWrite {
/** If null, dataset_id must be provided */
datasetName?: string;
/** If null, dataset_name must be provided */
datasetId?: string;
/** Optional. Associates the batch with a project by name. Ignored if project_id is provided. */
projectName?: string;
/** Optional. Associates the batch with a project by ID. Takes precedence over project_name. */
projectId?: string;
items: DatasetItemWrite[];
/** Optional batch group ID to group multiple batches into a single dataset version. If null, mutates the latest version instead of creating a new one. */
batchGroupId?: string;
}
interface DatasetItemStreamRequest {
datasetName: string;
lastRetrievedId?: string;
steamLimit?: number;
datasetVersion?: string;
projectName?: string;
filters?: string;
}
/**
* @example
* {}
*/
interface DatasetItemsDelete {
/** List of dataset item IDs to delete (max 1000). Use this to delete specific items by their IDs. Mutually exclusive with 'dataset_id' and 'filters'. */
itemIds?: string[];
/** Dataset ID to scope the deletion. Required when using 'filters'. Mutually exclusive with 'item_ids'. */
datasetId?: string;
/** Filters to select dataset items to delete within the specified dataset. Must be used with 'dataset_id'. Mutually exclusive with 'item_ids'. Empty array means 'delete all items in the dataset'. */
filters?: DatasetItemFilter[];
/** Optional batch group ID to group multiple delete operations into a single dataset version. If null, mutates the latest version instead of creating a new one. */
batchGroupId?: string;
}
/**
* @example
* {
* name: "name"
* }
*/
interface DatasetUpdate {
name: string;
description?: string;
visibility?: DatasetUpdateVisibility;
tags?: string[];
}
/**
* @example
* {
* versionRef: "version_ref"
* }
*/
interface DatasetVersionRestorePublic {
/** Version hash or tag to restore from */
versionRef: string;
}
/**
* @example
* {
* versionName: "v1"
* }
*/
interface DatasetVersionRetrieveRequestPublic {
/** Version name in format 'vN' (e.g., 'v1', 'v373') */
versionName: string;
}
/**
* @example
* {
* tag: "tag"
* }
*/
interface DatasetVersionTag {
tag: string;
}
/**
* @example
* {}
*/
interface DatasetVersionUpdatePublic {
/** Optional description of changes in this version */
changeDescription?: string;
/** Optional list of tags to add to this version */
tagsToAdd?: string[];
}
/**
* @example
* {
* name: "name"
* }
*/
interface DatasetWrite {
id?: string;
name: string;
/** Project ID. Takes precedence over project_name when both are provided. */
projectId?: string;
/** For project scope, specify either project_id or project_name. If project_name is provided and the project does not exist, it will be created. Ignored when project_id is provided. If neither is provided, the dataset is created at workspace level. */
projectName?: string;
type?: DatasetWriteType;
visibility?: DatasetWriteVisibility;
tags?: string[];
description?: string;
}
/**
* @example
* {}
*/
type DeleteDatasetRequest = {};
/**
* @example
* {}
*/
type DeleteVersionTagRequest = {};
/**
* @example
* {}
*/
type DownloadDatasetExportRequest = {};
/**
* @example
* {
* experimentIds: "experiment_ids"
* }
*/
interface FindDatasetItemsWithExperimentItemsRequest {
page?: number;
size?: number;
experimentIds: string;
filters?: string;
sorting?: string;
search?: string;
truncate?: boolean;
}
/**
* @example
* {}
*/
interface FindDatasetsRequest {
page?: number;
size?: number;
withExperimentsOnly?: boolean;
withOptimizationsOnly?: boolean;
promptId?: string;
projectId?: string;
name?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
type GetDatasetByIdRequest = {};
/**
* @example
* {
* experimentIds: "experiment_ids"
* }
*/
interface GetDatasetExperimentItemsStatsRequest {
experimentIds: string;
filters?: string;
}
/**
* @example
* {}
*/
type GetDatasetExportJobRequest = {};
/**
* @example
* {}
*/
type GetDatasetItemByIdRequest = {};
/**
* @example
* {}
*/
interface GetDatasetItemsOutputColumnsRequest {
experimentIds?: string;
}
/**
* @example
* {}
*/
interface GetDatasetItemsRequest {
page?: number;
size?: number;
version?: string;
filters?: string;
truncate?: boolean;
}
/**
* @example
* {}
*/
interface ListDatasetVersionsRequest {
page?: number;
size?: number;
}
/**
* @example
* {}
*/
type MarkDatasetExportJobViewedRequest = {};
/**
* @example
* {
* body: {
* source: "manual",
* data: {
* "key": "value"
* }
* }
* }
*/
interface PatchDatasetItemRequest {
body: DatasetItemWrite;
}
/**
* @example
* {}
*/
type StartDatasetExportRequest = {};
declare const DatasetUpdateVisibility: {
readonly Private: "private";
readonly Public: "public";
};
type DatasetUpdateVisibility = (typeof DatasetUpdateVisibility)[keyof typeof DatasetUpdateVisibility];
declare const DatasetWriteType: {
readonly Dataset: "dataset";
readonly EvaluationSuite: "evaluation_suite";
};
type DatasetWriteType = (typeof DatasetWriteType)[keyof typeof DatasetWriteType];
declare const DatasetWriteVisibility: {
readonly Private: "private";
readonly Public: "public";
};
type DatasetWriteVisibility = (typeof DatasetWriteVisibility)[keyof typeof DatasetWriteVisibility];
/**
* @example
* {}
*/
interface EnvironmentUpdate {
name?: string;
description?: string;
color?: string;
position?: number;
}
/**
* @example
* {
* name: "name"
* }
*/
interface EnvironmentWrite {
id?: string;
name: string;
description?: string;
color?: string;
position?: number;
}
/**
* @example
* {}
*/
type GetEnvironmentByIdRequest = {};
/**
* @example
* {
* ids: ["ids"],
* update: {}
* }
*/
interface ExperimentBatchUpdate {
/** List of experiment IDs to update (max 1000) */
ids: string[];
update: ExperimentUpdate;
/** If true, merge tags with existing tags instead of replacing them. Default: false */
mergeTags?: boolean;
}
/**
* @example
* {
* datasetName: "dataset_name",
* prompts: [{
* model: "model",
* messages: [{
* role: "role",
* content: {
* "key": "value"
* }
* }]
* }],
* datasetId: "dataset_id"
* }
*/
interface ExperimentExecutionRequest {
datasetName: string;
datasetVersionId?: string;
prompts: PromptVariant[];
projectName?: string;
datasetId: string;
versionHash?: string;
promptVersions?: PromptVersionLink[];
}
/**
* @example
* {
* experimentName: "experiment_name",
* datasetName: "dataset_name",
* items: [{
* datasetItemId: "dataset_item_id"
* }]
* }
*/
interface ExperimentItemBulkUploadExperimentItemBulkWriteView {
experimentName: string;
datasetName: string;
/** Optional experiment ID. If provided, items will be added to the existing experiment and experimentName will be ignored. If not provided or experiment with that ID doesn't exist, a new experiment will be created with the given experimentName */
experimentId?: string;
items: ExperimentItemBulkRecordExperimentItemBulkWriteView[];
}
interface ExperimentItemStreamRequest {
experimentName: string;
limit?: number;
lastRetrievedId?: string;
/** Truncate image included in either input, output or metadata */
truncate?: boolean;
projectName?: string;
}
/**
* @example
* {
* experimentItems: [{
* experimentId: "experiment_id",
* datasetItemId: "dataset_item_id",
* traceId: "trace_id"
* }]
* }
*/
interface ExperimentItemsBatch {
experimentItems: ExperimentItem[];
}
/**
* @example
* {
* ids: ["ids"]
* }
*/
interface ExperimentItemsDelete {
ids: string[];
}
interface ExperimentStreamRequestPublic {
name: string;
limit?: number;
lastRetrievedId?: string;
projectName?: string;
}
/**
* @example
* {}
*/
interface ExperimentWrite {
id?: string;
datasetName: string | null;
/** Project ID. Takes precedence over project_name when both are provided. */
projectId?: string;
/** Project name. Creates project if it doesn't exist. Ignored when project_id is provided. */
projectName?: string;
name?: string;
metadata?: JsonListStringWrite;
tags?: string[];
type?: ExperimentWriteType;
evaluationMethod?: ExperimentWriteEvaluationMethod;
optimizationId?: string;
status?: ExperimentWriteStatus;
experimentScores?: ExperimentScoreWrite[];
promptVersion?: PromptVersionLinkWrite;
promptVersions?: PromptVersionLinkWrite[];
/** ID of the dataset version this experiment is linked to. If not provided at creation, experiment will be automatically linked to the latest version. */
datasetVersionId?: string;
}
/**
* @example
* {}
*/
interface FindExperimentGroupsAggregationsRequest {
groups?: string;
types?: string;
name?: string;
projectId?: string;
projectDeleted?: boolean;
filters?: string;
}
/**
* @example
* {}
*/
interface FindExperimentGroupsRequest {
groups?: string;
types?: string;
name?: string;
projectId?: string;
projectDeleted?: boolean;
filters?: string;
}
/**
* @example
* {}
*/
interface FindExperimentsRequest {
page?: number;
size?: number;
datasetId?: string;
optimizationId?: string;
types?: string;
name?: string;
datasetDeleted?: boolean;
promptId?: string;
projectId?: string;
projectDeleted?: boolean;
sorting?: string;
filters?: string;
experimentIds?: string;
forceSorting?: boolean;
}
/**
* @example
* {}
*/
interface FindFeedbackScoreNamesRequest {
experimentIds?: string;
projectId?: string;
}
/**
* @example
* {}
*/
type GetExperimentByIdRequest = {};
/**
* @example
* {}
*/
type GetExperimentItemByIdRequest = {};
/**
* @example
* {
* body: {}
* }
*/
interface UpdateExperimentRequest {
body: ExperimentUpdate;
}
declare const ExperimentWriteEvaluationMethod: {
readonly Dataset: "dataset";
readonly EvaluationSuite: "evaluation_suite";
};
type ExperimentWriteEvaluationMethod = (typeof ExperimentWriteEvaluationMethod)[keyof typeof ExperimentWriteEvaluationMethod];
declare const ExperimentWriteStatus: {
readonly Running: "running";
readonly Completed: "completed";
readonly Cancelled: "cancelled";
};
type ExperimentWriteStatus = (typeof ExperimentWriteStatus)[keyof typeof ExperimentWriteStatus];
declare const ExperimentWriteType: {
readonly Regular: "regular";
readonly Trial: "trial";
readonly MiniBatch: "mini-batch";
readonly Mutation: "mutation";
};
type ExperimentWriteType = (typeof ExperimentWriteType)[keyof typeof ExperimentWriteType];
/**
* @example
* {}
*/
type DeleteFeedbackDefinitionByIdRequest = {};
/**
* @example
* {}
*/
interface FindFeedbackDefinitionsRequest {
page?: number;
size?: number;
name?: string;
type?: FindFeedbackDefinitionsRequestType;
}
/**
* @example
* {}
*/
type GetFeedbackDefinitionByIdRequest = {};
/**
* @example
* {
* body: {
* type: "numerical",
* name: "string",
* description: "This feedback definition is used to rate response quality"
* }
* }
*/
interface UpdateFeedbackDefinitionRequest {
body: FeedbackUpdate;
}
declare const FindFeedbackDefinitionsRequestType: {
readonly Numerical: "numerical";
readonly Categorical: "categorical";
readonly Boolean: "boolean";
};
type FindFeedbackDefinitionsRequestType = (typeof FindFeedbackDefinitionsRequestType)[keyof typeof FindFeedbackDefinitionsRequestType];
/**
* @example
* {
* guardrails: [{
* entityId: "entity_id",
* secondaryId: "secondary_id",
* name: "TOPIC",
* result: "passed",
* config: {
* "key": "value"
* },
* details: {
* "key": "value"
* }
* }]
* }
*/
interface GuardrailBatchWrite {
guardrails: GuardrailWrite[];
}
/**
* @example
* {}
*/
type DeleteInsightsViewRequest = {};
/**
* @example
* {}
*/
interface FindInsightsViewsRequest {
page?: number;
size?: number;
name?: string;
projectId?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
type GetInsightsViewByIdRequest = {};
/**
* @example
* {
* body: {}
* }
*/
interface UpdateInsightsViewRequest {
body: DashboardUpdatePublic;
}
/**
* @example
* {}
*/
type GetLlmProviderApiKeyByIdRequest = {};
/**
* @example
* {}
*/
interface ProviderApiKeyUpdate {
apiKey?: string;
name?: string;
/** Provider name - can be set to migrate legacy custom LLM or Bedrock providers to the new multi-provider format. Once set, it cannot be changed. Should only be set for custom LLM and Bedrock providers. */
providerName?: string;
headers?: Record<string, string>;
configuration?: Record<string, string>;
baseUrl?: string;
}
/**
* @example
* {
* provider: "openai"
* }
*/
interface ProviderApiKeyWrite {
provider: ProviderApiKeyWriteProvider;
apiKey?: string;
name?: string;
/** Provider name - required for custom LLM and Bedrock providers to uniquely identify them (e.g., 'ollama', 'vllm', 'Bedrock us-east-1'). Must not be blank for custom and Bedrock providers. Should not be set for standard providers (OpenAI, Anthropic, etc.). This requirement is conditional and validation is enforced programmatically. */
providerName?: string;
headers?: Record<string, string>;
configuration?: Record<string, string>;
baseUrl?: string;
}
declare const ProviderApiKeyWriteProvider: {
readonly Openai: "openai";
readonly Anthropic: "anthropic";
readonly Gemini: "gemini";
readonly Openrouter: "openrouter";
readonly VertexAi: "vertex-ai";
readonly Bedrock: "bedrock";
readonly Ollama: "ollama";
readonly CustomLlm: "custom-llm";
readonly OpikFree: "opik-free";
};
type ProviderApiKeyWriteProvider = (typeof ProviderApiKeyWriteProvider)[keyof typeof ProviderApiKeyWriteProvider];
/**
* @example
* {}
*/
type CancelStudioOptimizationsRequest = {};
/**
* @example
* {}
*/
interface FindOptimizationsRequest {
page?: number;
size?: number;
datasetId?: string;
name?: string;
datasetName?: string;
datasetDeleted?: boolean;
projectId?: string;
filters?: string;
}
/**
* @example
* {}
*/
type GetOptimizationByIdRequest = {};
/**
* @example
* {}
*/
type GetStudioOptimizationLogsRequest = {};
/**
* @example
* {}
*/
interface OptimizationUpdate {
name?: string;
status?: OptimizationUpdateStatus;
}
declare const OptimizationUpdateStatus: {
readonly Running: "running";
readonly Completed: "completed";
readonly Cancelled: "cancelled";
readonly Initialized: "initialized";
readonly Error: "error";
};
type OptimizationUpdateStatus = (typeof OptimizationUpdateStatus)[keyof typeof OptimizationUpdateStatus];
/**
* @example
* {
* runnerName: "runner_name",
* hmac: "hmac"
* }
*/
interface ActivateRequest {
runnerName: string;
hmac: string;
}
/**
* @example
* {
* projectId: "project_id",
* activationKey: "activation_key",
* type: "connect"
* }
*/
interface CreateSessionRequest {
projectId: string;
activationKey: string;
ttlSeconds?: number;
type: CreateSessionRequestType;
}
declare const CreateSessionRequestType: {
readonly Connect: "connect";
readonly Endpoint: "endpoint";
};
type CreateSessionRequestType = (typeof CreateSessionRequestType)[keyof typeof CreateSessionRequestType];
/**
* @example
* {}
*/
type DeleteProjectByIdRequest = {};
/**
* @example
* {}
*/
interface FindAlertsByProjectRequest {
page?: number;
size?: number;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
interface FindDashboardsByProjectRequest {
page?: number;
size?: number;
name?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
interface FindDatasetsByProjectRequest {
page?: number;
size?: number;
withExperimentsOnly?: boolean;
withOptimizationsOnly?: boolean;
name?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
interface FindExperimentsByProjectRequest {
page?: number;
size?: number;
datasetId?: string;
optimizationId?: string;
types?: string;
name?: string;
datasetDeleted?: boolean;
sorting?: string;
filters?: string;
experimentIds?: string;
forceSorting?: boolean;
}
/**
* @example
* {}
*/
interface FindFeedbackScoreNamesByProjectIdsRequest {
projectIds?: string;
}
/**
* @example
* {}
*/
interface FindOptimizationsByProjectRequest {
page?: number;
size?: number;
datasetId?: string;
datasetName?: string;
name?: string;
datasetDeleted?: boolean;
filters?: string;
}
/**
* @example
* {}
*/
interface FindProjectsRequest {
page?: number;
size?: number;
name?: string;
sorting?: string;
}
/**
* @example
* {}
*/
type FindTokenUsageNamesRequest = {};
/**
* @example
* {}
*/
type GetProjectByIdRequest = {};
/**
* @example
* {}
*/
interface GetProjectStatsRequest {
page?: number;
size?: number;
name?: string;
filters?: string;
sorting?: string;
}
/**
* @example
* {}
*/
interface GetPromptsByProjectRequest {
page?: number;
size?: number;
name?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
interface GetRecentActivityRequest {
page?: number;
size?: number;
}
/**
* @example
* {
* entityType: "traces",
* intervalStart: new Date("2024-01-15T09:30:00.000Z")
* }
*/
interface KpiCardRequest {
entityType: KpiCardRequestEntityType;
filters?: string;
intervalStart: Date;
intervalEnd?: Date;
}
/**
* @example
* {}
*/
interface ProjectMetricRequestPublic {
metricType?: ProjectMetricRequestPublicMetricType;
interval?: ProjectMetricRequestPublicInterval;
intervalStart?: Date;
intervalEnd?: Date;
spanFilters?: SpanFilterPublic[];
traceFilters?: TraceFilterPublic[];
threadFilters?: TraceThreadFilterPublic[];
breakdown?: BreakdownConfigPublic;
}
/**
* @example
* {
* name: "name"
* }
*/
interface ProjectRetrieveDetailed {
name: string;
}
/**
* @example
* {}
*/
interface ProjectUpdate {
name?: string;
description?: string;
visibility?: ProjectUpdateVisibility;
}
/**
* @example
* {
* name: "name"
* }
*/
interface ProjectWrite {
name: string;
visibility?: ProjectWriteVisibility;
description?: string;
}
declare const KpiCardRequestEntityType: {
readonly Traces: "traces";
readonly Spans: "spans";
readonly Threads: "threads";
};
type KpiCardRequestEntityType = (typeof KpiCardRequestEntityType)[keyof typeof KpiCardRequestEntityType];
declare const ProjectMetricRequestPublicInterval: {
readonly Hourly: "HOURLY";
readonly Daily: "DAILY";
readonly Weekly: "WEEKLY";
readonly Total: "TOTAL";
};
type ProjectMetricRequestPublicInterval = (typeof ProjectMetricRequestPublicInterval)[keyof typeof ProjectMetricRequestPublicInterval];
declare const ProjectMetricRequestPublicMetricType: {
readonly FeedbackScores: "FEEDBACK_SCORES";
readonly TraceCount: "TRACE_COUNT";
readonly TokenUsage: "TOKEN_USAGE";
readonly Duration: "DURATION";
readonly Cost: "COST";
readonly GuardrailsFailedCount: "GUARDRAILS_FAILED_COUNT";
readonly ThreadCount: "THREAD_COUNT";
readonly ThreadDuration: "THREAD_DURATION";
readonly ThreadFeedbackScores: "THREAD_FEEDBACK_SCORES";
readonly SpanFeedbackScores: "SPAN_FEEDBACK_SCORES";
readonly SpanCount: "SPAN_COUNT";
readonly SpanDuration: "SPAN_DURATION";
readonly SpanTokenUsage: "SPAN_TOKEN_USAGE";
readonly TraceAverageDuration: "TRACE_AVERAGE_DURATION";
readonly TraceErrorRate: "TRACE_ERROR_RATE";
readonly SpanAverageDuration: "SPAN_AVERAGE_DURATION";
readonly SpanCost: "SPAN_COST";
readonly SpanErrorRate: "SPAN_ERROR_RATE";
readonly ThreadAverageDuration: "THREAD_AVERAGE_DURATION";
readonly ThreadCost: "THREAD_COST";
};
type ProjectMetricRequestPublicMetricType = (typeof ProjectMetricRequestPublicMetricType)[keyof typeof ProjectMetricRequestPublicMetricType];
declare const ProjectUpdateVisibility: {
readonly Private: "private";
readonly Public: "public";
};
type ProjectUpdateVisibility = (typeof ProjectUpdateVisibility)[keyof typeof ProjectUpdateVisibility];
declare const ProjectWriteVisibility: {
readonly Private: "private";
readonly Public: "public";
};
type ProjectWriteVisibility = (typeof ProjectWriteVisibility)[keyof typeof ProjectWriteVisibility];
/**
* @example
* {
* name: "name",
* version: {
* template: "template"
* }
* }
*/
interface CreatePromptVersionDetail {
name: string;
version: PromptVersionDetail;
/** Template structure for the prompt: 'text' or 'chat'. Note: This field is only used when creating a new prompt. If a prompt with the given name already exists, this field is ignored and the existing prompt's template structure is used. Template structure is immutable after prompt creation. */
templateStructure?: CreatePromptVersionDetailTemplateStructure;
/** Project ID. Takes precedence over project_name when both are provided. */
projectId?: string;
/** If provided, scopes the prompt to the specified project. Ignored when project_id is provided. */
projectName?: string;
}
/**
* @example
* {}
*/
type DeletePromptRequest = {};
/**
* @example
* {}
*/
type GetPromptByCommitRequest = {};
/**
* @example
* {}
*/
interface GetPromptByIdRequest {
/** Optional mask version id; when set, requestedVersion is the mask row for that id */
maskId?: string;
/** Optional environment name; when set, requestedVersion is the version mapped to that environment for the prompt */
environment?: string;
}
/**
* @example
* {}
*/
interface GetPromptsRequest {
page?: number;
size?: number;
name?: string;
projectId?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {}
*/
type GetPromptVersionByIdRequest = {};
/**
* @example
* {}
*/
type GetPromptVersionByNumberRequest = {};
/**
* @example
* {}
*/
interface GetPromptVersionsRequest {
page?: number;
size?: number;
/** Search text to find in template or change description fields */
search?: string;
sorting?: string;
filters?: string;
}
/**
* @example
* {
* name: "name"
* }
*/
interface PromptUpdatable {
name: string;
description?: string;
tags?: string[];
}
/**
* @example
* {
* ids: ["ids"],
* update: {}
* }
*/
interface PromptVersionBatchUpdate {
/** IDs of prompt versions to update */
ids: string[];
update: PromptVersionUpdate;
/**
* Tag merge behavior:
* - true: Add new tags to existing tags (union)
* - false: Replace all existing tags with new tags (default behaviour if not provided)
*/
mergeTags?: boolean;
}
/**
* @example
* {
* commits: ["commits"]
* }
*/
interface PromptVersionCommitsRequestPublic {
commits: string[];
}
/**
* @example
* {}
*/
interface PromptVersionEnvironmentUpdate {
environment?: string;
}
/**
* @example
* {
* ids: ["ids"]
* }
*/
interface PromptVersionIdsRequestDetail {
ids: string[];
}
/**
* @example
* {
* name: "name"
* }
*/
interface PromptVersionRetrieveDetail {
name: string;
commit?: string;
/** If provided, resolves to the version mapped to this environment for the prompt; mutually exclusive with commit and version_number */
environment?: string;
/** If provided, resolves to the version with this sequential number (e.g. v3); mutually exclusive with commit and environment */
versionNumber?: string;
/** If provided, scopes the search to the specified project */
projectName?: string;
}
/**
* @example
* {
* name: "name"
* }
*/
interface PromptWrite {
id?: string;
name: string;
/** Project ID. Takes precedence over project_name when both are provided. */
projectId?: string;
/** For project scope, specify either project_id or project_name. If project_name is provided and the project does not exist, it will be created. Ignored when project_id is provided. If neither is provided, the prompt is created at workspace level. */
projectName?: string;
description?: string;
template?: string;
metadata?: JsonNodeWrite;
changeDescription?: string;
type?: PromptWriteType;
/** Template structure type: 'text' or 'chat'. Immutable after creation. */
templateStructure?: PromptWriteTemplateStructure;
tags?: string[];
}
/**
* @example
* {}
*/
type RestorePromptVersionRequest = {};
/** Template structure for the prompt: 'text' or 'chat'. Note: This field is only used when creating a new prompt. If a prompt with the given name already exists, this field is ignored and the existing prompt's template structure is used. Template structure is immutable after prompt creation. */
declare const CreatePromptVersionDetailTemplateStructure: {
readonly Text: "text";
readonly Chat: "chat";
};
type CreatePromptVersionDetailTemplateStructure = (typeof CreatePromptVersionDetailTemplateStructure)[keyof typeof CreatePromptVersionDetailTemplateStructure];
/** Template structure type: 'text' or 'chat'. Immutable after creation. */
declare const PromptWriteTemplateStructure: {
readonly Text: "text";
readonly Chat: "chat";
};
type PromptWriteTemplateStructure = (typeof PromptWriteTemplateStructure)[keyof typeof PromptWriteTemplateStructure];
declare const PromptWriteType: {
readonly Mustache: "mustach