or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/langsmith@0.4.x

docs

index.md
tile.json

tessl/npm-langsmith

tessl install tessl/npm-langsmith@0.4.3

TypeScript client SDK for the LangSmith LLM tracing, evaluation, and monitoring platform.

client.mddocs/api/

Client API Overview

The Client class provides programmatic access to the LangSmith platform. This page provides an overview and links to detailed sections.

Overview

The Client class provides methods for:

  • Client Construction & Configuration - Create and configure clients
  • Project Management - Manage projects and sessions
  • Run Management - Create, query, and manage runs
  • Dataset Operations - Create and manage datasets
  • Example Management - Manage examples within datasets
  • Feedback Operations - Collect and analyze feedback
  • Prompt Management - Version control prompts

Quick Start

import { Client } from "langsmith";

// Create client (uses environment variables)
const client = new Client();

// Create client with explicit configuration
const client = new Client({
  apiUrl: "https://api.smith.langchain.com",
  apiKey: process.env.LANGCHAIN_API_KEY,
  timeout_ms: 10000
});

API Sections

Client Core

Client Construction & Configuration

Client setup, configuration options, and utility methods:

  • Constructor and configuration
  • Default configuration
  • Privacy controls
  • Batching and performance settings

Project Operations

Project Management

Organize traces into projects:

  • Create, read, update, delete projects
  • List and filter projects
  • Project URLs
  • Check existence

Run Operations

Run Management

Manage traces and execution data:

  • Create and update runs
  • List and filter runs
  • Advanced filtering
  • Share runs
  • Get run statistics

Dataset Operations

Dataset Management

Create and manage test datasets:

  • Create, read, update, delete datasets
  • Dataset versioning
  • Dataset sharing
  • Compare versions
  • CSV upload

Example Operations

Example Management

Manage examples within datasets:

  • Create and update examples
  • Bulk operations
  • List and filter examples
  • Multipart upload
  • Similarity search

Feedback Operations

Feedback Collection

Collect and analyze feedback:

  • Create and update feedback
  • List and filter feedback
  • Presigned feedback tokens
  • Evaluation feedback logging

Prompt Operations

Prompt Management

Version control and share prompts:

  • Create and delete prompts
  • Push and pull prompt versions
  • List commits
  • Like/unlike prompts
  • Check existence

Type Reference

Type Definitions

Complete TypeScript type definitions for all entities.

Common Patterns

Client Lifecycle

import { Client } from "langsmith";

const client = new Client();

// Use client for operations
await client.createProject({ projectName: "my-project" });

// Ensure traces are uploaded
await client.awaitPendingTraceBatches();

// Cleanup resources
client.cleanup();

Error Handling

import { Client } from "langsmith";

const client = new Client();

try {
  const run = await client.readRun(runId);
} catch (error) {
  if (error.status === 404) {
    console.error("Run not found");
  } else if (error.status === 401) {
    console.error("Authentication failed");
  } else {
    console.error("API error:", error.message);
  }
}

Pagination

// Async iteration handles pagination automatically
for await (const run of client.listRuns({
  projectName: "my-project",
  limit: 100
})) {
  console.log(run.name);
}

Related Documentation