curl --request GET \
--url https://cloud.comfy.org/api/billing/usage/timeseries \
--header 'X-API-Key: <api-key>'import requests
url = "https://cloud.comfy.org/api/billing/usage/timeseries"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://cloud.comfy.org/api/billing/usage/timeseries', 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.comfy.org/api/billing/usage/timeseries",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$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.comfy.org/api/billing/usage/timeseries"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
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.comfy.org/api/billing/usage/timeseries")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud.comfy.org/api/billing/usage/timeseries")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"group_by": "model",
"granularity": "hour",
"starting_on": "2023-11-07T05:31:56Z",
"ending_before": "2023-11-07T05:31:56Z",
"groups": [
"<string>"
],
"buckets": [
{
"period_start": "2023-11-07T05:31:56Z",
"period_end": "2023-11-07T05:31:56Z",
"group_key": "google/nano-banana-2",
"cost_micros": 1250000
}
],
"breakdown": [
{
"group_key": "google/nano-banana-2",
"cost_micros": 1250000,
"share": 0.42
}
],
"summary": {
"spend_micros": 2975000,
"balance": {
"amount_micros": 4250,
"prepaid_balance_micros": 2250,
"cloud_credit_balance_micros": 2000,
"currency": "USD"
}
}
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}Get workspace usage over time
Returns billed usage for the workspace the API key belongs to, split into time buckets and grouped by model, endpoint, or product. Use it to reconcile spend, attribute cost across models, or feed an internal cost report.
Units. cost_micros and spend_micros are millionths of a US dollar,
so divide by 1,000,000 to get dollars. The fields under summary.balance
are the exception: despite their _micros suffix they are cents, so
divide those by 100.
Freshness. Figures are drawn from your invoices rather than from live request traffic, so very recent usage may not appear yet. Treat this as a reporting surface, not a real-time meter.
Empty results. A workspace that has not been billed yet returns empty
groups, buckets, and breakdown arrays with a 200, not an error.
curl --request GET \
--url https://cloud.comfy.org/api/billing/usage/timeseries \
--header 'X-API-Key: <api-key>'import requests
url = "https://cloud.comfy.org/api/billing/usage/timeseries"
headers = {"X-API-Key": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {'X-API-Key': '<api-key>'}};
fetch('https://cloud.comfy.org/api/billing/usage/timeseries', 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.comfy.org/api/billing/usage/timeseries",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"X-API-Key: <api-key>"
],
]);
$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.comfy.org/api/billing/usage/timeseries"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("X-API-Key", "<api-key>")
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.comfy.org/api/billing/usage/timeseries")
.header("X-API-Key", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://cloud.comfy.org/api/billing/usage/timeseries")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["X-API-Key"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"group_by": "model",
"granularity": "hour",
"starting_on": "2023-11-07T05:31:56Z",
"ending_before": "2023-11-07T05:31:56Z",
"groups": [
"<string>"
],
"buckets": [
{
"period_start": "2023-11-07T05:31:56Z",
"period_end": "2023-11-07T05:31:56Z",
"group_key": "google/nano-banana-2",
"cost_micros": 1250000
}
],
"breakdown": [
{
"group_key": "google/nano-banana-2",
"cost_micros": 1250000,
"share": 0.42
}
],
"summary": {
"spend_micros": 2975000,
"balance": {
"amount_micros": 4250,
"prepaid_balance_micros": 2250,
"cloud_credit_balance_micros": 2000,
"currency": "USD"
}
}
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}{
"code": "<string>",
"message": "<string>"
}Autorizaciones
API key authentication. Generate an API key from your account settings at https://platform.comfy.org/profile/api-keys. Pass the key in the X-API-Key header.
Parámetros de consulta
Respuesta
Success - Usage returned
Billed usage for one workspace over a time range.
¿Esta página le ayudó?