Prompt engineering is the practice of designing inputs to guide large language models (LLMs) to produce desired responses. Each prompt has two key components: a system prompt and a user prompt — both integrated within a single Prompt object for management and retrieval.

  • System Prompt: Provides background context or instructions to influence the model’s overall behavior.
  • User Prompt: The specific question or input meant for the model to address in its response.

Using the Quotient SDK, you can manage Prompts by creating, retrieving, updating, and deleting them programmatically within your application.

Creating Prompts

To create a new prompt, use the create() method, specifying a unique name, a system prompt for model behavior, and a user prompt for user interaction.

from quotientai import QuotientAI

quotient = QuotientAI()

new_prompt = quotient.prompts.create(
    name="Customer Support Inquiry",
    system_prompt="You are a helpful assistant.",
    user_prompt="How can I assist you today?"
)

print(new_prompt)
Prompt names must be unique within your Quotient account. Attempting to create a prompt with an existing name will raise an error.

Retrieving a Specific Prompt

To retrieve a prompt by its ID (and optionally by version), use the get() method.

prompt_id = quotient.prompts.list()[0].id
prompt = quotient.prompts.get(prompt_id)

print(prompt)

The returned Prompt object includes a messages property, useful for integration with model provider libraries (e.g., OpenAI)

from openai import OpenAI
from quotientai import QuotientAI

oai = OpenAI()
quotient = QuotientAI()

prompt = quotient.prompts.get(prompt_id)

response = oai.chat.completions.create(
    messages=prompt.messages,
    model="gpt-4o-mini",
)

Listing Prompts

Retrieve all available prompts using the list() method. Each prompt includes details like id, name, system_prompt, and user_prompt.

prompts = quotient.prompts.list()

for prompt in prompts:
    print(prompt)

Versioning Prompts

Each prompt starts at version 0 upon creation. Quotient manages prompt versions, linking them by prompt name and unique ID.

Creating a New Prompt Version

To update a prompt’s details and have them recorded in Quotient, use the update() method. If any attributes (like name, system_prompt, or user_prompt) change, the version is automatically incremented.

prompt.user_prompt = "How can I assist you today? Please provide more details."

updated_prompt = quotient.prompts.update(prompt=prompt)

print(updated_prompt)

Deleting a Prompt

Deleting a prompt removes all its associated versions. Use the delete() method with the Prompt object you wish to remove.

quotient.prompts.delete(prompt)

# Confirm the deletion
print("Prompt deleted successfully!")
Prompts are soft-deleted — if you’d like to permanently remove prompts, contact us at support@quotientai.co