How to create, version and use a Prompt in Humanloop

Humanloop acts as a registry of your Prompts so you can centrally manage all their versions and Logs, and evaluate and improve your AI systems.

This guide will show you how to create a Prompt in the UI or via the SDK/API.

Prerequisite: A Humanloop account.

You can create an account now by going to the Sign up page.

Create a Prompt in the UI

1

Create a Prompt File

When you first open Humanloop you’ll see your File navigation on the left. Click ‘+ New’ and create a Prompt.

In the sidebar, rename this file to “Comedian Bot” now or later.

2

Create the Prompt template in the Editor

The left hand side of the screen defines your Prompt – the parameters such as model, temperature and template. The right hand side is a single chat session with this Prompt.

Click the ”+ Message” button within the chat template to add a system message to the chat template.

Add the following templated message to the chat template.

You are a funny comedian. Write a joke about {{topic}}.

This message forms the chat template. It has an input slot called topic (surrounded by two curly brackets) for an input value that is provided each time you call this Prompt.

On the right hand side of the page, you’ll now see a box in the Inputs section for topic.

  1. Add a value fortopic e.g. music, jogging, whatever.
  2. Click Run in the bottom right of the page.

This will call OpenAI’s model and return the assistant response. Feel free to try other values, the model is very funny.

You now have a first version of your prompt that you can use.

3

Commit your first version of this Prompt

  1. Click the Commit button
  2. Put “initial version” in the commit message field
  3. Click Commit
4

View the logs

Under the Prompt File click ‘Logs’ to view all the generations from this Prompt

Click on a row to see the details of what version of the prompt generated it. From here you can give feedback to that generation, see performance metrics, open up this example in the Editor, or add this log to a dataset.


Create a Prompt using the SDK

The Humanloop Python SDK allows you to programmatically create and version your Prompts in Humanloop, and log generations from your models. This guide will show you how to create a Prompt using the SDK.

Note that you can also version your prompts dynamically with every Prompt

Prerequisite: A Humanloop SDK Key.

You can get this from your Organisation Settings page if you have the right permissions.

After initializing the SDK client, you can call the Prompt creation endpoint.

1

Create the Prompt

POST
1curl -X POST https://api.humanloop.com/v5/prompts \
2 -H "X-API-KEY: <apiKey>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "gpt-4o",
6 "path": "Personal Projects/Coding Assistant",
7 "endpoint": "chat",
8 "template": [
9 {
10 "content": "You are a helpful coding assistant specialising in {{language}}",
11 "role": "system"
12 }
13 ],
14 "provider": "openai",
15 "max_tokens": -1,
16 "temperature": 0.7,
17 "top_p": 1,
18 "presence_penalty": 0,
19 "frequency_penalty": 0,
20 "other": {},
21 "tools": [],
22 "linked_tools": [],
23 "commit_message": "Initial commit"
24}'
2

Go to the App

Go to the Humanloop app and you will see your Prompt in your list of files.

You now have a Prompt in Humanloop that contains your initial version. You can call the Prompt in Editor and invite team members by going to your organization’s members page.

Next Steps

With the Prompt set up, you can now integrate it into your app by following the Call a Prompt Guide.