Skip to main content
The LangSmith SDK provides comprehensive TypeScript types for all API interactions.

Core types

Run

Represents a traced execution (root trace or span).
interface Run extends BaseRun {
  id: string;
  session_id?: string;
  child_run_ids?: string[];
  child_runs?: Run[];
  feedback_stats?: KVMap;
  app_path?: string;
  status?: string;
  prompt_tokens?: number;
  completion_tokens?: number;
  total_tokens?: number;
}

BaseRun

Base properties for all runs.
interface BaseRun {
  id?: string;
  name: string;
  start_time?: number | string;
  run_type: string;
  end_time?: number | string;
  extra?: KVMap;
  error?: string;
  serialized?: object;
  events?: KVMap[];
  inputs: KVMap;
  outputs?: KVMap;
  reference_example_id?: string;
  parent_run_id?: string;
  tags?: string[];
  trace_id?: string;
  dotted_order?: string;
  attachments?: Attachments;
}

RunCreate

Parameters for creating a new run.
interface RunCreate extends BaseRun {
  revision_id?: string;
  child_runs?: RunCreate[];
  session_name?: string;
}

RunUpdate

Parameters for updating an existing run.
interface RunUpdate {
  id?: string;
  name?: string;
  run_type?: string;
  start_time?: number | string;
  end_time?: number | string;
  extra?: KVMap;
  tags?: string[];
  error?: string;
  serialized?: object;
  inputs?: KVMap;
  outputs?: KVMap;
  parent_run_id?: string;
  reference_example_id?: string;
  events?: KVMap[];
  session_id?: string;
  session_name?: string;
  trace_id?: string;
  dotted_order?: string;
  attachments?: Attachments;
}

Dataset types

Dataset

Represents a dataset in LangSmith.
interface Dataset extends BaseDataset {
  id: string;
  created_at: string;
  modified_at: string;
  example_count?: number;
  session_count?: number;
  last_session_start_time?: number;
}

BaseDataset

interface BaseDataset {
  name: string;
  description: string;
  tenant_id: string;
  data_type?: DataType;
  inputs_schema_definition?: KVMap;
  outputs_schema_definition?: KVMap;
}

Example

Represents an example in a dataset.
interface Example extends BaseExample {
  id: string;
  created_at: string;
  modified_at?: string;
  source_run_id?: string;
  runs: Run[];
  attachments?: Record<string, AttachmentInfo>;
  split?: string | string[];
}

ExampleCreate

Parameters for creating an example.
interface ExampleCreate {
  id?: string;
  inputs: KVMap;
  outputs?: KVMap;
  metadata?: KVMap;
  split?: string | string[];
  attachments?: Attachments;
  created_at?: string;
  dataset_id?: string;
  dataset_name?: string;
  source_run_id?: string;
  use_source_run_io?: boolean;
  use_source_run_attachments?: string[];
}

Feedback types

Feedback

Represents feedback on a run.
interface Feedback extends FeedbackBase {
  id: string;
}

FeedbackBase

interface FeedbackBase {
  created_at: string;
  modified_at: string;
  run_id: string;
  key: string;
  score: ScoreType;
  value: ValueType;
  comment: string | null;
  correction: string | object | null;
  feedback_source: APIFeedbackSource | ModelFeedbackSource | KVMap | null;
}

FeedbackConfig

Configuration for how feedback should be interpreted.
interface FeedbackConfig {
  type: "continuous" | "categorical" | "freeform";
  min?: number | null;
  max?: number | null;
  categories?: FeedbackCategory[] | null;
}

FeedbackCategory

interface FeedbackCategory {
  value: number;
  label?: string | null;
}

Project types

TracerSession

Represents a project/session.
interface TracerSession {
  tenant_id: string;
  id: string;
  start_time: number;
  end_time?: number;
  description?: string;
  name?: string;
  extra?: KVMap;
  reference_dataset_id?: string;
}

TracerSessionResult

Project with additional statistics.
interface TracerSessionResult extends TracerSession {
  run_count?: number;
  latency_p50?: number;
  latency_p99?: number;
  total_tokens?: number;
  prompt_tokens?: number;
  completion_tokens?: number;
  last_run_start_time?: number;
  feedback_stats?: Record<string, unknown>;
  run_facets?: KVMap[];
}

Invocation parameters

InvocationParamsSchema

Standardized parameters for LLM invocations.
interface InvocationParamsSchema {
  ls_provider?: string;
  ls_model_name?: string;
  ls_model_type: "chat" | "llm";
  ls_temperature?: number;
  ls_max_tokens?: number;
  ls_stop?: string[];
  ls_invocation_params?: Record<string, unknown>;
}

Utility types

KVMap

Generic key-value map.
type KVMap = Record<string, any>;

ScoreType

Valid score types for feedback.
type ScoreType = number | boolean | null;

ValueType

Valid value types for feedback.
type ValueType = number | boolean | string | object | null;

DataType

Dataset data types.
type DataType = "kv" | "llm" | "chat";

RunType

Common run types (deprecated - use strings instead).
type RunType =
  | "llm"
  | "chain"
  | "tool"
  | "retriever"
  | "embedding"
  | "prompt"
  | "parser";

Attachment types

Attachments

Attachments for runs or examples.
type Attachments = Record<
  string,
  [string, AttachmentData] | AttachmentDescription
>;

AttachmentData

type AttachmentData = Uint8Array | ArrayBuffer;

AttachmentDescription

type AttachmentDescription = {
  mimeType: string;
  data: AttachmentData;
};

AttachmentInfo

Attachment metadata from the API.
interface AttachmentInfo {
  presigned_url: string;
  mime_type?: string;
}

Prompt types

Prompt

Represents a prompt from the LangSmith Hub.
interface Prompt {
  id: string;
  repo_handle: string;
  description: string | null;
  readme: string | null;
  num_likes: number;
  num_downloads: number;
  num_views: number;
  liked_by_auth_user: boolean;
  last_committed_at: string;
  num_commits: number;
  original_repo_id: string | null;
  original_repo_full_name: string | null;
  is_public: boolean;
  is_archived: boolean;
  tags: string[];
}

PromptCommit

A specific version of a prompt.
interface PromptCommit {
  owner: string;
  repo: string;
  commit_hash: string;
  manifest: Record<string, any>;
  examples: any[];
}

Comparative evaluation types

ComparativeExperiment

Represents a comparative experiment.
interface ComparativeExperiment {
  id: string;
  name: string;
  description: string;
  tenant_id: string;
  created_at: string;
  modified_at: string;
  reference_dataset_id: string;
  extra?: Record<string, unknown>;
  experiments_info?: Array<Record<string, unknown>>;
  feedback_stats?: Record<string, unknown>;
}

ComparisonEvaluationResult

Result from a comparative evaluator.
interface ComparisonEvaluationResult {
  key: string;
  scores: Record<string, ScoreType>;
  source_run_id?: string;
}

Retriever output type

RetrieverOutput

Expected output schema for retriever runs.
type RetrieverOutput = Array<{
  page_content: string;
  type: "Document";
  metadata?: KVMap;
}>;

Example usage

import type {
  Run,
  RunCreate,
  Example,
  Feedback,
  InvocationParamsSchema,
  KVMap,
} from "langsmith";

const runCreate: RunCreate = {
  name: "my-chain",
  run_type: "chain",
  inputs: { query: "Hello" },
  outputs: { response: "Hi!" },
  tags: ["production"],
};

const invocationParams: InvocationParamsSchema = {
  ls_provider: "openai",
  ls_model_type: "chat",
  ls_model_name: "gpt-4",
  ls_temperature: 0.7,
  ls_max_tokens: 1000,
};

Build docs developers (and LLMs) love