import os
from datetime import datetime
from scale_gp import SGPClient
client = SGPClient(
api_key=os.environ.get("SGP_API_KEY"), # This is the default and can be omitted
)
interaction = client.interactions.create(
application_variant_id="application_variant_id",
input={
"query": "query"
},
output={
"response": "response"
},
start_timestamp=datetime.fromisoformat("2019-12-27T18:11:19.117"),
)
print(interaction.id)package main
import (
"context"
"fmt"
"time"
"github.com/stainless-sdks/sgp-go"
"github.com/stainless-sdks/sgp-go/option"
)
func main() {
client := sgp.NewClient(
option.WithAPIKey("My API Key"),
)
interaction, err := client.Interactions.New(context.TODO(), sgp.InteractionNewParams{
ApplicationVariantID: sgp.F("application_variant_id"),
Input: sgp.F(sgp.InteractionNewParamsInput{
Query: sgp.F("query"),
}),
Output: sgp.F(sgp.InteractionNewParamsOutput{
Response: sgp.F("response"),
}),
StartTimestamp: sgp.F(time.Now()),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", interaction.ID)
}curl --request POST \
--url https://api.egp.scale.com/v4/interactions/ \
--header 'Content-Type: application/json' \
--data '
{
"application_variant_id": "<string>",
"input": {
"query": "<string>"
},
"output": {
"response": "<string>",
"context": [
{
"text": "<string>",
"score": 123
}
]
},
"start_timestamp": "2023-11-07T05:31:56Z",
"thread_id": "<string>",
"duration_ms": 0,
"operation_status": "SUCCESS",
"operation_metadata": {},
"trace_spans": [
{
"node_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"operation_status": "SUCCESS",
"end_timestamp": "2023-11-07T05:31:56Z",
"operation_input": {},
"operation_output": {},
"operation_metadata": {},
"duration_ms": 0,
"account_id": "<string>"
}
]
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
application_variant_id: '<string>',
input: {query: '<string>'},
output: {response: '<string>', context: [{text: '<string>', score: 123}]},
start_timestamp: '2023-11-07T05:31:56Z',
thread_id: '<string>',
duration_ms: 0,
operation_status: 'SUCCESS',
operation_metadata: {},
trace_spans: [
{
node_id: '<string>',
start_timestamp: '2023-11-07T05:31:56Z',
operation_status: 'SUCCESS',
end_timestamp: '2023-11-07T05:31:56Z',
operation_input: {},
operation_output: {},
operation_metadata: {},
duration_ms: 0,
account_id: '<string>'
}
]
})
};
fetch('https://api.egp.scale.com/v4/interactions/', 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.egp.scale.com/v4/interactions/",
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([
'application_variant_id' => '<string>',
'input' => [
'query' => '<string>'
],
'output' => [
'response' => '<string>',
'context' => [
[
'text' => '<string>',
'score' => 123
]
]
],
'start_timestamp' => '2023-11-07T05:31:56Z',
'thread_id' => '<string>',
'duration_ms' => 0,
'operation_status' => 'SUCCESS',
'operation_metadata' => [
],
'trace_spans' => [
[
'node_id' => '<string>',
'start_timestamp' => '2023-11-07T05:31:56Z',
'operation_status' => 'SUCCESS',
'end_timestamp' => '2023-11-07T05:31:56Z',
'operation_input' => [
],
'operation_output' => [
],
'operation_metadata' => [
],
'duration_ms' => 0,
'account_id' => '<string>'
]
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://api.egp.scale.com/v4/interactions/")
.header("Content-Type", "application/json")
.body("{\n \"application_variant_id\": \"<string>\",\n \"input\": {\n \"query\": \"<string>\"\n },\n \"output\": {\n \"response\": \"<string>\",\n \"context\": [\n {\n \"text\": \"<string>\",\n \"score\": 123\n }\n ]\n },\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"thread_id\": \"<string>\",\n \"duration_ms\": 0,\n \"operation_status\": \"SUCCESS\",\n \"operation_metadata\": {},\n \"trace_spans\": [\n {\n \"node_id\": \"<string>\",\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_status\": \"SUCCESS\",\n \"end_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_input\": {},\n \"operation_output\": {},\n \"operation_metadata\": {},\n \"duration_ms\": 0,\n \"account_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.egp.scale.com/v4/interactions/")
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 \"application_variant_id\": \"<string>\",\n \"input\": {\n \"query\": \"<string>\"\n },\n \"output\": {\n \"response\": \"<string>\",\n \"context\": [\n {\n \"text\": \"<string>\",\n \"score\": 123\n }\n ]\n },\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"thread_id\": \"<string>\",\n \"duration_ms\": 0,\n \"operation_status\": \"SUCCESS\",\n \"operation_metadata\": {},\n \"trace_spans\": [\n {\n \"node_id\": \"<string>\",\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_status\": \"SUCCESS\",\n \"end_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_input\": {},\n \"operation_output\": {},\n \"operation_metadata\": {},\n \"duration_ms\": 0,\n \"account_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"application_variant_id": "<string>",
"input": {
"query": "<string>"
},
"output": {
"response": "<string>",
"context": [
{
"text": "<string>",
"score": 123
}
]
},
"start_timestamp": "2023-11-07T05:31:56Z",
"id": "<string>",
"thread_id": "<string>",
"duration_ms": 0,
"operation_status": "SUCCESS",
"operation_metadata": {},
"trace_spans": [
{
"node_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"id": "<string>",
"application_interaction_id": "<string>",
"operation_status": "SUCCESS",
"end_timestamp": "2023-11-07T05:31:56Z",
"operation_input": {},
"operation_output": {},
"operation_metadata": {},
"duration_ms": 0,
"account_id": "<string>"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Create Application Interaction
import os
from datetime import datetime
from scale_gp import SGPClient
client = SGPClient(
api_key=os.environ.get("SGP_API_KEY"), # This is the default and can be omitted
)
interaction = client.interactions.create(
application_variant_id="application_variant_id",
input={
"query": "query"
},
output={
"response": "response"
},
start_timestamp=datetime.fromisoformat("2019-12-27T18:11:19.117"),
)
print(interaction.id)package main
import (
"context"
"fmt"
"time"
"github.com/stainless-sdks/sgp-go"
"github.com/stainless-sdks/sgp-go/option"
)
func main() {
client := sgp.NewClient(
option.WithAPIKey("My API Key"),
)
interaction, err := client.Interactions.New(context.TODO(), sgp.InteractionNewParams{
ApplicationVariantID: sgp.F("application_variant_id"),
Input: sgp.F(sgp.InteractionNewParamsInput{
Query: sgp.F("query"),
}),
Output: sgp.F(sgp.InteractionNewParamsOutput{
Response: sgp.F("response"),
}),
StartTimestamp: sgp.F(time.Now()),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", interaction.ID)
}curl --request POST \
--url https://api.egp.scale.com/v4/interactions/ \
--header 'Content-Type: application/json' \
--data '
{
"application_variant_id": "<string>",
"input": {
"query": "<string>"
},
"output": {
"response": "<string>",
"context": [
{
"text": "<string>",
"score": 123
}
]
},
"start_timestamp": "2023-11-07T05:31:56Z",
"thread_id": "<string>",
"duration_ms": 0,
"operation_status": "SUCCESS",
"operation_metadata": {},
"trace_spans": [
{
"node_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"operation_status": "SUCCESS",
"end_timestamp": "2023-11-07T05:31:56Z",
"operation_input": {},
"operation_output": {},
"operation_metadata": {},
"duration_ms": 0,
"account_id": "<string>"
}
]
}
'const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
application_variant_id: '<string>',
input: {query: '<string>'},
output: {response: '<string>', context: [{text: '<string>', score: 123}]},
start_timestamp: '2023-11-07T05:31:56Z',
thread_id: '<string>',
duration_ms: 0,
operation_status: 'SUCCESS',
operation_metadata: {},
trace_spans: [
{
node_id: '<string>',
start_timestamp: '2023-11-07T05:31:56Z',
operation_status: 'SUCCESS',
end_timestamp: '2023-11-07T05:31:56Z',
operation_input: {},
operation_output: {},
operation_metadata: {},
duration_ms: 0,
account_id: '<string>'
}
]
})
};
fetch('https://api.egp.scale.com/v4/interactions/', 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.egp.scale.com/v4/interactions/",
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([
'application_variant_id' => '<string>',
'input' => [
'query' => '<string>'
],
'output' => [
'response' => '<string>',
'context' => [
[
'text' => '<string>',
'score' => 123
]
]
],
'start_timestamp' => '2023-11-07T05:31:56Z',
'thread_id' => '<string>',
'duration_ms' => 0,
'operation_status' => 'SUCCESS',
'operation_metadata' => [
],
'trace_spans' => [
[
'node_id' => '<string>',
'start_timestamp' => '2023-11-07T05:31:56Z',
'operation_status' => 'SUCCESS',
'end_timestamp' => '2023-11-07T05:31:56Z',
'operation_input' => [
],
'operation_output' => [
],
'operation_metadata' => [
],
'duration_ms' => 0,
'account_id' => '<string>'
]
]
]),
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;
}HttpResponse<String> response = Unirest.post("https://api.egp.scale.com/v4/interactions/")
.header("Content-Type", "application/json")
.body("{\n \"application_variant_id\": \"<string>\",\n \"input\": {\n \"query\": \"<string>\"\n },\n \"output\": {\n \"response\": \"<string>\",\n \"context\": [\n {\n \"text\": \"<string>\",\n \"score\": 123\n }\n ]\n },\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"thread_id\": \"<string>\",\n \"duration_ms\": 0,\n \"operation_status\": \"SUCCESS\",\n \"operation_metadata\": {},\n \"trace_spans\": [\n {\n \"node_id\": \"<string>\",\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_status\": \"SUCCESS\",\n \"end_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_input\": {},\n \"operation_output\": {},\n \"operation_metadata\": {},\n \"duration_ms\": 0,\n \"account_id\": \"<string>\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.egp.scale.com/v4/interactions/")
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 \"application_variant_id\": \"<string>\",\n \"input\": {\n \"query\": \"<string>\"\n },\n \"output\": {\n \"response\": \"<string>\",\n \"context\": [\n {\n \"text\": \"<string>\",\n \"score\": 123\n }\n ]\n },\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"thread_id\": \"<string>\",\n \"duration_ms\": 0,\n \"operation_status\": \"SUCCESS\",\n \"operation_metadata\": {},\n \"trace_spans\": [\n {\n \"node_id\": \"<string>\",\n \"start_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_status\": \"SUCCESS\",\n \"end_timestamp\": \"2023-11-07T05:31:56Z\",\n \"operation_input\": {},\n \"operation_output\": {},\n \"operation_metadata\": {},\n \"duration_ms\": 0,\n \"account_id\": \"<string>\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"application_variant_id": "<string>",
"input": {
"query": "<string>"
},
"output": {
"response": "<string>",
"context": [
{
"text": "<string>",
"score": 123
}
]
},
"start_timestamp": "2023-11-07T05:31:56Z",
"id": "<string>",
"thread_id": "<string>",
"duration_ms": 0,
"operation_status": "SUCCESS",
"operation_metadata": {},
"trace_spans": [
{
"node_id": "<string>",
"start_timestamp": "2023-11-07T05:31:56Z",
"id": "<string>",
"application_interaction_id": "<string>",
"operation_status": "SUCCESS",
"end_timestamp": "2023-11-07T05:31:56Z",
"operation_input": {},
"operation_output": {},
"operation_metadata": {},
"duration_ms": 0,
"account_id": "<string>"
}
]
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Body
Represents an interaction performed with an application, including input, output, and associated metadata.
Identifier for the application variant that performed this interaction.
The input data for the interaction.
Show child attributes
Show child attributes
The output data from the interaction.
Show child attributes
Show child attributes
Timestamp marking the start of the interaction.
Optional UUID identifying the conversation thread associated with the interaction.The interaction will be associated with the thread if the id represents an existing thread.If the thread with the specified id is not found, a new thread will be created.
Duration of the interaction in milliseconds.
The outcome status of the interaction.
SUCCESS, ERROR Optional metadata related to the operation, including custom or predefined keys.
List of trace spans associated with the interaction.These spans provide insight into the individual steps taken by nodes involved in generating the output.
Show child attributes
Show child attributes
Response
Successful Response
Model representing an interaction entity.
Identifier for the application variant that performed this interaction.
The input data for the interaction.
Show child attributes
Show child attributes
The output data from the interaction.
Show child attributes
Show child attributes
Timestamp marking the start of the interaction.
Unique identifier for the interaction.
Optional UUID identifying the conversation thread associated with the interaction.The interaction will be associated with the thread if the id represents an existing thread.If the thread with the specified id is not found, a new thread will be created.
Duration of the interaction in milliseconds.
The outcome status of the interaction.
SUCCESS, ERROR Optional metadata related to the operation, including custom or predefined keys.
List of trace span entities associated with the interaction.
Show child attributes
Show child attributes

