Skip to main content
POST
/
traces
Create trace
curl --request POST \
  --url https://api.galtea.ai/traces \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "inferenceResultId": "ir_123",
  "name": "Example Name",
  "inputData": {},
  "outputData": {},
  "error": "Error message",
  "latencyMs": 123,
  "metadata": {}
}
'
import requests

url = "https://api.galtea.ai/traces"

payload = {
"inferenceResultId": "ir_123",
"name": "Example Name",
"inputData": {},
"outputData": {},
"error": "Error message",
"latencyMs": 123,
"metadata": {}
}
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({
inferenceResultId: 'ir_123',
name: 'Example Name',
inputData: {},
outputData: {},
error: 'Error message',
latencyMs: 123,
metadata: {}
})
};

fetch('https://api.galtea.ai/traces', 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.galtea.ai/traces",
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([
'inferenceResultId' => 'ir_123',
'name' => 'Example Name',
'inputData' => [

],
'outputData' => [

],
'error' => 'Error message',
'latencyMs' => 123,
'metadata' => [

]
]),
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.galtea.ai/traces"

payload := strings.NewReader("{\n \"inferenceResultId\": \"ir_123\",\n \"name\": \"Example Name\",\n \"inputData\": {},\n \"outputData\": {},\n \"error\": \"Error message\",\n \"latencyMs\": 123,\n \"metadata\": {}\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.galtea.ai/traces")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"inferenceResultId\": \"ir_123\",\n \"name\": \"Example Name\",\n \"inputData\": {},\n \"outputData\": {},\n \"error\": \"Error message\",\n \"latencyMs\": 123,\n \"metadata\": {}\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.galtea.ai/traces")

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 \"inferenceResultId\": \"ir_123\",\n \"name\": \"Example Name\",\n \"inputData\": {},\n \"outputData\": {},\n \"error\": \"Error message\",\n \"latencyMs\": 123,\n \"metadata\": {}\n}"

response = http.request(request)
puts response.read_body
{
  "id": "trace_123",
  "inferenceResultId": "ir_123",
  "name": "fetch_user_data",
  "type": "TOOL",
  "description": "Fetches user data from the database by ID",
  "inputData": {
    "user_id": "123"
  },
  "outputData": {
    "name": "John Doe",
    "email": "john@example.com"
  },
  "error": "Connection timeout",
  "latencyMs": 45.5,
  "metadata": {
    "model": "gpt-4",
    "temperature": 0.7
  },
  "parentTraceId": "trace_parent_123",
  "startTime": "2023-11-07T05:31:56Z",
  "endTime": "2023-11-07T05:31:56Z",
  "createdAt": "2023-11-07T05:31:56Z",
  "deletedAt": "2023-11-07T05:31:56Z"
}
{
"error": "Error type",
"message": "Error message description"
}

Authorizations

Authorization
string
header
required

API key authorization. Pass your API key in the Authorization header as a Bearer token. Both new (gsk_*) and legacy (gsk-) API keys are accepted, e.g. Authorization: Bearer gsk_... or Authorization: Bearer gsk-....

Body

application/json
inferenceResultId
string
required
Example:

"ir_123"

name
string
required
Example:

"Example Name"

type
enum<string>
Available options:
SPAN,
GENERATION,
EVENT,
AGENT,
TOOL,
CHAIN,
RETRIEVER,
EVALUATOR,
EMBEDDING,
GUARDRAIL
inputData
object
outputData
object
error
string
Example:

"Error message"

latencyMs
number
metadata
object

Response

Trace created successfully

id
string
Example:

"trace_123"

inferenceResultId
string
Example:

"ir_123"

name
string
Example:

"fetch_user_data"

type
enum<string> | null
Available options:
SPAN,
GENERATION,
EVENT,
AGENT,
TOOL,
CHAIN,
RETRIEVER,
EVALUATOR,
EMBEDDING,
GUARDRAIL
Example:

"TOOL"

description
string | null

Human-readable description of the operation. Maximum 1MB.

Example:

"Fetches user data from the database by ID"

inputData
object | null

Input parameters passed to the operation

Example:
{ "user_id": "123" }
outputData
object | null

Result returned by the operation

Example:
{
"name": "John Doe",
"email": "john@example.com"
}
error
string | null

Error message if failed

Example:

"Connection timeout"

latencyMs
number | null

Execution time in milliseconds

Example:

45.5

metadata
object | null

Additional custom metadata

Example:
{ "model": "gpt-4", "temperature": 0.7 }
parentTraceId
string | null

ID of parent trace for hierarchical relationships

Example:

"trace_parent_123"

startTime
string<date-time> | null
endTime
string<date-time> | null
createdAt
string<date-time>
deletedAt
string<date-time> | null