Create spans
curl --request POST \
--url https://api.example.com/v1/projects/{project_identifier}/spans \
--header 'Content-Type: application/json' \
--data '
{
"data": [
{
"attributes": {
"llm.model_name": "gpt-4",
"llm.token_count.completion": 50,
"llm.token_count.prompt": 100
},
"context": {
"span_id": "1a2b3c4d5e6f7a8b",
"trace_id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
},
"end_time": "2024-01-01T12:00:01Z",
"events": [],
"name": "llm_call",
"span_kind": "LLM",
"start_time": "2024-01-01T12:00:00Z",
"status_code": "OK",
"status_message": ""
}
]
}
'import requests
url = "https://api.example.com/v1/projects/{project_identifier}/spans"
payload = { "data": [
{
"attributes": {
"llm.model_name": "gpt-4",
"llm.token_count.completion": 50,
"llm.token_count.prompt": 100
},
"context": {
"span_id": "1a2b3c4d5e6f7a8b",
"trace_id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
},
"end_time": "2024-01-01T12:00:01Z",
"events": [],
"name": "llm_call",
"span_kind": "LLM",
"start_time": "2024-01-01T12:00:00Z",
"status_code": "OK",
"status_message": ""
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
attributes: {
'llm.model_name': 'gpt-4',
'llm.token_count.completion': 50,
'llm.token_count.prompt': 100
},
context: {span_id: '1a2b3c4d5e6f7a8b', trace_id: 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4'},
end_time: '2024-01-01T12:00:01Z',
events: [],
name: 'llm_call',
span_kind: 'LLM',
start_time: '2024-01-01T12:00:00Z',
status_code: 'OK',
status_message: ''
}
]
})
};
fetch('https://api.example.com/v1/projects/{project_identifier}/spans', 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.example.com/v1/projects/{project_identifier}/spans",
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([
'data' => [
[
'attributes' => [
'llm.model_name' => 'gpt-4',
'llm.token_count.completion' => 50,
'llm.token_count.prompt' => 100
],
'context' => [
'span_id' => '1a2b3c4d5e6f7a8b',
'trace_id' => 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4'
],
'end_time' => '2024-01-01T12:00:01Z',
'events' => [
],
'name' => 'llm_call',
'span_kind' => 'LLM',
'start_time' => '2024-01-01T12:00:00Z',
'status_code' => 'OK',
'status_message' => ''
]
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/v1/projects/{project_identifier}/spans"
payload := strings.NewReader("{\n \"data\": [\n {\n \"attributes\": {\n \"llm.model_name\": \"gpt-4\",\n \"llm.token_count.completion\": 50,\n \"llm.token_count.prompt\": 100\n },\n \"context\": {\n \"span_id\": \"1a2b3c4d5e6f7a8b\",\n \"trace_id\": \"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\"\n },\n \"end_time\": \"2024-01-01T12:00:01Z\",\n \"events\": [],\n \"name\": \"llm_call\",\n \"span_kind\": \"LLM\",\n \"start_time\": \"2024-01-01T12:00:00Z\",\n \"status_code\": \"OK\",\n \"status_message\": \"\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/projects/{project_identifier}/spans")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"attributes\": {\n \"llm.model_name\": \"gpt-4\",\n \"llm.token_count.completion\": 50,\n \"llm.token_count.prompt\": 100\n },\n \"context\": {\n \"span_id\": \"1a2b3c4d5e6f7a8b\",\n \"trace_id\": \"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\"\n },\n \"end_time\": \"2024-01-01T12:00:01Z\",\n \"events\": [],\n \"name\": \"llm_call\",\n \"span_kind\": \"LLM\",\n \"start_time\": \"2024-01-01T12:00:00Z\",\n \"status_code\": \"OK\",\n \"status_message\": \"\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/projects/{project_identifier}/spans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"attributes\": {\n \"llm.model_name\": \"gpt-4\",\n \"llm.token_count.completion\": 50,\n \"llm.token_count.prompt\": 100\n },\n \"context\": {\n \"span_id\": \"1a2b3c4d5e6f7a8b\",\n \"trace_id\": \"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\"\n },\n \"end_time\": \"2024-01-01T12:00:01Z\",\n \"events\": [],\n \"name\": \"llm_call\",\n \"span_kind\": \"LLM\",\n \"start_time\": \"2024-01-01T12:00:00Z\",\n \"status_code\": \"OK\",\n \"status_message\": \"\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"total_received": 123,
"total_queued": 123
}"<string>""<string>""<string>"{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Spans
Create spans
Submit spans to be inserted into a project. If any spans are invalid or duplicates, no spans will be inserted.
POST
/
v1
/
projects
/
{project_identifier}
/
spans
Create spans
curl --request POST \
--url https://api.example.com/v1/projects/{project_identifier}/spans \
--header 'Content-Type: application/json' \
--data '
{
"data": [
{
"attributes": {
"llm.model_name": "gpt-4",
"llm.token_count.completion": 50,
"llm.token_count.prompt": 100
},
"context": {
"span_id": "1a2b3c4d5e6f7a8b",
"trace_id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
},
"end_time": "2024-01-01T12:00:01Z",
"events": [],
"name": "llm_call",
"span_kind": "LLM",
"start_time": "2024-01-01T12:00:00Z",
"status_code": "OK",
"status_message": ""
}
]
}
'import requests
url = "https://api.example.com/v1/projects/{project_identifier}/spans"
payload = { "data": [
{
"attributes": {
"llm.model_name": "gpt-4",
"llm.token_count.completion": 50,
"llm.token_count.prompt": 100
},
"context": {
"span_id": "1a2b3c4d5e6f7a8b",
"trace_id": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4"
},
"end_time": "2024-01-01T12:00:01Z",
"events": [],
"name": "llm_call",
"span_kind": "LLM",
"start_time": "2024-01-01T12:00:00Z",
"status_code": "OK",
"status_message": ""
}
] }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
data: [
{
attributes: {
'llm.model_name': 'gpt-4',
'llm.token_count.completion': 50,
'llm.token_count.prompt': 100
},
context: {span_id: '1a2b3c4d5e6f7a8b', trace_id: 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4'},
end_time: '2024-01-01T12:00:01Z',
events: [],
name: 'llm_call',
span_kind: 'LLM',
start_time: '2024-01-01T12:00:00Z',
status_code: 'OK',
status_message: ''
}
]
})
};
fetch('https://api.example.com/v1/projects/{project_identifier}/spans', 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.example.com/v1/projects/{project_identifier}/spans",
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([
'data' => [
[
'attributes' => [
'llm.model_name' => 'gpt-4',
'llm.token_count.completion' => 50,
'llm.token_count.prompt' => 100
],
'context' => [
'span_id' => '1a2b3c4d5e6f7a8b',
'trace_id' => 'a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4'
],
'end_time' => '2024-01-01T12:00:01Z',
'events' => [
],
'name' => 'llm_call',
'span_kind' => 'LLM',
'start_time' => '2024-01-01T12:00:00Z',
'status_code' => 'OK',
'status_message' => ''
]
]
]),
CURLOPT_HTTPHEADER => [
"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.example.com/v1/projects/{project_identifier}/spans"
payload := strings.NewReader("{\n \"data\": [\n {\n \"attributes\": {\n \"llm.model_name\": \"gpt-4\",\n \"llm.token_count.completion\": 50,\n \"llm.token_count.prompt\": 100\n },\n \"context\": {\n \"span_id\": \"1a2b3c4d5e6f7a8b\",\n \"trace_id\": \"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\"\n },\n \"end_time\": \"2024-01-01T12:00:01Z\",\n \"events\": [],\n \"name\": \"llm_call\",\n \"span_kind\": \"LLM\",\n \"start_time\": \"2024-01-01T12:00:00Z\",\n \"status_code\": \"OK\",\n \"status_message\": \"\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
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.example.com/v1/projects/{project_identifier}/spans")
.header("Content-Type", "application/json")
.body("{\n \"data\": [\n {\n \"attributes\": {\n \"llm.model_name\": \"gpt-4\",\n \"llm.token_count.completion\": 50,\n \"llm.token_count.prompt\": 100\n },\n \"context\": {\n \"span_id\": \"1a2b3c4d5e6f7a8b\",\n \"trace_id\": \"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\"\n },\n \"end_time\": \"2024-01-01T12:00:01Z\",\n \"events\": [],\n \"name\": \"llm_call\",\n \"span_kind\": \"LLM\",\n \"start_time\": \"2024-01-01T12:00:00Z\",\n \"status_code\": \"OK\",\n \"status_message\": \"\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/v1/projects/{project_identifier}/spans")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"data\": [\n {\n \"attributes\": {\n \"llm.model_name\": \"gpt-4\",\n \"llm.token_count.completion\": 50,\n \"llm.token_count.prompt\": 100\n },\n \"context\": {\n \"span_id\": \"1a2b3c4d5e6f7a8b\",\n \"trace_id\": \"a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4\"\n },\n \"end_time\": \"2024-01-01T12:00:01Z\",\n \"events\": [],\n \"name\": \"llm_call\",\n \"span_kind\": \"LLM\",\n \"start_time\": \"2024-01-01T12:00:00Z\",\n \"status_code\": \"OK\",\n \"status_message\": \"\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"total_received": 123,
"total_queued": 123
}"<string>""<string>""<string>"{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Path Parameters
The project identifier: either project ID or project name. If using a project name, it cannot contain slash (/), question mark (?), or pound sign (#) characters.
Body
application/json
Show child attributes
Show child attributes
Was this page helpful?
⌘I

