Prerequisites
Before you begin, make sure you have:- A LangSmith account: Sign up or log in at smith.langchain.com.
- A LangSmith API key: Follow the Create an API key guide.
- An OpenAI API key: Generate this from the OpenAI dashboard.
- UI
- SDK
1. Set workspace secret
在 LangSmith UI 中,确保您的 API 密钥已设置为工作区密钥。- 导航到 设置,然后转到 密钥 选项卡。
- 选择 添加密钥,输入密钥环境变量(例如,
OPENAI_API_KEY或ANTHROPIC_API_KEY)和您的 API 密钥作为值。 - 选择 保存密钥。
在 LangSmith UI 中添加工作区密钥时,请确保密钥名称与您的模型提供商预期的环境变量名称匹配。
2. Create a prompt
- In the LangSmith UI, navigate to the Prompts section in the left-hand menu.
- Click on + Prompt to create a prompt.
- Modify the prompt by editing or adding prompts and input variables as needed.

3. Test a prompt
- Under the Prompts heading select the gear icon next to the model name, which will launch the Prompt Settings window on the Model Configuration tab.
-
Set the model configuration you want to use. The Provider and Model you select will determine the parameters that are configurable on this configuration page. Once set, click Save as.

-
Specify the input variables you would like to test in the Inputs box and then click Start.
To learn about more options for configuring your prompt in the Playground, refer to Configure prompt settings.

- After testing and refining your prompt, click Save to store it for future use.
4. Iterate on a prompt
LangSmith allows for team-based prompt iteration. Workspace members can experiment with prompts in the Playground and save their changes as a new commit when ready.To improve your prompts:- Reference the documentation provided by your model provider for best practices in prompt creation, such as:
- Build and refine your prompts with the Prompt Canvas—an interactive tool in LangSmith. Learn more in the Prompt Canvas guide.
- Tag specific commits to mark important moments in your commit history.
- To create a commit, navigate to the Playground and select Commit. Choose the prompt to commit changes to and then Commit.
- Navigate to Prompts in the left-hand menu. Select the prompt. On the prompt detail page, select Tag on the top right to add a commit tag.
Next steps
- Learn more about how to store and manage prompts using the Prompt Hub in the Create a prompt guide.
- Learn how to set up the Playground to Test multi-turn conversations in this tutorial.
- Learn how to test your prompt’s performance over a dataset instead of individual examples, refer to Run an evaluation from the Playground.
Use Polly in the Playground to help optimize your prompts, generate tools, and create output schemas.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.




