Client class is the primary interface for interacting with the LangSmith API. It handles tracing, datasets, experiments, feedback, and all other LangSmith features.
Constructor
Configuration options for the client
ClientConfig properties
ClientConfig properties
Your LangSmith API key. Defaults to
LANGSMITH_API_KEY environment variable.The LangSmith API URL. Defaults to
https://api.smith.langchain.com.The LangSmith web UI URL. Auto-detected from apiUrl if not provided.
The workspace ID. Required for org-scoped API keys.
Request timeout in milliseconds.
Whether to hide run inputs. Can be a boolean or function to transform inputs.
Whether to hide run outputs. Can be a boolean or function to transform outputs.
Whether to omit runtime information (SDK version, platform, etc.) from traced runs.
Whether to automatically batch trace uploads.
Maximum size of a batch of runs in bytes.
Maximum number of operations to batch in a single request.
Maximum total memory (in bytes) for both the AutoBatchQueue and batchIngestCaller queue. Defaults to 1GB.
Whether to block on root run finalization. Set to true for synchronous tracing.
Number of concurrent batch trace uploads.
Whether to require manual .flush() calls before sending traces. Useful for serverless environments.
Sampling rate for tracing (0.0 to 1.0). Samples at the trace level.
Enable debug mode. If set, all sent HTTP requests will be logged.
Disable prompt caching for this client.
Custom fetch options for HTTP requests.
Methods
createRun()
Create a new run (trace or span).The run parameters
CreateRunParams properties
CreateRunParams properties
A human-readable name for the run.
The inputs that were used to initiate the run.
The type of run (e.g., “llm”, “chain”, “tool”, “retriever”).
Unique identifier for the run. Auto-generated if not provided.
The epoch time at which the run started.
The epoch time at which the run ended.
Outputs produced by the run.
Error message if the run failed.
The name of the project/session.
ID of the parent run if this is a child run.
Unique ID assigned to every run within this nested trace.
ID of an example that might be related to this run.
Tags for categorizing the run.
Additional metadata or settings for the run.
updateRun()
Update an existing run.flush()
Flush current queued traces immediately.createProject()
Create a new project.CreateProjectParams properties
CreateProjectParams properties
The name of the project.
A description of the project.
Extra metadata for the project.
If true, update the project if it already exists.
The reference dataset ID this project’s runs were generated on.
createDataset()
Create a new dataset.createExample()
Create an example in a dataset.listRuns()
List runs from a project with filtering.ListRunsParams properties
ListRunsParams properties
The ID or IDs of the project(s) to filter by.
The name or names of the project(s) to filter by.
The ID of the trace to filter by.
Whether to only include root runs.
The run type to filter by (e.g., “llm”, “chain”).
Filter by error runs.
The maximum number of runs to retrieve.
Filter query string using LangSmith’s filter language. Supports comparators like eq, neq, gt, gte, lt, lte, has, and search.
The start time to filter by.
createFeedback()
Create feedback for a run.getPrompt()
Retrieve a prompt from the LangSmith Hub.Static methods
getDefaultClientConfig()
Get the default client configuration from environment variables.API URL from
LANGSMITH_ENDPOINT or default.API key from
LANGSMITH_API_KEY.Whether to hide inputs from
LANGSMITH_HIDE_INPUTS.Whether to hide outputs from
LANGSMITH_HIDE_OUTPUTS.