Agents' prompt cache
curl --request GET \
--url https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache \
--header 'Authorization: Bearer <token>'import requests
url = "https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache', 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://{space}.{region}.api.niadra.com/v1/usage/prompt-cache",
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://{space}.{region}.api.niadra.com/v1/usage/prompt-cache"
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://{space}.{region}.api.niadra.com/v1/usage/prompt-cache")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache")
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{
"buckets": [
{
"cache_write_tokens": 123,
"cached_tokens": 123,
"calls": 123,
"prompt_tokens": 123,
"day": "2023-12-25",
"estimated_savings_micros": 123,
"hit_rate": 123,
"model": "<string>",
"provider": "<string>",
"source_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"unpriced_calls": 0,
"vendor": "<string>"
}
],
"group_by": [
"<string>"
],
"prices": [
{
"cache_write": 123,
"cached_input": 123,
"input": 123,
"model": "<string>",
"provider": "<string>",
"table": "product"
}
],
"prices_as_of": "<string>",
"since": "2023-12-25",
"until": "2023-12-25",
"estimate": true
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Patterns, measurement and usage
Agents' prompt cache
Tokens, the provider’s cache hit rate and the estimated savings, per agent, vendor or model.
GET
/
v1
/
usage
/
prompt-cache
Agents' prompt cache
curl --request GET \
--url https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache \
--header 'Authorization: Bearer <token>'import requests
url = "https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache', 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://{space}.{region}.api.niadra.com/v1/usage/prompt-cache",
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://{space}.{region}.api.niadra.com/v1/usage/prompt-cache"
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://{space}.{region}.api.niadra.com/v1/usage/prompt-cache")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{space}.{region}.api.niadra.com/v1/usage/prompt-cache")
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{
"buckets": [
{
"cache_write_tokens": 123,
"cached_tokens": 123,
"calls": 123,
"prompt_tokens": 123,
"day": "2023-12-25",
"estimated_savings_micros": 123,
"hit_rate": 123,
"model": "<string>",
"provider": "<string>",
"source_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"unpriced_calls": 0,
"vendor": "<string>"
}
],
"group_by": [
"<string>"
],
"prices": [
{
"cache_write": 123,
"cached_input": 123,
"input": 123,
"model": "<string>",
"provider": "<string>",
"table": "product"
}
],
"prices_as_of": "<string>",
"since": "2023-12-25",
"until": "2023-12-25",
"estimate": true
}{
"code": "<string>",
"status": 123,
"title": "<string>",
"detail": "<string>",
"request_id": "<string>",
"type": "about:blank"
}Authorizations
sourceKeypersonToken
nia_sk_...
Query Parameters
Response
Successful Response
GET /v1/usage/prompt-cache: the agents' prompt cache, from what the providers reported.
Show child attributes
Show child attributes
The price of every model the estimate used.
Show child attributes
Show child attributes
When the product's table was taken from the public price lists.
Always true: the savings are an estimate, never what a provider billed.

