> ## Documentation Index
> Fetch the complete documentation index at: https://arize-ax.mintlify.dev/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Build a Prompt

> Learn what prompts are, how to build, test, improve, and save versioned prompts in Arize AX's Prompt Hub.

## What are prompts?

A **prompt** is the instruction set you send to an LLM. In Arize, a prompt is managed as a **Prompt Object**: messages, model settings, tools/functions, and response format together as one versioned artifact.

<Frame caption="One Prompt Object: messages, model settings, tools, and response format">
  <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/Screenshot%202025-10-21%20at%2010.15.23%E2%80%AFAM.png" alt="Diagram of a Prompt Object including template messages, parameters, tools, and response format" />
</Frame>

<CardGroup cols={2}>
  <Card title="Prompt template" icon="message">
    System, user, and assistant messages with variables like `{customer_input}`.
  </Card>

  <Card title="Model settings" icon="sliders">
    Model choice and invocation parameters such as temperature and max tokens.
  </Card>

  <Card title="Tools/functions" icon="wrench">
    Optional tool definitions and function-calling behavior.
  </Card>

  <Card title="Response format" icon="code">
    Output schema and structure your application expects.
  </Card>
</CardGroup>

<Frame
  caption={
"Template variables in curly braces are filled at run time so you can test many inputs without rewriting the prompt."
}
>
  <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/arize-docs-images/evaluate/prompt.png" alt="Prompt editor showing system and user messages with a highlighted template variable where input data is injected" />
</Frame>

## Build and improve a prompt

Start in **Playground** with a draft prompt, then refine it for clarity, correctness, and brevity.

### Create a prompt

<Frame caption="Open Playgrounds and create a new playground">
  <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/create-a-prompt-1.gif" alt="Navigate to Playgrounds and click New Playground, or start from the home page and have Alyx create a playground" />
</Frame>

<Tabs>
  <Tab title="By Alyx">
    <Steps>
      <Step title="Create a new playground">
        Navigate to **Playgrounds** and click **New Playground** to create a new playground. You can also start from the home page, and **Alyx** will create a playground for you.
      </Step>

      <Step title="Choose a provider or model">
        If you have not already added one, select your LLM provider and model in the Playground before you draft or run. Options include OpenAI, Azure, Vertex AI, AWS Bedrock, and others.

        <Frame caption="Choose provider and model in the Playground">
          <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/create-a-prompt-2.png" alt="LLM provider and model dropdowns in the Prompt Playground" />
        </Frame>
      </Step>

      <Step title="Draft and refine your prompt with Alyx">
        Describe your use case in plain language in the **Alyx** panel on the right. Include details about what your prompt should capture, desired output format, tone, length, etc. **Alyx** will wire them in automatically.

        For example, you could say:

        > Create a prompt for a customer support agent that handles returns and escalations. Use `{customer_input}` and `{order_id}` as variables.

        Give feedback on Alyx's drafts and keep iterating until you are satisfied with the prompt.

        <Frame caption="Use Alyx in the Prompt Playground to draft prompts">
          <video src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/arize-docs-images/evaluate/alyxcreateprompt.mp4" width="100%" height="100%" style={{ display: "block", objectFit: "contain" }} controls muted loop aria-label="Describe your use case in the Alyx panel to draft and refine a prompt" />
        </Frame>
      </Step>

      <Step title="Try the prompt in the Playground">
        If you added a dataset or test cases, **run the prompt** over rows to check outputs. If you skipped that step, exercise the prompt with manual inputs or keep iterating with Alyx. For a fuller testing workflow, see [**Test a prompt**](#test-a-prompt).
      </Step>
    </Steps>
  </Tab>

  <Tab title="By UI">
    <Steps>
      <Step title="Create a new playground">
        Navigate to **Playgrounds** and click **New Playground** to create a new playground.
      </Step>

      <Step title="Choose provider and model">
        Select your LLM provider and model from OpenAI, Azure, Vertex AI, AWS Bedrock, and others.

        <Frame caption="Choose provider and model in the Playground">
          <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/create-a-prompt-2.png" alt="LLM provider and model dropdowns in the Prompt Playground" />
        </Frame>
      </Step>

      <Step title="Add prompt messages">
        Add any system, user, or assistant messages. Use curly braces around names (for example, `{destination}`) for template variables filled dynamically at run time.

        <Frame caption="Define system and user messages with template variables">
          <video src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/create-a-prompt-3.mp4" width="100%" height="100%" style={{ display: "block", objectFit: "contain" }} controls muted loop />
        </Frame>
      </Step>

      <Step title="Add function calling (optional)">
        Click **Functions** and paste tool definitions as JSON. Function descriptions must be in JSON format. To add multiple functions, add entries to the JSON list with the proper attributes. Set **Function Selection** to give the model instructions on when to invoke each function.

        <Frame caption="Configure tools and function calling in the Playground">
          <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/create-a-prompt-4.gif" alt="Adding function definitions and function selection in the Prompt Playground" />
        </Frame>
      </Step>

      <Step title="Set invocation parameters">
        Click **Params** to configure temperature, max completion tokens, frequency penalty, and more. Different LLM providers expose different hyperparameters that affect the output.

        <Frame caption="Invocation parameters in the Playground">
          <video src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/create-a-prompt-5.mp4" width="100%" height="100%" style={{ display: "block", objectFit: "contain" }} controls muted loop />
        </Frame>
      </Step>
    </Steps>
  </Tab>

  <Tab title="By Code">
    Create a prompt and initial version from code. Use the reference for your stack:

    <Tabs>
      <Tab title="Python SDK">
        Full options (providers, invocation params, tools): [Create a Prompt](/api-clients/python/version-8/client-resources/prompts#create-a-prompt) in the Python v8 Prompts API.

        ```python theme={null}
        from arize._generated.api_client.models.input_variable_format import InputVariableFormat
        from arize._generated.api_client.models.llm_provider import LlmProvider
        from arize._generated.api_client.models.llm_message import LLMMessage

        prompt = client.prompts.create(
            space="your-space-name-or-id",
            name="customer-support-agent",
            description="Handles returns and escalations",
            commit_message="Initial version",
            input_variable_format=InputVariableFormat.F_STRING,
            provider=LlmProvider.OPENAI,
            model="gpt-4o",
            messages=[
                LLMMessage(role="system", content="You are a support agent for {company}."),
                LLMMessage(role="user", content="{ticket_text}"),
            ],
        )

        print(prompt.id, prompt.name)
        ```
      </Tab>

      <Tab title="TypeScript SDK">
        Full options: [Create a Prompt](/api-clients/typescript/version-1/client-resources/prompts#create-a-prompt) in the TypeScript Prompts API.

        ```typescript theme={null}
        import { createPrompt } from "@arizeai/ax-client";

        const prompt = await createPrompt({
          space: "my-space",
          name: "customer-support",
          description: "Handles returns and escalations",
          version: {
            commitMessage: "Initial version",
            inputVariableFormat: "f_string",
            provider: "openAI",
            model: "gpt-4o",
            messages: [
              { role: "system", content: "You are a support agent for {company_name}." },
              { role: "user", content: "{ticket_text}" },
            ],
          },
        });
        ```
      </Tab>

      <Tab title="CLI">
        Flags and message JSON shape: [`ax prompts create`](/api-clients/cli/prompts#ax-prompts-create) in the CLI reference.

        ```bash theme={null}
        ax prompts create \
          --name "customer-support-agent" \
          --space sp_abc123 \
          --provider openAI \
          --input-variable-format f_string \
          --messages '[{"role":"system","content":"You are a support agent for {company}."},{"role":"user","content":"{ticket_text}"}]' \
          --model gpt-4o \
          --description "Handles returns and escalations" \
          --commit-message "Initial version"
        ```
      </Tab>
    </Tabs>
  </Tab>
</Tabs>

### Test a prompt

Test your prompt against real examples before shipping.

<Frame caption="Test prompts in Playground against datasets, traces, or multiple versions">
  <video src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/arize-docs-images/evaluate/playground2.mp4" width="100%" height="100%" style={{ display: "block", objectFit: "contain" }} controls muted loop aria-label="Testing prompts in the Prompt Playground at scale" />
</Frame>

<Tabs>
  <Tab title="By Alyx">
    <Steps>
      <Step title="Load or generate data">
        Open **Alyx** and load your data, or ask it to generate examples from your use case.
      </Step>

      <Step title="Load your prompt">
        Ask Alyx to load a prompt from Prompt Hub and align `{variables}` with your dataset columns.
      </Step>

      <Step title="Create evaluator and run">
        Ask Alyx to draft an [evaluator](/ax/evaluate/evaluators), then run the experiment.
      </Step>

      <Step title="Review results">
        Open **View Experiment** to compare outputs, latency, tokens, and evaluator labels.
      </Step>
    </Steps>
  </Tab>

  <Tab title="By UI">
    <Steps>
      <Step title="Select a dataset">
        Choose your dataset in the Playground and confirm variable mapping.
      </Step>

      <Step title="Load or write your prompt">
        Load from Prompt Hub or draft a new prompt with `{variables}` from your dataset.
      </Step>

      <Step title="Attach evaluators">
        Add [evaluators](/ax/evaluate/evaluators) to score each row.
      </Step>

      <Step title="Run and compare">
        Click **Run**, then open **View Experiment** to inspect regressions and wins.
      </Step>
    </Steps>

    <Frame caption="Diff Output Mode highlights text changes against a baseline">
      <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/arize-docs-images/improve/ui_compare_two.png" alt="Compare Experiments view with Diff Output Mode enabled, highlighting insertions and deletions against a baseline run" />
    </Frame>
  </Tab>

  <Tab title="By Code">
    For programmatic testing and run comparison, use:

    * [Set up an experiment](/ax/improve/set-up-an-experiment)
    * [Run an experiment](/ax/improve/experiment-in-code#run-an-experiment)
    * [Log experiment results](/ax/improve/experiment-in-code#log-an-experiment)
  </Tab>
</Tabs>

For full run-and-compare workflow details, go to [Experiment in Playground](/ax/improve/experiment-in-playground).

## Save and version prompts

When a variant wins, save it to **Prompt Hub** so your team can track and deploy it safely.

<Frame caption="Prompt Hub: prompts list, versions, and labels">
  <img src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/prompt-hub.gif" alt="Prompt Hub in Arize AX showing prompts list and version management" />
</Frame>

<Tabs>
  <Tab title="By Alyx">
    In the **Prompt Playground**, you can ask **Alyx** to persist the prompt you have been editing, for example:

    > Save this prompt to Prompt Hub as `support-agent-v2` with a description that we tightened escalation rules.

    Alyx can help you refine messages, parameters, and tools first; when you are ready, ask it to **save** (or click **Save Prompt** yourself) so a new immutable version is written to **Prompt Hub** with the name, description, and tags you want.
  </Tab>

  <Tab title="By UI">
    <Steps>
      <Step title="Save from the Playground">
        Click **Save Prompt** in the Playground to store the current state (messages, parameters, tools, and response format) as a new immutable version in Prompt Hub.
      </Step>

      <Step title="Browse and compare versions">
        Open Prompt Hub to compare versions, review diffs, and track what changed over time.
      </Step>

      <Step title="Tag production">
        Tag the winning version as **Production** (or your deployment label) so your app resolves the approved prompt at runtime.
      </Step>
    </Steps>
  </Tab>

  <Tab title="By Code">
    | Step                 | Python                                                                                              | TypeScript                                                                                              | CLI                                                                               |
    | -------------------- | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
    | List versions        | [List versions](/api-clients/python/version-8/client-resources/prompts#list-versions)               | [List versions](/api-clients/typescript/version-1/client-resources/prompts#list-versions)               | [`ax prompts list-versions`](/api-clients/cli/prompts#ax-prompts-list-versions)   |
    | Create a new version | [Create a new version](/api-clients/python/version-8/client-resources/prompts#create-a-new-version) | [Create a new version](/api-clients/typescript/version-1/client-resources/prompts#create-a-new-version) | [`ax prompts create-version`](/api-clients/cli/prompts#ax-prompts-create-version) |
  </Tab>
</Tabs>

<Frame caption="Browse and compare prompt version history">
  <video src="https://storage.googleapis.com/arize-phoenix-assets/assets/images/version-prompt.mp4" width="100%" height="100%" style={{ display: "block", objectFit: "contain" }} controls muted loop aria-label="Prompt Hub version history and compare workflow" />
</Frame>

For deeper version-control and SDK workflows, see [Save and version prompts](/ax/improve/save-and-version-prompts).
