LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
  • RemoteGraph
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDKRemoteGraph
Language
Theme
Pythonlangsmithasync_clientAsyncClient
Class●Since v0.1

AsyncClient

Async Client for interacting with the LangSmith API.

Copy
AsyncClient(
  self,
  api_url: Optional[str] = None,
  api_key: Optional[str] = None,
  timeout_ms: Optional[Union[int, tuple[Optional[int], Optional[int], Optional[int], Optional[int]]]] = None,
  retry_config: Optional[Mapping[str, Any]] = None,
  web_url: Optional[str] = None,
  disable_prompt_cache: bool = False,
  cache: Optional[Union[bool, AsyncPromptCache]] = None
)

Parameters

NameTypeDescription
api_urlOptional[str]
Default:None

URL for the LangSmith API.

api_keyOptional[str]
Default:None

API key for the LangSmith API.

timeout_msOptional[Union[int, tuple[Optional[int], Optional[int], Optional[int], Optional[int]]]]
Default:None

Timeout for requests in milliseconds.

retry_configOptional[Mapping[str, Any]]
Default:None

Retry configuration.

web_urlOptional[str]
Default:None

URL for the LangSmith web app.

disable_prompt_cachebool
Default:False

Disable prompt caching for this client.

cacheOptional[Union[bool, AsyncPromptCache]]
Default:None

[Deprecated] Control prompt caching behavior.

This parameter is deprecated. Use configure_global_async_prompt_cache() to configure caching, or disable_prompt_cache=True to disable it.

  • True: Enable caching with the global singleton
  • False: Disable caching (equivalent to disable_prompt_cache=True)
  • AsyncCache(...)/AsyncPromptCache(...): Use a custom cache instance

Constructors

constructor
__init__
NameType
api_urlOptional[str]
api_keyOptional[str]
timeout_msOptional[Union[int, tuple[Optional[int], Optional[int], Optional[int], Optional[int]]]]
retry_configOptional[Mapping[str, Any]]
web_urlOptional[str]
disable_prompt_cachebool
cacheOptional[Union[bool, AsyncPromptCache]]

Methods

method
aclose

Close the async client.

method
create_run

Create a run.

method
update_run

Update a run.

method
read_run

Read a run.

method
list_runs

List runs from the LangSmith API.

method
share_run

Get a share link for a run asynchronously.

method
run_is_shared

Get share state for a run asynchronously.

method
read_run_shared_link

Retrieve the shared link for a specific run asynchronously.

method
create_project

Create a project.

method
read_project

Read a project.

method
delete_project

Delete a project from LangSmith.

method
create_dataset

Create a dataset.

method
read_dataset

Read a dataset.

method
delete_dataset

Delete a dataset.

method
list_datasets

List datasets.

method
create_example

Create an example.

method
read_example

Read an example.

method
list_examples

List examples.

method
create_feedback

Create feedback for a run.

method
create_feedback_from_token

Create feedback from a presigned token or URL.

method
create_presigned_feedback_token

Create a pre-signed URL to send feedback data to.

This is useful for giving browser-based clients a way to upload feedback data directly to LangSmith without accessing the API key.

method
read_feedback

Read feedback.

method
list_feedback

List feedback.

method
delete_feedback

Delete a feedback by ID.

method
list_annotation_queues

List the annotation queues on the LangSmith API.

method
create_annotation_queue

Create an annotation queue on the LangSmith API.

method
read_annotation_queue

Read an annotation queue with the specified queue_id.

method
update_annotation_queue

Update an annotation queue with the specified queue_id.

method
delete_annotation_queue

Delete an annotation queue with the specified queue_id.

method
add_runs_to_annotation_queue

Add runs to an annotation queue with the specified queue_id.

method
delete_run_from_annotation_queue

Delete a run from an annotation queue with the specified queue_id and run_id.

method
get_run_from_annotation_queue

Get a run from an annotation queue at the specified index.

method
create_feedback_config

Create a feedback configuration.

Defines how feedback with a given key should be interpreted. If an identical configuration already exists for the key, it is returned unchanged. If a different configuration already exists for the key, an error is raised.

method
list_feedback_configs

List feedback configurations.

method
update_feedback_config

Update a feedback configuration.

Only the provided fields will be updated; others remain unchanged.

method
delete_feedback_config

Delete a feedback configuration.

This performs a soft delete. The configuration can be recreated later with the same key.

method
index_dataset

Enable dataset indexing. Examples are indexed by their inputs.

This enables searching for similar examples by inputs with client.similar_examples().

method
sync_indexed_dataset

Sync dataset index.

This already happens automatically every 5 minutes, but you can call this to force a sync.

method
similar_examples

Retrieve the dataset examples whose inputs best match the current inputs.

Note

Must have few-shot indexing enabled for the dataset. See client.index_dataset().

method
like_prompt

Like a prompt.

method
unlike_prompt

Unlike a prompt.

method
list_prompts

List prompts with pagination.

method
get_prompt

Get a specific prompt by its identifier.

method
create_prompt

Create a new prompt.

Does not attach prompt object, just creates an empty prompt.

method
create_commit

Create a commit for an existing prompt.

method
update_prompt

Update a prompt's metadata.

To update the content of a prompt, use push_prompt or create_commit instead.

method
delete_prompt

Delete a prompt.

method
pull_prompt_commit

Pull a prompt object from the LangSmith API.

method
list_prompt_commits

List commits for a given prompt.

method
pull_prompt

Pull a prompt and return it as a LangChain PromptTemplate.

This method requires langchain-core.

method
push_prompt

Push a prompt to the LangSmith API.

Can be used to update prompt metadata or prompt content.

If the prompt does not exist, it will be created.

If the prompt exists, it will be updated.

View source on GitHub