Python
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
)
model_usage = client.models.deployments.usage_statistics.retrieve(
model_deployment_id="model_deployment_id",
chunks=0,
end_date=datetime.fromisoformat("2019-12-27T18:11:19.117"),
start_date=datetime.fromisoformat("2019-12-27T18:11:19.117"),
)
print(model_usage.data)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"),
)
modelUsage, err := client.Models.Deployments.UsageStatistics.Get(
context.TODO(),
"model_deployment_id",
sgp.ModelDeploymentUsageStatisticGetParams{
Chunks: sgp.F(int64(0)),
EndDate: sgp.F(time.Now()),
StartDate: sgp.F(time.Now()),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", modelUsage.Data)
}curl --request GET \
--url https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statisticsconst options = {method: 'GET'};
fetch('https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statistics', 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/model-deployments/{model_deployment_id}/usage-statistics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statistics")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statistics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": [
{
"date": "2023-11-07T05:31:56Z",
"prompt_tokens": 123,
"response_tokens": 123,
"summary_tokens": 123
}
],
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Models
Get Model usage for one deployment
GET
/
v4
/
model-deployments
/
{model_deployment_id}
/
usage-statistics
Python
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
)
model_usage = client.models.deployments.usage_statistics.retrieve(
model_deployment_id="model_deployment_id",
chunks=0,
end_date=datetime.fromisoformat("2019-12-27T18:11:19.117"),
start_date=datetime.fromisoformat("2019-12-27T18:11:19.117"),
)
print(model_usage.data)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"),
)
modelUsage, err := client.Models.Deployments.UsageStatistics.Get(
context.TODO(),
"model_deployment_id",
sgp.ModelDeploymentUsageStatisticGetParams{
Chunks: sgp.F(int64(0)),
EndDate: sgp.F(time.Now()),
StartDate: sgp.F(time.Now()),
},
)
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", modelUsage.Data)
}curl --request GET \
--url https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statisticsconst options = {method: 'GET'};
fetch('https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statistics', 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/model-deployments/{model_deployment_id}/usage-statistics",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.get("https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statistics")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.egp.scale.com/v4/model-deployments/{model_deployment_id}/usage-statistics")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
response = http.request(request)
puts response.read_body{
"data": [
{
"date": "2023-11-07T05:31:56Z",
"prompt_tokens": 123,
"response_tokens": 123,
"summary_tokens": 123
}
],
"start_date": "2023-11-07T05:31:56Z",
"end_date": "2023-11-07T05:31:56Z"
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>",
"input": "<unknown>",
"ctx": {}
}
]
}Path Parameters
Query Parameters
Response
Successful Response
The list of data points for the given period
Show child attributes
Show child attributes
The start date of the data points. Equal to the first date in the data list
The end date of the data points. Equal to the last date in the data list
⌘I

