Skip to main content
This guide shows how to pull a prompt into your code and use it to prompt an LLM. Before you start, tag a prompt version as ready (for example, “staging”).
Phoenix treats prompts as code, but stores them outside your codebase. This has these effects on your application:Key Implementation Impacts
  • Your application must use the network to get prompts.
  • Debugging is more complex.
  • Your application depends on an external system.
Current StatusThe Phoenix team is adding safeguards to decrease these risks:
  • Caching mechanisms
  • Fallback systems
Best PracticesIf you use Phoenix prompts in your application, do these steps:
  1. Implement robust caching.
  2. Implement fallback mechanisms.
  3. Examine the effect on the reliability requirements of your application.
To give feedback on these improvements, open an issue: https://github.com/Arize-ai/phoenix/issues/6290
Install the phoenix client library. For Python:
For JavaScript / TypeScript:

Pulling a prompt

You can pull a prompt in three ways: by name or ID (latest version), by version, or by tag.

Pulling a prompt by Name or ID

Pull a prompt by its name or ID (the identifier) to get the latest version of the prompt. This is the easiest method. A name or ID does not identify a specific version, so you always get the latest version. Thus, use this method only during development.
Prompt names and IDs are synonymous.

Pulling a prompt by Version ID

Pull a prompt by version ID to get the content of a prompt at a specific point in time. A version cannot change and you cannot delete it. Thus, you can use it in production-like use cases.
Phoenix saved prompt showing its version identifier

The ID of a specific prompt version can be found in the prompt history.

Pulling a prompt by Tag

Pull a prompt by tag to use a specific prompt version automatically in an environment (for example, “staging”). Before you pull by tag, Tag a prompt in the UI.
Phoenix saved prompt showing its assigned tag

You can control the prompt version tags in the UI.

Tags are unique per prompt. Thus, you must pair the tag with the prompt_identifier.
To update a prompt pulled by tag in your application, move the “staging” tag to a different prompt version. Your application then gets the new version automatically.

Using a prompt

Use the Phoenix client to format the prompt with variables. The client gives the messages, model information, tools, and response format (if applicable). The Phoenix client libraries transform prompts to the format of your SDK. You do not need a proxy.
The Python and TypeScript SDKs can transform your prompts to these SDKs. You do not need a proprietary SDK.
  • Python - OpenAI, Anthropic, Gemini
  • TypeScript - OpenAI, Anthropic, and the Vercel AI SDK