curl --request GET \
--url https://api.moonbounce.ai/v1/decisions/{decision_id}/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonbounce.ai/v1/decisions/{decision_id}/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonbounce.ai/v1/decisions/{decision_id}/usage', 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.moonbounce.ai/v1/decisions/{decision_id}/usage",
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://api.moonbounce.ai/v1/decisions/{decision_id}/usage"
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://api.moonbounce.ai/v1/decisions/{decision_id}/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonbounce.ai/v1/decisions/{decision_id}/usage")
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{
"decision_id": "<string>",
"environment": "production",
"window": {
"since": "2023-11-07T05:31:56Z",
"until": "2023-11-07T05:31:56Z"
},
"evaluations": [
{
"engine_profile": "<string>",
"assignment_mode": "<string>",
"evaluations": 1,
"uncached": 1,
"engine_calls": 1,
"input_tokens": 1,
"output_tokens": 1,
"usd_micros": {
"total": 1,
"mean": 1,
"p50": 1,
"p95": 1
},
"estimated_usd_micros": 1
}
],
"engines": [
{
"engine": "<string>",
"resolved_model": "<string>",
"adapter": "<string>",
"calls": 1,
"failed": 1,
"input_tokens": 1,
"output_tokens": 1,
"usd_micros": 1,
"estimated_usd_micros": 1
}
],
"other_spend": [
{
"kind": "<string>",
"attempts": 1,
"engine_calls": 1,
"input_tokens": 1,
"output_tokens": 1,
"model_input_tokens": 1,
"model_output_tokens": 1,
"usd_micros": 1,
"estimated_usd_micros": 1
}
],
"total": {
"usd_micros": 1,
"estimated_usd_micros": 1
},
"previews": {
"runs": 1,
"features_run": 1,
"input_tokens": 1,
"usd_micros": 1,
"estimated_usd_micros": 1
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}Engine and model cost for a decision, per evaluation and in total
Engine cost of one decision’s evaluations and previews over a window; reads only. What the decision’s evaluations cost over a window, for the key’s organization and environment. Amounts are US dollars in micros (usd_micros: millionths of a dollar). Costs are what our engines reported, priced by each adapter from the vendor’s published price, plus an estimate for calls we couldn’t price from a vendor report (no usage reported, or a suggestion-writer model with no listed price), broken out as estimated_usd_micros; cache hits cost nothing. Evaluations that never committed and suggestion generation (its replays and model call) are in other_spend, outside the per-evaluation numbers, and total adds everything recorded. Per-request cost on evaluate and seeds is reported cost only. since (inclusive) and until (exclusive) are read to the millisecond and default to the last 30 days ending now; the window may span at most 366 days. A decision with no traffic in the window answers 200 with empty groups. The web session may not read it (403).
curl --request GET \
--url https://api.moonbounce.ai/v1/decisions/{decision_id}/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.moonbounce.ai/v1/decisions/{decision_id}/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.moonbounce.ai/v1/decisions/{decision_id}/usage', 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.moonbounce.ai/v1/decisions/{decision_id}/usage",
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://api.moonbounce.ai/v1/decisions/{decision_id}/usage"
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://api.moonbounce.ai/v1/decisions/{decision_id}/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.moonbounce.ai/v1/decisions/{decision_id}/usage")
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{
"decision_id": "<string>",
"environment": "production",
"window": {
"since": "2023-11-07T05:31:56Z",
"until": "2023-11-07T05:31:56Z"
},
"evaluations": [
{
"engine_profile": "<string>",
"assignment_mode": "<string>",
"evaluations": 1,
"uncached": 1,
"engine_calls": 1,
"input_tokens": 1,
"output_tokens": 1,
"usd_micros": {
"total": 1,
"mean": 1,
"p50": 1,
"p95": 1
},
"estimated_usd_micros": 1
}
],
"engines": [
{
"engine": "<string>",
"resolved_model": "<string>",
"adapter": "<string>",
"calls": 1,
"failed": 1,
"input_tokens": 1,
"output_tokens": 1,
"usd_micros": 1,
"estimated_usd_micros": 1
}
],
"other_spend": [
{
"kind": "<string>",
"attempts": 1,
"engine_calls": 1,
"input_tokens": 1,
"output_tokens": 1,
"model_input_tokens": 1,
"model_output_tokens": 1,
"usd_micros": 1,
"estimated_usd_micros": 1
}
],
"total": {
"usd_micros": 1,
"estimated_usd_micros": 1
},
"previews": {
"runs": 1,
"features_run": 1,
"input_tokens": 1,
"usd_micros": 1,
"estimated_usd_micros": 1
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}{
"error": {
"type": "invalid_request",
"message": "<string>",
"reason": "<string>",
"param": "<string>",
"details": {}
}
}Authorizations
An API key, sent as Authorization: Bearer <key>. Each operation lists the scope its key needs: decisions:evaluate (evaluate and read evaluations), decisions:feedback (your app's feedback) or decisions:develop (everything else, including owner feedback and the review queue). An operation listing no scope takes any scoped key. A key with no scope, or without the operation's, gets 403 INSUFFICIENT_SCOPE.
Path Parameters
^[a-z][a-z0-9_.-]{0,127}$Query Parameters
Start of the window, inclusive. Default: until - 30 days.
End of the window, exclusive. Default: now.
Response
The decision's cost report
^[a-z][a-z0-9_.-]{0,127}$The environment of the key that made the call: production or test. Evaluations, feedback, reviews and suggestions are separate per environment; registered structures are shared.
production, test Show child attributes
Show child attributes
One group per engine profile and assignment mode, ordered by both. Spend whose evaluation is gone is grouped under unknown, as is dry-run spend, which has no evaluation.
Show child attributes
Show child attributes
One group per engine, resolved model and adapter, from the per-call traces. Evaluations stored before traces existed and dry runs contribute none.
Show child attributes
Show child attributes
Spend that is not an evaluation, one group per kind, kept out of the per-evaluation numbers.
Show child attributes
Show child attributes
Everything recorded above: evaluations, other spend and previews.
Show child attributes
Show child attributes
Stored preview runs in the window (mb test, previews, and the one preview each generated suggestion runs), which write no evaluations. Generation's exploratory replays and model call are in other_spend, as is a preview run that stored nothing (uncommitted).
Show child attributes
Show child attributes