curl --request GET \
--url https://cloud-api.near.ai/v1/organizations/{org_id}/usage/export \
--header 'Authorization: Bearer <token>'import requests
url = "https://cloud-api.near.ai/v1/organizations/{org_id}/usage/export"
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/export', 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/export",
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/export"
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/export")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud-api.near.ai/v1/organizations/{org_id}/usage/export")
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{
"data": [
{
"inference": {
"cache_read_tokens": 123,
"inference_type": "<string>",
"input_cost_nano_usd": 123,
"input_tokens": 123,
"model": "<string>",
"output_cost_nano_usd": 123,
"output_tokens": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123,
"cache_read_cost_nano_usd": 123,
"image_count": 123,
"inference_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"response_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"source": "inference",
"api_key_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"total_cost_nano_usd": 123,
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"total_cost_usd": "<string>"
}
],
"next_cursor": "<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>"
}
}Export organization usage and cost rows.
Requires a reporting token scoped to the organization in the path. Results
are returned in descending (created_at, source, id) order with opaque
cursor pagination.
curl --request GET \
--url https://cloud-api.near.ai/v1/organizations/{org_id}/usage/export \
--header 'Authorization: Bearer <token>'import requests
url = "https://cloud-api.near.ai/v1/organizations/{org_id}/usage/export"
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/export', 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/export",
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/export"
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/export")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud-api.near.ai/v1/organizations/{org_id}/usage/export")
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{
"data": [
{
"inference": {
"cache_read_tokens": 123,
"inference_type": "<string>",
"input_cost_nano_usd": 123,
"input_tokens": 123,
"model": "<string>",
"output_cost_nano_usd": 123,
"output_tokens": 123,
"total_cost_nano_usd": 123,
"total_tokens": 123,
"cache_read_cost_nano_usd": 123,
"image_count": 123,
"inference_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"response_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a"
},
"source": "inference",
"api_key_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"created_at": "2023-11-07T05:31:56Z",
"id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"total_cost_nano_usd": 123,
"workspace_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"total_cost_usd": "<string>"
}
],
"next_cursor": "<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 export. Defaults to all.
all, inference, service Filter by workspace ID.
Filter by API key ID.
Filter inference rows by model name.
Filter inference rows by inference type.
Filter service rows by platform service name.
Maximum rows to return. Defaults to 100 and must not exceed 1000.
x >= 0Opaque cursor returned by the previous export page.