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
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
Pythonlangsmithasync_clientAsyncClientpull_prompt
Methodā—Since v0.3

pull_prompt

Copy
pull_prompt(
  self,
  prompt_identifier: str,
  *,
  include_model: bool | None = False,
View source on GitHub
secrets
:
dict
[
str
,
str
]
|
None
=
None
,
secrets_from_env
:
bool
=
False
,
skip_cache
:
bool
=
False
,
dangerously_pull_public_prompt
:
bool
=
False
)
->
Any

Parameters

NameTypeDescription
prompt_identifier*str

The identifier of the prompt.

include_modelbool | None
Default:False

Whether to include model configuration in the loaded prompt.

secretsdict[str, str] | None
Default:None
secrets_from_envbool
Default:False
skip_cachebool
Default:False
dangerously_pull_public_promptbool
Default:False

Pull a prompt and return it as a LangChain PromptTemplate.

This method requires langchain-core.

Security note

Pulled prompts should be treated as executable configuration, not plain text.

The secrets and secrets_from_env arguments only control explicit serialized LangChain secret references in the manifest. They do not prevent deserialized model integrations from using their own environment-based credential defaults during initialization. For example, a deserialized OpenAI chat model may still use OPENAI_API_KEY from the environment if its constructor supports that default.

Avoid pulling public prompts or prompts outside your own organization unless you have reviewed and trust their contents. When you do pull a trusted external prompt, prefer pinning to a specific commit SHA rather than following a mutable latest version. This is especially important when include_model=True.

Behavior changed in langsmith 0.5.1

Updated to take arguments secrets and secrets_from_env which default to None and False, respectively.

By default, explicit serialized LangChain secret references in a pulled manifest are not resolved from environment variables unless you specify secrets_from_env=True.

These updates were made to remediate vulnerability GHSA-c67j-w6g6-q2cm in the langchain-core package which this method (but not the entire langsmith package) depends on.

A map of secrets to use for explicit serialized LangChain secret references in the manifest, e.g. {'OPENAI_API_KEY': 'sk-...'}.

If a manifest secret reference is not found in the map, it will be loaded from the environment only if secrets_from_env is True. Deserialized model integrations may still use their own environment-based credential defaults during initialization.

Whether explicit serialized LangChain secret references in the manifest may be loaded from environment variables during deserialization.

Whether to skip the prompt cache. Defaults to False.

Set to True to allow pulling a public prompt by owner/name (for example, username/promptname). Only do this for trusted prompts. Defaults to False.