Skip to main content
POST
/
api
/
v1
/
analytics
/
turns
Create Turn Metrics
curl --request POST \
  --url https://control-plane.kubiya.ai/api/v1/analytics/turns \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "execution_id": "<string>",
  "turn_number": 123,
  "model": "<string>",
  "started_at": "<string>",
  "turn_id": "<string>",
  "model_provider": "<string>",
  "completed_at": "<string>",
  "duration_ms": 123,
  "input_tokens": 0,
  "output_tokens": 0,
  "cache_read_tokens": 0,
  "cache_creation_tokens": 0,
  "total_tokens": 0,
  "input_cost": 0,
  "output_cost": 0,
  "cache_read_cost": 0,
  "cache_creation_cost": 0,
  "total_cost": 0,
  "finish_reason": "<string>",
  "response_preview": "<string>",
  "tools_called_count": 0,
  "tools_called_names": [
    "<string>"
  ],
  "error_message": "<string>",
  "metrics": {},
  "runtime_minutes": 0,
  "model_weight": 1,
  "tool_calls_weight": 1,
  "aem_value": 0,
  "aem_cost": 0
}
'
import requests

url = "https://control-plane.kubiya.ai/api/v1/analytics/turns"

payload = {
    "execution_id": "<string>",
    "turn_number": 123,
    "model": "<string>",
    "started_at": "<string>",
    "turn_id": "<string>",
    "model_provider": "<string>",
    "completed_at": "<string>",
    "duration_ms": 123,
    "input_tokens": 0,
    "output_tokens": 0,
    "cache_read_tokens": 0,
    "cache_creation_tokens": 0,
    "total_tokens": 0,
    "input_cost": 0,
    "output_cost": 0,
    "cache_read_cost": 0,
    "cache_creation_cost": 0,
    "total_cost": 0,
    "finish_reason": "<string>",
    "response_preview": "<string>",
    "tools_called_count": 0,
    "tools_called_names": ["<string>"],
    "error_message": "<string>",
    "metrics": {},
    "runtime_minutes": 0,
    "model_weight": 1,
    "tool_calls_weight": 1,
    "aem_value": 0,
    "aem_cost": 0
}
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({
    execution_id: '<string>',
    turn_number: 123,
    model: '<string>',
    started_at: '<string>',
    turn_id: '<string>',
    model_provider: '<string>',
    completed_at: '<string>',
    duration_ms: 123,
    input_tokens: 0,
    output_tokens: 0,
    cache_read_tokens: 0,
    cache_creation_tokens: 0,
    total_tokens: 0,
    input_cost: 0,
    output_cost: 0,
    cache_read_cost: 0,
    cache_creation_cost: 0,
    total_cost: 0,
    finish_reason: '<string>',
    response_preview: '<string>',
    tools_called_count: 0,
    tools_called_names: ['<string>'],
    error_message: '<string>',
    metrics: {},
    runtime_minutes: 0,
    model_weight: 1,
    tool_calls_weight: 1,
    aem_value: 0,
    aem_cost: 0
  })
};

fetch('https://control-plane.kubiya.ai/api/v1/analytics/turns', 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://control-plane.kubiya.ai/api/v1/analytics/turns",
  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([
    'execution_id' => '<string>',
    'turn_number' => 123,
    'model' => '<string>',
    'started_at' => '<string>',
    'turn_id' => '<string>',
    'model_provider' => '<string>',
    'completed_at' => '<string>',
    'duration_ms' => 123,
    'input_tokens' => 0,
    'output_tokens' => 0,
    'cache_read_tokens' => 0,
    'cache_creation_tokens' => 0,
    'total_tokens' => 0,
    'input_cost' => 0,
    'output_cost' => 0,
    'cache_read_cost' => 0,
    'cache_creation_cost' => 0,
    'total_cost' => 0,
    'finish_reason' => '<string>',
    'response_preview' => '<string>',
    'tools_called_count' => 0,
    'tools_called_names' => [
        '<string>'
    ],
    'error_message' => '<string>',
    'metrics' => [
        
    ],
    'runtime_minutes' => 0,
    'model_weight' => 1,
    'tool_calls_weight' => 1,
    'aem_value' => 0,
    'aem_cost' => 0
  ]),
  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://control-plane.kubiya.ai/api/v1/analytics/turns"

	payload := strings.NewReader("{\n  \"execution_id\": \"<string>\",\n  \"turn_number\": 123,\n  \"model\": \"<string>\",\n  \"started_at\": \"<string>\",\n  \"turn_id\": \"<string>\",\n  \"model_provider\": \"<string>\",\n  \"completed_at\": \"<string>\",\n  \"duration_ms\": 123,\n  \"input_tokens\": 0,\n  \"output_tokens\": 0,\n  \"cache_read_tokens\": 0,\n  \"cache_creation_tokens\": 0,\n  \"total_tokens\": 0,\n  \"input_cost\": 0,\n  \"output_cost\": 0,\n  \"cache_read_cost\": 0,\n  \"cache_creation_cost\": 0,\n  \"total_cost\": 0,\n  \"finish_reason\": \"<string>\",\n  \"response_preview\": \"<string>\",\n  \"tools_called_count\": 0,\n  \"tools_called_names\": [\n    \"<string>\"\n  ],\n  \"error_message\": \"<string>\",\n  \"metrics\": {},\n  \"runtime_minutes\": 0,\n  \"model_weight\": 1,\n  \"tool_calls_weight\": 1,\n  \"aem_value\": 0,\n  \"aem_cost\": 0\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://control-plane.kubiya.ai/api/v1/analytics/turns")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n  \"execution_id\": \"<string>\",\n  \"turn_number\": 123,\n  \"model\": \"<string>\",\n  \"started_at\": \"<string>\",\n  \"turn_id\": \"<string>\",\n  \"model_provider\": \"<string>\",\n  \"completed_at\": \"<string>\",\n  \"duration_ms\": 123,\n  \"input_tokens\": 0,\n  \"output_tokens\": 0,\n  \"cache_read_tokens\": 0,\n  \"cache_creation_tokens\": 0,\n  \"total_tokens\": 0,\n  \"input_cost\": 0,\n  \"output_cost\": 0,\n  \"cache_read_cost\": 0,\n  \"cache_creation_cost\": 0,\n  \"total_cost\": 0,\n  \"finish_reason\": \"<string>\",\n  \"response_preview\": \"<string>\",\n  \"tools_called_count\": 0,\n  \"tools_called_names\": [\n    \"<string>\"\n  ],\n  \"error_message\": \"<string>\",\n  \"metrics\": {},\n  \"runtime_minutes\": 0,\n  \"model_weight\": 1,\n  \"tool_calls_weight\": 1,\n  \"aem_value\": 0,\n  \"aem_cost\": 0\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://control-plane.kubiya.ai/api/v1/analytics/turns")

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  \"execution_id\": \"<string>\",\n  \"turn_number\": 123,\n  \"model\": \"<string>\",\n  \"started_at\": \"<string>\",\n  \"turn_id\": \"<string>\",\n  \"model_provider\": \"<string>\",\n  \"completed_at\": \"<string>\",\n  \"duration_ms\": 123,\n  \"input_tokens\": 0,\n  \"output_tokens\": 0,\n  \"cache_read_tokens\": 0,\n  \"cache_creation_tokens\": 0,\n  \"total_tokens\": 0,\n  \"input_cost\": 0,\n  \"output_cost\": 0,\n  \"cache_read_cost\": 0,\n  \"cache_creation_cost\": 0,\n  \"total_cost\": 0,\n  \"finish_reason\": \"<string>\",\n  \"response_preview\": \"<string>\",\n  \"tools_called_count\": 0,\n  \"tools_called_names\": [\n    \"<string>\"\n  ],\n  \"error_message\": \"<string>\",\n  \"metrics\": {},\n  \"runtime_minutes\": 0,\n  \"model_weight\": 1,\n  \"tool_calls_weight\": 1,\n  \"aem_value\": 0,\n  \"aem_cost\": 0\n}"

response = http.request(request)
puts response.read_body
{
  "detail": [
    {
      "loc": [
        "<string>"
      ],
      "msg": "<string>",
      "type": "<string>"
    }
  ]
}

Authorizations

Authorization
string
header
required

Enter your Kubiya API token (format: Bearer )

Body

application/json

Schema for creating a turn metrics record

execution_id
string
required
turn_number
integer
required
model
string
required
started_at
string
required
turn_id
string | null
model_provider
string | null
completed_at
string | null
duration_ms
integer | null
input_tokens
integer
default:0
output_tokens
integer
default:0
cache_read_tokens
integer
default:0
cache_creation_tokens
integer
default:0
total_tokens
integer
default:0
input_cost
number
default:0
output_cost
number
default:0
cache_read_cost
number
default:0
cache_creation_cost
number
default:0
total_cost
number
default:0
finish_reason
string | null
response_preview
string | null
tools_called_count
integer
default:0
tools_called_names
string[]
error_message
string | null
metrics
Metrics · object
runtime_minutes
number
default:0
model_weight
number
default:1
tool_calls_weight
number
default:1
aem_value
number
default:0
aem_cost
number
default:0

Response

Successful Response