Create 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
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
The name of the trace
"qa-chatbot"
The slug of the feature in Basalt.
"qa-chatbot"
Deprecated: Use featureSlug instead. The slug of the feature in Basalt.
"qa-chatbot"
The input of the trace
"What is the capital of France?"
The output of the trace
"Paris"
The ideal output of the trace. Used in some evaluators.
Additional metadata to be associated with the trace.
Show child attributes
Show child attributes
{ "sessionId": "456", "userType": "admin" }The organization related to the trace. Used to identify the organization of the user that triggered the trace.
Show child attributes
Show child attributes
{ "id": "123", "name": "ACME" }The user related to the trace. Used to identify the user that triggered the trace.
Show child attributes
Show child attributes
{ "id": "123", "name": "John Doe" }The start time of the trace
"2021-01-01T00:00:00Z"
The end time of the trace
"2021-01-01T00:00:00Z"
The experiment to append the trace to. You must create an experiment before.
Show child attributes
Show child attributes
{ "id": "123" }The logs to append to the trace.
- Option 1
- Option 2
Show child attributes
Show child attributes
[
{
"id": "123",
"type": "generation",
"name": "qa-chatbot",
"startTime": "2021-01-01T00:00:00Z",
"endTime": "2021-01-01T00:00:00Z",
"metadata": { "sessionId": "456", "userType": "admin" }
}
]The evaluators used to generate the trace.
Show child attributes
Show child attributes
[{ "slug": "hallucination" }]The evaluation configuration of the trace.
Show child attributes
Show child attributes
{ "sampleRate": 0.5 }Response
The trace created
Was this page helpful?
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>"
}