> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://humanloop.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://humanloop.com/docs/_mcp/server.

> Learn how to create a Prompt in Humanloop using the UI or SDK, version it, and use it to generate responses from your AI models. Prompt management is a key part of the Humanloop platform.

Humanloop acts as a registry of your [Prompts](/docs/explanation/prompts) so you can centrally manage all their versions and [Logs](/docs/explanation/logs), and evaluate and improve your AI systems.

This guide will show you how to create a Prompt [in the UI](/docs/v4/guides/create-prompt#create-a-prompt-in-the-ui) or [via the SDK/API](/docs/v4/guides/create-prompt#create-a-prompt-using-the-sdk).

> **Note**
>
> **Prerequisite**: A Humanloop account.
>
> You can create an account now by going to the [Sign up page](https://app.humanloop.com/signup).

## Create a Prompt in the UI

#### Account setup

#### Create a Humanloop Account

If you haven’t already, create an account or log in to Humanloop

#### Add an OpenAI API Key

If you’re the first person in your organization, you’ll need to add an API key to a model provider.

1. Go to OpenAI and [grab an API key](https://platform.openai.com/api-keys)
2. In Humanloop [Organization Settings](https://app.humanloop.com/account/api-keys) set up OpenAI as a model provider.

> **Info**
>
> Using the Prompt Editor will use your OpenAI credits in the same way that the
> OpenAI playground does. Keep your API keys for Humanloop and the model
> providers private.

## Get Started

### Create a Prompt File

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

![](/docs/_fern-img/839c05752b46bcbe68b6a4d4871b0ad54aa401b557ec69baf800c66dd6605289.webp)

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

### 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.

![](/docs/_fern-img/bd73541ed1ed343f1aa4d43d423a73cde3169db401631ffbe309e10079fd36d6.webp)

In the editor, update the system message to:

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

![](/docs/_fern-img/6c8bf026adf4480dbfad2fe692b6a933e0de461effd0cdd94cf1c47c530370df.webp)

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 for `topic` 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.

### Save your first version of this Prompt

1. Click the **Save** button at the top of the editor
2. Enter **Initial Comedian Setup** in the version name field
3. Enter **Prompt for making (not so) funny jokes!** in the description field
4. Click **Save**

![](/docs/_fern-img/3ee06b7926a5ce932cd2b90e4b00f8d450cce378137f10278df5c02ae227d9a2.webp)

### 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.

![](/docs/_fern-img/3154bf4ca107872314e9353d516687b4d692370a60087d5bb33f9df4ec6693d7.webp)

---

## Create a Prompt using the SDK

The Humanloop Python SDK allows you to programmatically create and version your [Prompts](/docs/explanation/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

> **Note**
>
> **Prerequisite**: A Humanloop SDK Key.
>
> You can get this from your [Organisation Settings page](https://app.humanloop.com/account/api-keys) if you have the [right permissions](/docs/v5/reference/access-roles).

#### Install and initialize the SDK

First you need to install and initialize the SDK. If you have already done this, skip to the next section.

Open up your terminal and follow these steps:

1. Install the Humanloop SDK:

```python
pip install humanloop
```

```typescript
npm install humanloop
```

2. Initialize the SDK with your Humanloop API key (you can get it from the [Organization Settings page](https://app.humanloop.com/account/api-keys)).

```python
from humanloop import Humanloop
humanloop = Humanloop(api_key="<YOUR HUMANLOOP KEY>")

# Check that the authentication was successful
print(humanloop.prompts.list())
```

```typescript
import { HumanloopClient, Humanloop } from "humanloop";

const humanloop = new HumanloopClient({ apiKey: "YOUR_API_KEY" });

// Check that the authentication was successful
console.log(await humanloop.prompts.list());
```

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

### Create the Prompt

This can be done by using the [Prompt Upsert](/docs/api/prompts/upsert) method in the SDK.

Or by calling the API directly:

### Request

POST [https://api.humanloop.com/v5/prompts](https://api.humanloop.com/v5/prompts)

**`Upsert prompt`**

```curl Upsert prompt
curl -X POST https://api.humanloop.com/v5/prompts \
     -H "X-API-KEY: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "model": "gpt-4o",
  "path": "Personal Projects/Coding Assistant",
  "endpoint": "chat",
  "template": [
    {
      "content": "You are a helpful coding assistant specialising in {{language}}",
      "role": "system"
    }
  ],
  "provider": "openai",
  "max_tokens": -1,
  "temperature": 0.7,
  "version_name": "coding-assistant-v1",
  "version_description": "Initial version"
}'
```

**`Upsert prompt`**

```python Upsert prompt
import requests

url = "https://api.humanloop.com/v5/prompts"

payload = {
    "model": "gpt-4o",
    "path": "Personal Projects/Coding Assistant",
    "endpoint": "chat",
    "template": [
        {
            "content": "You are a helpful coding assistant specialising in {{language}}",
            "role": "system"
        }
    ],
    "provider": "openai",
    "max_tokens": -1,
    "temperature": 0.7,
    "version_name": "coding-assistant-v1",
    "version_description": "Initial version"
}
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

**`Upsert prompt`**

```typescript Upsert prompt
import { HumanloopClient } from "humanloop";

const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" });
await client.prompts.upsert({
    path: "Personal Projects/Coding Assistant",
    model: "gpt-4o",
    endpoint: "chat",
    template: [{
            content: "You are a helpful coding assistant specialising in {{language}}",
            role: "system"
        }],
    provider: "openai",
    maxTokens: -1,
    temperature: 0.7,
    versionName: "coding-assistant-v1",
    versionDescription: "Initial version"
});

```

**`Upsert prompt`**

```go Upsert prompt
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.humanloop.com/v5/prompts"

	payload := strings.NewReader("{\n  \"model\": \"gpt-4o\",\n  \"path\": \"Personal Projects/Coding Assistant\",\n  \"endpoint\": \"chat\",\n  \"template\": [\n    {\n      \"content\": \"You are a helpful coding assistant specialising in {{language}}\",\n      \"role\": \"system\"\n    }\n  ],\n  \"provider\": \"openai\",\n  \"max_tokens\": -1,\n  \"temperature\": 0.7,\n  \"version_name\": \"coding-assistant-v1\",\n  \"version_description\": \"Initial version\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-KEY", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

**`Upsert prompt`**

```ruby Upsert prompt
require 'uri'
require 'net/http'

url = URI("https://api.humanloop.com/v5/prompts")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-KEY"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"gpt-4o\",\n  \"path\": \"Personal Projects/Coding Assistant\",\n  \"endpoint\": \"chat\",\n  \"template\": [\n    {\n      \"content\": \"You are a helpful coding assistant specialising in {{language}}\",\n      \"role\": \"system\"\n    }\n  ],\n  \"provider\": \"openai\",\n  \"max_tokens\": -1,\n  \"temperature\": 0.7,\n  \"version_name\": \"coding-assistant-v1\",\n  \"version_description\": \"Initial version\"\n}"

response = http.request(request)
puts response.read_body
```

**`Upsert prompt`**

```java Upsert prompt
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.humanloop.com/v5/prompts")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"gpt-4o\",\n  \"path\": \"Personal Projects/Coding Assistant\",\n  \"endpoint\": \"chat\",\n  \"template\": [\n    {\n      \"content\": \"You are a helpful coding assistant specialising in {{language}}\",\n      \"role\": \"system\"\n    }\n  ],\n  \"provider\": \"openai\",\n  \"max_tokens\": -1,\n  \"temperature\": 0.7,\n  \"version_name\": \"coding-assistant-v1\",\n  \"version_description\": \"Initial version\"\n}")
  .asString();
```

**`Upsert prompt`**

```php Upsert prompt
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.humanloop.com/v5/prompts', [
  'body' => '{
  "model": "gpt-4o",
  "path": "Personal Projects/Coding Assistant",
  "endpoint": "chat",
  "template": [
    {
      "content": "You are a helpful coding assistant specialising in {{language}}",
      "role": "system"
    }
  ],
  "provider": "openai",
  "max_tokens": -1,
  "temperature": 0.7,
  "version_name": "coding-assistant-v1",
  "version_description": "Initial version"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

**`Upsert prompt`**

```csharp Upsert prompt
using RestSharp;

var client = new RestClient("https://api.humanloop.com/v5/prompts");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"model\": \"gpt-4o\",\n  \"path\": \"Personal Projects/Coding Assistant\",\n  \"endpoint\": \"chat\",\n  \"template\": [\n    {\n      \"content\": \"You are a helpful coding assistant specialising in {{language}}\",\n      \"role\": \"system\"\n    }\n  ],\n  \"provider\": \"openai\",\n  \"max_tokens\": -1,\n  \"temperature\": 0.7,\n  \"version_name\": \"coding-assistant-v1\",\n  \"version_description\": \"Initial version\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`Upsert prompt`**

```swift Upsert prompt
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "model": "gpt-4o",
  "path": "Personal Projects/Coding Assistant",
  "endpoint": "chat",
  "template": [
    [
      "content": "You are a helpful coding assistant specialising in {{language}}",
      "role": "system"
    ]
  ],
  "provider": "openai",
  "max_tokens": -1,
  "temperature": 0.7,
  "version_name": "coding-assistant-v1",
  "version_description": "Initial version"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v5/prompts")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```

### Go to the App

Go to the [Humanloop app](https://app.humanloop.com) 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](/docs/development/guides/call-prompt).