Skip to main content
POST
/
monitor
/
trace
Create a trace
curl --request POST \
  --url https://api.getbasalt.ai/monitor/trace \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "qa-chatbot",
  "featureSlug": "qa-chatbot",
  "chainSlug": "qa-chatbot",
  "input": "What is the capital of France?",
  "output": "Paris",
  "idealOutput": "<string>",
  "metadata": {
    "sessionId": "456",
    "userType": "admin"
  },
  "organization": {
    "id": "123",
    "name": "ACME"
  },
  "user": {
    "id": "123",
    "name": "John Doe"
  },
  "startTime": "2021-01-01T00:00:00Z",
  "endTime": "2021-01-01T00:00:00Z",
  "experiment": {
    "id": "123"
  },
  "logs": [
    {
      "id": "123",
      "type": "generation",
      "name": "qa-chatbot",
      "startTime": "2021-01-01T00:00:00Z",
      "endTime": "2021-01-01T00:00:00Z",
      "metadata": {
        "sessionId": "456",
        "userType": "admin"
      }
    }
  ],
  "evaluators": [
    {
      "slug": "hallucination"
    }
  ],
  "evaluationConfig": {
    "sampleRate": 0.5
  }
}
'
import requests

url = "https://api.getbasalt.ai/monitor/trace"

payload = {
"name": "qa-chatbot",
"featureSlug": "qa-chatbot",
"chainSlug": "qa-chatbot",
"input": "What is the capital of France?",
"output": "Paris",
"idealOutput": "<string>",
"metadata": {
"sessionId": "456",
"userType": "admin"
},
"organization": {
"id": "123",
"name": "ACME"
},
"user": {
"id": "123",
"name": "John Doe"
},
"startTime": "2021-01-01T00:00:00Z",
"endTime": "2021-01-01T00:00:00Z",
"experiment": { "id": "123" },
"logs": [
{
"id": "123",
"type": "generation",
"name": "qa-chatbot",
"startTime": "2021-01-01T00:00:00Z",
"endTime": "2021-01-01T00:00:00Z",
"metadata": {
"sessionId": "456",
"userType": "admin"
}
}
],
"evaluators": [{ "slug": "hallucination" }],
"evaluationConfig": { "sampleRate": 0.5 }
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}

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

print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'qa-chatbot',
featureSlug: 'qa-chatbot',
chainSlug: 'qa-chatbot',
input: 'What is the capital of France?',
output: 'Paris',
idealOutput: '<string>',
metadata: {sessionId: '456', userType: 'admin'},
organization: {id: '123', name: 'ACME'},
user: {id: '123', name: 'John Doe'},
startTime: '2021-01-01T00:00:00Z',
endTime: '2021-01-01T00:00:00Z',
experiment: {id: '123'},
logs: [
{
id: '123',
type: 'generation',
name: 'qa-chatbot',
startTime: '2021-01-01T00:00:00Z',
endTime: '2021-01-01T00:00:00Z',
metadata: {sessionId: '456', userType: 'admin'}
}
],
evaluators: [{slug: 'hallucination'}],
evaluationConfig: {sampleRate: 0.5}
})
};

fetch('https://api.getbasalt.ai/monitor/trace', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.getbasalt.ai/monitor/trace",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'qa-chatbot',
'featureSlug' => 'qa-chatbot',
'chainSlug' => 'qa-chatbot',
'input' => 'What is the capital of France?',
'output' => 'Paris',
'idealOutput' => '<string>',
'metadata' => [
'sessionId' => '456',
'userType' => 'admin'
],
'organization' => [
'id' => '123',
'name' => 'ACME'
],
'user' => [
'id' => '123',
'name' => 'John Doe'
],
'startTime' => '2021-01-01T00:00:00Z',
'endTime' => '2021-01-01T00:00:00Z',
'experiment' => [
'id' => '123'
],
'logs' => [
[
'id' => '123',
'type' => 'generation',
'name' => 'qa-chatbot',
'startTime' => '2021-01-01T00:00:00Z',
'endTime' => '2021-01-01T00:00:00Z',
'metadata' => [
'sessionId' => '456',
'userType' => 'admin'
]
]
],
'evaluators' => [
[
'slug' => 'hallucination'
]
],
'evaluationConfig' => [
'sampleRate' => 0.5
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

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

func main() {

url := "https://api.getbasalt.ai/monitor/trace"

payload := strings.NewReader("{\n \"name\": \"qa-chatbot\",\n \"featureSlug\": \"qa-chatbot\",\n \"chainSlug\": \"qa-chatbot\",\n \"input\": \"What is the capital of France?\",\n \"output\": \"Paris\",\n \"idealOutput\": \"<string>\",\n \"metadata\": {\n \"sessionId\": \"456\",\n \"userType\": \"admin\"\n },\n \"organization\": {\n \"id\": \"123\",\n \"name\": \"ACME\"\n },\n \"user\": {\n \"id\": \"123\",\n \"name\": \"John Doe\"\n },\n \"startTime\": \"2021-01-01T00:00:00Z\",\n \"endTime\": \"2021-01-01T00:00:00Z\",\n \"experiment\": {\n \"id\": \"123\"\n },\n \"logs\": [\n {\n \"id\": \"123\",\n \"type\": \"generation\",\n \"name\": \"qa-chatbot\",\n \"startTime\": \"2021-01-01T00:00:00Z\",\n \"endTime\": \"2021-01-01T00:00:00Z\",\n \"metadata\": {\n \"sessionId\": \"456\",\n \"userType\": \"admin\"\n }\n }\n ],\n \"evaluators\": [\n {\n \"slug\": \"hallucination\"\n }\n ],\n \"evaluationConfig\": {\n \"sampleRate\": 0.5\n }\n}")

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

req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")

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

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

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.getbasalt.ai/monitor/trace")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"qa-chatbot\",\n \"featureSlug\": \"qa-chatbot\",\n \"chainSlug\": \"qa-chatbot\",\n \"input\": \"What is the capital of France?\",\n \"output\": \"Paris\",\n \"idealOutput\": \"<string>\",\n \"metadata\": {\n \"sessionId\": \"456\",\n \"userType\": \"admin\"\n },\n \"organization\": {\n \"id\": \"123\",\n \"name\": \"ACME\"\n },\n \"user\": {\n \"id\": \"123\",\n \"name\": \"John Doe\"\n },\n \"startTime\": \"2021-01-01T00:00:00Z\",\n \"endTime\": \"2021-01-01T00:00:00Z\",\n \"experiment\": {\n \"id\": \"123\"\n },\n \"logs\": [\n {\n \"id\": \"123\",\n \"type\": \"generation\",\n \"name\": \"qa-chatbot\",\n \"startTime\": \"2021-01-01T00:00:00Z\",\n \"endTime\": \"2021-01-01T00:00:00Z\",\n \"metadata\": {\n \"sessionId\": \"456\",\n \"userType\": \"admin\"\n }\n }\n ],\n \"evaluators\": [\n {\n \"slug\": \"hallucination\"\n }\n ],\n \"evaluationConfig\": {\n \"sampleRate\": 0.5\n }\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.getbasalt.ai/monitor/trace")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"qa-chatbot\",\n \"featureSlug\": \"qa-chatbot\",\n \"chainSlug\": \"qa-chatbot\",\n \"input\": \"What is the capital of France?\",\n \"output\": \"Paris\",\n \"idealOutput\": \"<string>\",\n \"metadata\": {\n \"sessionId\": \"456\",\n \"userType\": \"admin\"\n },\n \"organization\": {\n \"id\": \"123\",\n \"name\": \"ACME\"\n },\n \"user\": {\n \"id\": \"123\",\n \"name\": \"John Doe\"\n },\n \"startTime\": \"2021-01-01T00:00:00Z\",\n \"endTime\": \"2021-01-01T00:00:00Z\",\n \"experiment\": {\n \"id\": \"123\"\n },\n \"logs\": [\n {\n \"id\": \"123\",\n \"type\": \"generation\",\n \"name\": \"qa-chatbot\",\n \"startTime\": \"2021-01-01T00:00:00Z\",\n \"endTime\": \"2021-01-01T00:00:00Z\",\n \"metadata\": {\n \"sessionId\": \"456\",\n \"userType\": \"admin\"\n }\n }\n ],\n \"evaluators\": [\n {\n \"slug\": \"hallucination\"\n }\n ],\n \"evaluationConfig\": {\n \"sampleRate\": 0.5\n }\n}"

response = http.request(request)
puts response.read_body
{
  "trace": {
    "id": "123"
  },
  "warning": "No prompt found with the given slug or no production version found or no prompt found with the given version or tag (production version also missing)"
}
{
"error": "<string>"
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
name
string | null

The name of the trace

Example:

"qa-chatbot"

featureSlug
string

The slug of the feature in Basalt.

Example:

"qa-chatbot"

chainSlug
string
deprecated

Deprecated: Use featureSlug instead. The slug of the feature in Basalt.

Example:

"qa-chatbot"

input

The input of the trace

Example:

"What is the capital of France?"

output

The output of the trace

Example:

"Paris"

idealOutput

The ideal output of the trace. Used in some evaluators.

metadata
object | null

Additional metadata to be associated with the trace.

Example:
{ "sessionId": "456", "userType": "admin" }
organization
object | null

The organization related to the trace. Used to identify the organization of the user that triggered the trace.

Example:
{ "id": "123", "name": "ACME" }
user
object | null

The user related to the trace. Used to identify the user that triggered the trace.

Example:
{ "id": "123", "name": "John Doe" }
startTime

The start time of the trace

Example:

"2021-01-01T00:00:00Z"

endTime

The end time of the trace

Example:

"2021-01-01T00:00:00Z"

experiment
object | null

The experiment to append the trace to. You must create an experiment before.

Example:
{ "id": "123" }
logs
object[] | null

The logs to append to the trace.

Example:
[
{
"id": "123",
"type": "generation",
"name": "qa-chatbot",
"startTime": "2021-01-01T00:00:00Z",
"endTime": "2021-01-01T00:00:00Z",
"metadata": { "sessionId": "456", "userType": "admin" }
}
]
evaluators
object[] | null

The evaluators used to generate the trace.

Example:
[{ "slug": "hallucination" }]
evaluationConfig
object | null

The evaluation configuration of the trace.

Example:
{ "sampleRate": 0.5 }

Response

The trace created

trace
object
required

The trace created

Example:
{ "id": "123" }
warning
string | null

The warning message

Example:

"No prompt found with the given slug or no production version found or no prompt found with the given version or tag (production version also missing)"