curl --request GET \
--url https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary \
--header 'Authorization: Bearer <token>'import requests
url = "https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary', 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://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"by_api_key": [
{
"api_key_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"request_count": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123
}
],
"by_day": [
{
"cache_read_tokens": 123,
"day": "<string>",
"inference_cost_nano_usd": 123,
"input_tokens": 123,
"output_tokens": 123,
"request_count": 123,
"service_cost_nano_usd": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123
}
],
"by_model": [
{
"cache_read_tokens": 123,
"input_tokens": 123,
"model": "<string>",
"output_tokens": 123,
"request_count": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123
}
],
"by_service": [
{
"quantity": 123,
"service_name": "<string>",
"total_cost_nano_usd": 123,
"usage_count": 123
}
],
"by_workspace": [
{
"request_count": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123,
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"end_time": "2023-11-07T05:31:56Z",
"source": "all",
"start_time": "2023-11-07T05:31:56Z",
"totals": {
"cache_read_tokens": 123,
"inference_cost_nano_usd": 123,
"input_tokens": 123,
"output_tokens": 123,
"request_count": 123,
"service_cost_nano_usd": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123,
"total_cost_usd": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Summarize organization usage and costs.
Requires a reporting token scoped to the organization in the path. Totals include inference and platform service usage by default.
curl --request GET \
--url https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary \
--header 'Authorization: Bearer <token>'import requests
url = "https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary', 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://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud-api.near.ai/v1/organizations/{org_id}/usage/summary")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"by_api_key": [
{
"api_key_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"request_count": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123
}
],
"by_day": [
{
"cache_read_tokens": 123,
"day": "<string>",
"inference_cost_nano_usd": 123,
"input_tokens": 123,
"output_tokens": 123,
"request_count": 123,
"service_cost_nano_usd": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123
}
],
"by_model": [
{
"cache_read_tokens": 123,
"input_tokens": 123,
"model": "<string>",
"output_tokens": 123,
"request_count": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123
}
],
"by_service": [
{
"quantity": 123,
"service_name": "<string>",
"total_cost_nano_usd": 123,
"usage_count": 123
}
],
"by_workspace": [
{
"request_count": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123,
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
}
],
"end_time": "2023-11-07T05:31:56Z",
"source": "all",
"start_time": "2023-11-07T05:31:56Z",
"totals": {
"cache_read_tokens": 123,
"inference_cost_nano_usd": 123,
"input_tokens": 123,
"output_tokens": 123,
"request_count": 123,
"service_cost_nano_usd": 123,
"service_usage_count": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123,
"total_cost_usd": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}{
"error": {
"message": "<string>",
"type": "<string>",
"code": "<string>",
"param": "<string>"
}
}Authorizations
Read-only reporting token for usage reporting endpoints (Authorization: Bearer rpt-<reporting_token>)
Path Parameters
Organization ID
Query Parameters
Inclusive RFC3339 start timestamp. Defaults to 366 days before the effective end_time.
Inclusive RFC3339 end timestamp. Defaults to the request time. The effective range must not exceed 366 days.
Usage source to summarize. Defaults to all.
all, inference, service Filter by workspace ID.
Filter by API key ID.
Filter inference usage by model name.
Filter inference usage by inference type.
Filter service usage by platform service name.
Response
Usage summary
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
all, inference, service Show child attributes
Show child attributes