Get usage
curl --request GET \
--url https://api.zode.dev/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.zode.dev/v1/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.zode.dev/v1/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.zode.dev/v1/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.zode.dev/v1/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.zode.dev/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zode.dev/v1/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{
"from": "2023-12-25",
"to": "2023-12-25",
"as_of": "2023-11-07T05:31:56Z",
"group_by": "repo",
"totals": {
"billable_micros": 123,
"compute_micros": 123,
"storage_micros": 123,
"static_ip_micros": 123,
"ai_micros": 123,
"ai_calls": 123,
"sandbox_hours": 123,
"vcpu_hours": 123,
"peak_concurrent": 123,
"forks": 123,
"fork_p95_ms": 123,
"fork_samples": 123,
"oom_kills": 123,
"breaker_trips": 123,
"caps_reached": 123
},
"series": [
{
"day": "2023-12-25",
"billable_micros": 123,
"compute_micros": 123,
"storage_micros": 123,
"static_ip_micros": 123,
"ai_micros": 123,
"ai_calls": 123,
"sandbox_hours": 123,
"peak_concurrent": 123,
"forks": 123
}
],
"groups": [
{
"key": "<string>",
"label": "<string>",
"billable_micros": 123,
"compute_micros": 123,
"storage_micros": 123,
"static_ip_micros": 123,
"ai_micros": 123,
"ai_calls": 123,
"sandbox_hours": 123
}
],
"ai_by_model": [
{
"provider": "<string>",
"model": "<string>",
"calls": 123,
"cost_micros": 123
}
],
"ai_billed": true,
"recorder": "on",
"price_versions": [
"<string>"
]
}{
"error": {
"code": "not_found",
"message": "<string>"
}
}{
"error": {
"code": "not_found",
"message": "<string>"
}
}{
"error": {
"code": "not_found",
"message": "<string>"
}
}Usage and billing
Get usage
Workspace usage for a range of UTC days (every role).
Totals, a daily series and a group-by table. Compute and storage are
sums of ledger lines (stored lines for rolled-up days, metered live
for the rest); AI spend and OOM kills come from the flight recorder
and are null/absent when it is not connected (recorder). Totals
equal the sum of the series, of the groups and of the CSV rows, and
zode cost prints these totals.
GET
/
v1
/
usage
Get usage
curl --request GET \
--url https://api.zode.dev/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.zode.dev/v1/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.zode.dev/v1/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.zode.dev/v1/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.zode.dev/v1/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.zode.dev/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.zode.dev/v1/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{
"from": "2023-12-25",
"to": "2023-12-25",
"as_of": "2023-11-07T05:31:56Z",
"group_by": "repo",
"totals": {
"billable_micros": 123,
"compute_micros": 123,
"storage_micros": 123,
"static_ip_micros": 123,
"ai_micros": 123,
"ai_calls": 123,
"sandbox_hours": 123,
"vcpu_hours": 123,
"peak_concurrent": 123,
"forks": 123,
"fork_p95_ms": 123,
"fork_samples": 123,
"oom_kills": 123,
"breaker_trips": 123,
"caps_reached": 123
},
"series": [
{
"day": "2023-12-25",
"billable_micros": 123,
"compute_micros": 123,
"storage_micros": 123,
"static_ip_micros": 123,
"ai_micros": 123,
"ai_calls": 123,
"sandbox_hours": 123,
"peak_concurrent": 123,
"forks": 123
}
],
"groups": [
{
"key": "<string>",
"label": "<string>",
"billable_micros": 123,
"compute_micros": 123,
"storage_micros": 123,
"static_ip_micros": 123,
"ai_micros": 123,
"ai_calls": 123,
"sandbox_hours": 123
}
],
"ai_by_model": [
{
"provider": "<string>",
"model": "<string>",
"calls": 123,
"cost_micros": 123
}
],
"ai_billed": true,
"recorder": "on",
"price_versions": [
"<string>"
]
}{
"error": {
"code": "not_found",
"message": "<string>"
}
}{
"error": {
"code": "not_found",
"message": "<string>"
}
}{
"error": {
"code": "not_found",
"message": "<string>"
}
}Authorizations
An API key (zode_tok_...). Create one in the console under API keys (https://console.zode.dev/tokens), or with zode login.
Query Parameters
Response
Usage
⌘I