curl --request GET \
--url https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost \
--header 'Authorization: Bearer <token>'import requests
url = "https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost', 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://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost",
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://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost"
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://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost")
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{
"cost_totals": {},
"costs": {},
"end_date": "<string>",
"interval": "<string>",
"start_date": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Get App Cost
Retrieve cost breakdown for a specific app.
curl --request GET \
--url https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost \
--header 'Authorization: Bearer <token>'import requests
url = "https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost', 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://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost",
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://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost"
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://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://rest.cerebrium.ai/v2/projects/{project_id}/apps/{app_id}/cost")
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{
"cost_totals": {},
"costs": {},
"end_date": "<string>",
"interval": "<string>",
"start_date": "<string>"
}{
"message": "<string>"
}{
"message": "<string>"
}Authorizations
Service Account Token authentication. To authenticate API requests:
-
Create a Service Account Token:
- Go to the Cerebrium Dashboard and open the API Keys page
- Click Create Service Account, name it (e.g., "GitHub Actions CI/CD"), choose an expiry date, and click Create
- Copy the token generated for the desired service account
-
Use the Token: Include the service account token in the Authorization header of API requests:
Authorization: Bearer <your-service-account-token> -
Best Practices:
- Create separate service accounts for different environments (dev, staging, prod)
- Store tokens securely as secrets in consuming applications or workflows
- Set appropriate expiry dates and rotate tokens regularly
- Never commit tokens to source control
For CI/CD integration examples, see the CI/CD documentation.
Query Parameters
Billing month to retrieve costs for. Valid values: current, previous. Default: current.
Response
Daily cost metrics for the app over the selected month.
Costs summed over the period, with the same fields as each costs entry.
Costs per interval, keyed by date. Each value has total_cost_cents, cpu_cost_cents, memory_cost_cents, gpu_cost_cents, unique_container_count, and total_running_time_ms fields.
End of the reporting period, in RFC3339 format.
Time bucket size for the breakdown.
Start of the reporting period, in RFC3339 format.