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"
}概览
账户用量
通过现有账户 API 查询汇总用量。
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"
}使用下方声明的范围与时间参数查询汇总用量。
控制台查询流程与逐笔记录请参阅用量日志。
请求规范
- 方法与路径: GET /usage
- 请求 URL 模板: https://api.aisa.one/v1/usage
- start_time: query; 必填
- end_time: query; 可选
{
"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"
}
}
}
}
授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
查询参数
Window start as a Unix timestamp in seconds.
Window end as a Unix timestamp in seconds. Defaults to the current time.
响应
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