Account Usage
curl --request GET \
--url https://api.aisa.one/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.aisa.one/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.aisa.one/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.aisa.one/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.aisa.one/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.aisa.one/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/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{
"scope": "key",
"currency": "USD",
"start_time": 1785513600,
"end_time": 1787760000,
"bucket_width": "1d",
"totals": {
"requests": 1162,
"failed_requests": 401,
"input_tokens": 206393,
"output_tokens": 5031,
"cache_read_tokens": 0,
"cache_write_tokens": 0,
"usage_value_micros_usd": 128398109,
"charged_micros_usd": 128398109
},
"buckets": [
{
"start_time": 1785513600,
"end_time": 1785600000,
"requests": 42,
"failed_requests": 3,
"input_tokens": 8123,
"output_tokens": 210,
"cache_read_tokens": 0,
"cache_write_tokens": 0,
"usage_value_micros_usd": 5123400,
"charged_micros_usd": 5123400
}
]
}{
"error": "start_time must be a positive Unix timestamp"
}Overview
Account Usage
Read aggregate usage through the existing account API contract.
GET
https://api.aisa.one/v1
/
usage
Account Usage
curl --request GET \
--url https://api.aisa.one/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.aisa.one/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.aisa.one/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.aisa.one/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.aisa.one/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.aisa.one/v1/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisa.one/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{
"scope": "key",
"currency": "USD",
"start_time": 1785513600,
"end_time": 1787760000,
"bucket_width": "1d",
"totals": {
"requests": 1162,
"failed_requests": 401,
"input_tokens": 206393,
"output_tokens": 5031,
"cache_read_tokens": 0,
"cache_write_tokens": 0,
"usage_value_micros_usd": 128398109,
"charged_micros_usd": 128398109
},
"buckets": [
{
"start_time": 1785513600,
"end_time": 1785600000,
"requests": 42,
"failed_requests": 3,
"input_tokens": 8123,
"output_tokens": 210,
"cache_read_tokens": 0,
"cache_write_tokens": 0,
"usage_value_micros_usd": 5123400,
"charged_micros_usd": 5123400
}
]
}{
"error": "start_time must be a positive Unix timestamp"
}Use the declared scope and time parameters below to request aggregate usage.
See Usage and Logs
for the Console workflow and per-request records.
Request contract
- Method and path: GET /usage
- Request URL template: https://api.aisa.one/v1/usage
- start_time: query; required
- end_time: query; optional
{
"operationId": "accountUsage",
"method": "GET",
"path": "/usage",
"servers": [
{
"url": "https://api.aisa.one/v1"
}
],
"parameters": [
{
"name": "start_time",
"in": "query",
"required": true,
"description": "Window start as a Unix timestamp in seconds.",
"schema": {
"type": "integer",
"format": "int64"
}
},
{
"name": "end_time",
"in": "query",
"required": false,
"description": "Window end as a Unix timestamp in seconds. Defaults to the current time.",
"schema": {
"type": "integer",
"format": "int64"
}
}
],
"security": [
{
"BearerAuth": []
}
],
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "AISA API Key or OAuth access token"
}
}
}
}
Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Query Parameters
Window start as a Unix timestamp in seconds.
Window end as a Unix timestamp in seconds. Defaults to the current time.
Response
Usage totals and per-day buckets over the window.
Aggregation scope implied by the credential (e.g. key or account).
ISO currency code (always USD).
Echoed window start (Unix seconds).
Echoed window end (Unix seconds).
Bucket granularity (e.g. 1d).
Aggregate totals across the whole window.
Show child attributes
Show child attributes
Per-bucket usage, ordered by time.
Show child attributes
Show child attributes