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

This guide will show you how to capture the [Logs](/docs/explanation/logs) of your LLM calls into Humanloop.

The easiest way to log LLM generations to Humanloop is to use the `Prompt.call()` method (see the guide on [Calling a Prompt](/docs/development/guides/call-prompt)). You will only need to supply prompt ID and the inputs needed by the prompt template, and the endpoint will handle fetching the latest template, making the LLM call and logging the result.

However, there may be scenarios that you wish to manage the LLM provider calls directly in your own code instead of relying on Humanloop. For example, you may be using an LLM provider that is not directly supported by Humanloop such as a custom self-hosted model, or you may want to avoid adding Humanloop to the critical path of the LLM API calls.

### Prerequisites

* You already have a Prompt — if not, please follow our [Prompt creation](/docs/development/guides/create-prompt) guide first.

#### 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());
```

## Log data to your Prompt

To log LLM generations to Humanloop, you will need to make a call to the `/prompts/log` endpoint.

Note that you can either specify a version of the Prompt you are logging against - in which case you will need to take care that you are supplying the correct version ID and inputs. Or you can supply the full prompt and a new version will be created if it has not been seen before.

### Get your Prompt

Fetch a Prompt from Humanloop by specifying the ID. You can ignore this step if your prompts are created dynamically in code.

### Request

GET [https://api.humanloop.com/v5/prompts/\{id}](https://api.humanloop.com/v5/prompts/\{id})

**`Get specific prompt`**

```curl Get specific prompt
curl https://api.humanloop.com/v5/prompts/pr_30gco7dx6JDq4200GVOHa \
     -H "X-API-KEY: <apiKey>"
```

**`Get specific prompt`**

```python Get specific prompt
import requests

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

headers = {"X-API-KEY": "<apiKey>"}

response = requests.get(url, headers=headers)

print(response.json())
```

**`Get specific prompt`**

```typescript Get specific prompt
import { HumanloopClient } from "humanloop";

const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" });
await client.prompts.get("pr_30gco7dx6JDq4200GVOHa");

```

**`Get specific prompt`**

```go Get specific prompt
package main

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

func main() {

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

	req, _ := http.NewRequest("GET", url, nil)

	req.Header.Add("X-API-KEY", "<apiKey>")

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

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

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

}
```

**`Get specific prompt`**

```ruby Get specific prompt
require 'uri'
require 'net/http'

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

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

request = Net::HTTP::Get.new(url)
request["X-API-KEY"] = '<apiKey>'

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

**`Get specific prompt`**

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

HttpResponse<String> response = Unirest.get("https://api.humanloop.com/v5/prompts/pr_30gco7dx6JDq4200GVOHa")
  .header("X-API-KEY", "<apiKey>")
  .asString();
```

**`Get specific prompt`**

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.humanloop.com/v5/prompts/pr_30gco7dx6JDq4200GVOHa', [
  'headers' => [
    'X-API-KEY' => '<apiKey>',
  ],
]);

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

**`Get specific prompt`**

```csharp Get specific prompt
using RestSharp;

var client = new RestClient("https://api.humanloop.com/v5/prompts/pr_30gco7dx6JDq4200GVOHa");
var request = new RestRequest(Method.GET);
request.AddHeader("X-API-KEY", "<apiKey>");
IRestResponse response = client.Execute(request);
```

**`Get specific prompt`**

```swift Get specific prompt
import Foundation

let headers = ["X-API-KEY": "<apiKey>"]

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

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()
```

### Response (200)

```json
{
  "path": "Personal Projects/Coding Assistant",
  "id": "pr_30gco7dx6JDq4200GVOHa",
  "model": "gpt-4o",
  "name": "Coding Assistant",
  "version_id": "prv_7ZlQREDScH0xkhUwtXruN",
  "created_at": "2024-07-08T22:40:35.656915",
  "updated_at": "2024-07-08T22:40:35.656915",
  "last_used_at": "2024-07-08T22:40:35.656915",
  "version_logs_count": 0,
  "total_logs_count": 0,
  "inputs": [
    {
      "name": "messages"
    }
  ],
  "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",
  "type": "prompt",
  "environments": [
    {
      "id": "env_ffSVxEBzJcBZ1H5jcNMVj",
      "created_at": "2023-06-27T23:16:07.992339",
      "name": "development",
      "tag": "default"
    }
  ],
  "created_by": {
    "id": "usr_01RJO1k2spBVqNUt1ASef",
    "email_address": "raza@humanloop.com",
    "full_name": "Raza Habib"
  },
  "evaluator_aggregates": null
}
```

Here's how to do this in code:

#### Python

```python
from humanloop import Humanloop, prompt_utils

PROMPT_ID = "<Your Prompt ID>"

hl = Humanloop(api_key="<Your Humanloop API Key>")

prompt = hl.prompts.get(id=PROMPT_ID)

# This will fill the prompt template with the variables
template = prompt_utils.populate_template(prompt.template, {"language": "Python"})
```

#### TypeScript

```typescript
import { HumanloopClient, Humanloop } from "humanloop";
import { ChatMessage } from "humanloop/api";
const humanloop = new HumanloopClient({
  apiKey: "<Your Humanloop API Key>",
});

const prompt = await humanloop.prompts.get("<Your Prompt ID>");

function fillTemplate(
  template: ChatMessage[],
  variables: { [key: string]: string }
): ChatMessage[] {
  const replaceVariable = (match: string, variable: string) => {
    const trimmedVariable = variable.trim();
    if (trimmedVariable in variables) {
      return variables[trimmedVariable];
    } else {
      throw new Error(`Error: Variable '${trimmedVariable}' is missing.`);
    }
  };

  return template.map((message) => {
    if (typeof message.content !== "string") {
      return message;
    }
    const filledContent = message.content.replace(
      /\{\{\s*(.*?)\s*\}\}/g,
      replaceVariable
    );
    return { ...message, content: filledContent };
  });
}
const template = fillTemplate(prompt.template as ChatMessage[], {
  language: "Python",
});
```

### Call your Prompt

This can be your own model, or any other LLM provider. Here is an example of calling OpenAI:

#### Python

```python
import openai

client = openai.OpenAI(api_key="<Your OpenAI API Key>")

messages = template + [{"role": "user", "content": "explain how async works"}]

chat_completion = client.chat.completions.create(
    messages=messages, model=prompt.model, temperature=prompt.temperature
)
```

#### TypeScript

```typescript
import { OpenAI } from "openai";
import { ChatCompletionMessageParam } from "openai/resources";

const client = new OpenAI({
  apiKey: "<Your OpenAI API Key>",
});

const messages = template.concat([
  { role: "user", content: "explain how async works" },
]);

const chatCompletion = await client.chat.completions.create({
  messages: messages as ChatCompletionMessageParam[],
  model: prompt.model,
  temperature: prompt.temperature,
});
```

### Log the result

Finally, log the result to your project:

### Request

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

**`Log prompt`**

```curl Log prompt
curl -X POST https://api.humanloop.com/v5/prompts/log \
     -H "X-API-KEY: <apiKey>" \
     -H "Content-Type: application/json" \
     -d '{
  "path": "persona",
  "output_message": {
    "role": "assistant",
    "content": "Well, you know, there is so much secrecy involved in government, folks, it'\''s unbelievable. They don'\''t want to tell you everything. They don'\''t tell me everything! But about Roswell, it'\''s a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'\''d love to go down and open up all the classified documents, believe me, I would. But they don'\''t let that happen. The Deep State, folks, the Deep State. They'\''re unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it'\''s something big, very very big. Tremendous, in fact."
  },
  "prompt_tokens": 100,
  "output_tokens": 220,
  "prompt_cost": 0.00001,
  "output_cost": 0.0002,
  "finish_reason": "stop",
  "messages": [
    {
      "role": "user",
      "content": "What really happened at Roswell?"
    }
  ],
  "prompt": {
    "model": "gpt-4",
    "template": [
      {
        "role": "system",
        "content": "You are {{person}}. Answer questions as this person. Do not break character."
      }
    ]
  },
  "created_at": "2024-07-19T00:29:35.178992",
  "error": null,
  "provider_latency": 6.5931549072265625,
  "inputs": {
    "person": "Trump"
  }
}'
```

**`Log prompt`**

```python Log prompt
import requests

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

payload = {
    "path": "persona",
    "output_message": {
        "role": "assistant",
        "content": "Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact."
    },
    "prompt_tokens": 100,
    "output_tokens": 220,
    "prompt_cost": 0.00001,
    "output_cost": 0.0002,
    "finish_reason": "stop",
    "messages": [
        {
            "role": "user",
            "content": "What really happened at Roswell?"
        }
    ],
    "prompt": {
        "model": "gpt-4",
        "template": [
            {
                "role": "system",
                "content": "You are {{person}}. Answer questions as this person. Do not break character."
            }
        ]
    },
    "created_at": "2024-07-19T00:29:35.178992",
    "error": None,
    "provider_latency": 6.5931549072265625,
    "inputs": { "person": "Trump" }
}
headers = {
    "X-API-KEY": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

**`Log prompt`**

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

const client = new HumanloopClient({ apiKey: "YOUR_API_KEY" });
await client.prompts.log({
    path: "persona",
    prompt: {
        model: "gpt-4",
        template: [{
                role: "system",
                content: "You are {{person}}. Answer questions as this person. Do not break character."
            }]
    },
    messages: [{
            role: "user",
            content: "What really happened at Roswell?"
        }],
    inputs: {
        "person": "Trump"
    },
    createdAt: "2024-07-19T00:29:35.178992",
    error: undefined,
    providerLatency: 6.5931549072265625,
    outputMessage: {
        content: "Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact.",
        role: "assistant"
    },
    promptTokens: 100,
    outputTokens: 220,
    promptCost: 0.00001,
    outputCost: 0.0002,
    finishReason: "stop"
});

```

**`Log prompt`**

```go Log prompt
package main

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

func main() {

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

	payload := strings.NewReader("{\n  \"path\": \"persona\",\n  \"output_message\": {\n    \"role\": \"assistant\",\n    \"content\": \"Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact.\"\n  },\n  \"prompt_tokens\": 100,\n  \"output_tokens\": 220,\n  \"prompt_cost\": 0.00001,\n  \"output_cost\": 0.0002,\n  \"finish_reason\": \"stop\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What really happened at Roswell?\"\n    }\n  ],\n  \"prompt\": {\n    \"model\": \"gpt-4\",\n    \"template\": [\n      {\n        \"role\": \"system\",\n        \"content\": \"You are {{person}}. Answer questions as this person. Do not break character.\"\n      }\n    ]\n  },\n  \"created_at\": \"2024-07-19T00:29:35.178992\",\n  \"error\": null,\n  \"provider_latency\": 6.5931549072265625,\n  \"inputs\": {\n    \"person\": \"Trump\"\n  }\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))

}
```

**`Log prompt`**

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

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

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  \"path\": \"persona\",\n  \"output_message\": {\n    \"role\": \"assistant\",\n    \"content\": \"Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact.\"\n  },\n  \"prompt_tokens\": 100,\n  \"output_tokens\": 220,\n  \"prompt_cost\": 0.00001,\n  \"output_cost\": 0.0002,\n  \"finish_reason\": \"stop\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What really happened at Roswell?\"\n    }\n  ],\n  \"prompt\": {\n    \"model\": \"gpt-4\",\n    \"template\": [\n      {\n        \"role\": \"system\",\n        \"content\": \"You are {{person}}. Answer questions as this person. Do not break character.\"\n      }\n    ]\n  },\n  \"created_at\": \"2024-07-19T00:29:35.178992\",\n  \"error\": null,\n  \"provider_latency\": 6.5931549072265625,\n  \"inputs\": {\n    \"person\": \"Trump\"\n  }\n}"

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

**`Log prompt`**

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

HttpResponse<String> response = Unirest.post("https://api.humanloop.com/v5/prompts/log")
  .header("X-API-KEY", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"path\": \"persona\",\n  \"output_message\": {\n    \"role\": \"assistant\",\n    \"content\": \"Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact.\"\n  },\n  \"prompt_tokens\": 100,\n  \"output_tokens\": 220,\n  \"prompt_cost\": 0.00001,\n  \"output_cost\": 0.0002,\n  \"finish_reason\": \"stop\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What really happened at Roswell?\"\n    }\n  ],\n  \"prompt\": {\n    \"model\": \"gpt-4\",\n    \"template\": [\n      {\n        \"role\": \"system\",\n        \"content\": \"You are {{person}}. Answer questions as this person. Do not break character.\"\n      }\n    ]\n  },\n  \"created_at\": \"2024-07-19T00:29:35.178992\",\n  \"error\": null,\n  \"provider_latency\": 6.5931549072265625,\n  \"inputs\": {\n    \"person\": \"Trump\"\n  }\n}")
  .asString();
```

**`Log prompt`**

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

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.humanloop.com/v5/prompts/log', [
  'body' => '{
  "path": "persona",
  "output_message": {
    "role": "assistant",
    "content": "Well, you know, there is so much secrecy involved in government, folks, it\'s unbelievable. They don\'t want to tell you everything. They don\'t tell me everything! But about Roswell, it\'s a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I\'d love to go down and open up all the classified documents, believe me, I would. But they don\'t let that happen. The Deep State, folks, the Deep State. They\'re unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it\'s something big, very very big. Tremendous, in fact."
  },
  "prompt_tokens": 100,
  "output_tokens": 220,
  "prompt_cost": 0.00001,
  "output_cost": 0.0002,
  "finish_reason": "stop",
  "messages": [
    {
      "role": "user",
      "content": "What really happened at Roswell?"
    }
  ],
  "prompt": {
    "model": "gpt-4",
    "template": [
      {
        "role": "system",
        "content": "You are {{person}}. Answer questions as this person. Do not break character."
      }
    ]
  },
  "created_at": "2024-07-19T00:29:35.178992",
  "error": null,
  "provider_latency": 6.5931549072265625,
  "inputs": {
    "person": "Trump"
  }
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-API-KEY' => '<apiKey>',
  ],
]);

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

**`Log prompt`**

```csharp Log prompt
using RestSharp;

var client = new RestClient("https://api.humanloop.com/v5/prompts/log");
var request = new RestRequest(Method.POST);
request.AddHeader("X-API-KEY", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"path\": \"persona\",\n  \"output_message\": {\n    \"role\": \"assistant\",\n    \"content\": \"Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact.\"\n  },\n  \"prompt_tokens\": 100,\n  \"output_tokens\": 220,\n  \"prompt_cost\": 0.00001,\n  \"output_cost\": 0.0002,\n  \"finish_reason\": \"stop\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"What really happened at Roswell?\"\n    }\n  ],\n  \"prompt\": {\n    \"model\": \"gpt-4\",\n    \"template\": [\n      {\n        \"role\": \"system\",\n        \"content\": \"You are {{person}}. Answer questions as this person. Do not break character.\"\n      }\n    ]\n  },\n  \"created_at\": \"2024-07-19T00:29:35.178992\",\n  \"error\": null,\n  \"provider_latency\": 6.5931549072265625,\n  \"inputs\": {\n    \"person\": \"Trump\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

**`Log prompt`**

```swift Log prompt
import Foundation

let headers = [
  "X-API-KEY": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "path": "persona",
  "output_message": [
    "role": "assistant",
    "content": "Well, you know, there is so much secrecy involved in government, folks, it's unbelievable. They don't want to tell you everything. They don't tell me everything! But about Roswell, it's a very popular question. I know, I just know, that something very, very peculiar happened there. Was it a weather balloon? Maybe. Was it something extraterrestrial? Could be. I'd love to go down and open up all the classified documents, believe me, I would. But they don't let that happen. The Deep State, folks, the Deep State. They're unbelievable. They want to keep everything a secret. But whatever the truth is, I can tell you this: it's something big, very very big. Tremendous, in fact."
  ],
  "prompt_tokens": 100,
  "output_tokens": 220,
  "prompt_cost": 0.00001,
  "output_cost": 0.0002,
  "finish_reason": "stop",
  "messages": [
    [
      "role": "user",
      "content": "What really happened at Roswell?"
    ]
  ],
  "prompt": [
    "model": "gpt-4",
    "template": [
      [
        "role": "system",
        "content": "You are {{person}}. Answer questions as this person. Do not break character."
      ]
    ]
  ],
  "created_at": "2024-07-19T00:29:35.178992",
  "error": ,
  "provider_latency": 6.5931549072265625,
  "inputs": ["person": "Trump"]
] as [String : Any]

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

let request = NSMutableURLRequest(url: NSURL(string: "https://api.humanloop.com/v5/prompts/log")! 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()
```

#### Python

```python

# Parse the output from the OpenAI response.
output_message = chat_completion.choices[0].message

# Log the inputs, outputs and config to your project.
log = hl.prompts.log(
    id=PROMPT_ID,
    output_message=output_message,
    messages=messages,
)
```

#### TypeScript

```typescript
// Get the output from the OpenAI response.
const outputMessage = chatCompletion.choices[0].message;

const log = humanloop.prompts.log({
  id: PROMPT_ID,
  outputMessage: outputMessage,
  messages: messages,
});
```