Skip to content

Get Started with Prompt Management

This guide walks through creating a prompt in XeroML and fetching it in your application using the SDK.

Prerequisites

  1. Create a XeroML account or self-host XeroML

  2. Set your API credentials as environment variables:

    Terminal window
    XEROML_SECRET_KEY="sk-xm-..."
    XEROML_PUBLIC_KEY="pk-xm-..."
    XEROML_BASE_URL="https://cloud.xeroml.com"

Create a Prompt

Via the UI

  1. Open your XeroML project and navigate to Prompts
  2. Click New Prompt and give it a name (e.g., movie-critic)
  3. Choose the type: Text or Chat
  4. Write your prompt using {{variable_name}} for dynamic values
  5. Click Save — this creates version 1

Via the SDK

Text prompt:

from xeroml import get_client
xeroml = get_client()
xeroml.create_prompt(
name="movie-critic",
type="text",
prompt="As a {{criticlevel}} movie critic, write a review of {{movie}} in {{num_words}} words.",
labels=["production"],
)

Chat prompt:

xeroml.create_prompt(
name="support-agent",
type="chat",
prompt=[
{"role": "system", "content": "You are a helpful support agent for {{company}}."},
{"role": "user", "content": "{{user_message}}"},
],
labels=["production"],
)

Fetch and Use a Prompt

from xeroml import get_client
xeroml = get_client()
# Fetch the production version
prompt = xeroml.get_prompt("movie-critic")
# Compile variables
compiled = prompt.compile(
criticlevel="seasoned",
movie="Inception",
num_words="200"
)
# Use with OpenAI
from xeroml.openai import openai
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": compiled}],
)

Next Steps