API Keys
Get scoped API key usage
Requires api_keys:read. The key owner or an account administrator can read request, error, throttle, latency and byte totals, hourly time series and lifecycle audit entries.
GET
/
api
/
v2
/
accounts
/
{accountId}
/
api-keys
/
{keyId}
/
usage
Get scoped API key usage
curl --request GET \
--url https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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{
"audit_log": [
{
"action": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"endpoint": "<string>",
"id": 123,
"ip_address": "<string>",
"metadata": {},
"user_agent": "<string>"
}
],
"period": {
"hours": 123,
"since": "2023-11-07T05:31:56Z"
},
"summary": {
"average_duration_ms": 123,
"error_count": 123,
"error_rate": 123,
"max_duration_ms": 123,
"request_count": 123,
"response_bytes": 123,
"throttled_count": 123
},
"timeseries": [
{
"bucket_start": "2023-11-07T05:31:56Z",
"error_count": 123,
"max_duration_ms": 123,
"request_count": 123,
"throttled_count": 123,
"total_duration_ms": 123
}
],
"total": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}Authorizations
Your personal access token from Settings → Profile, or a scoped API key (hc_…) created at Settings → Developer → API keys. Send it as Authorization: Bearer <token>.
Query Parameters
Usage window in hours (1-2160)
Maximum lifecycle audit entries (1-500)
⌘I
Get scoped API key usage
curl --request GET \
--url https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/usage")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://app.huechat.ai/api/v2/accounts/{accountId}/api-keys/{keyId}/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{
"audit_log": [
{
"action": "<string>",
"created_at": "2023-11-07T05:31:56Z",
"endpoint": "<string>",
"id": 123,
"ip_address": "<string>",
"metadata": {},
"user_agent": "<string>"
}
],
"period": {
"hours": 123,
"since": "2023-11-07T05:31:56Z"
},
"summary": {
"average_duration_ms": 123,
"error_count": 123,
"error_rate": 123,
"max_duration_ms": 123,
"request_count": 123,
"response_bytes": 123,
"throttled_count": 123
},
"timeseries": [
{
"bucket_start": "2023-11-07T05:31:56Z",
"error_count": 123,
"max_duration_ms": 123,
"request_count": 123,
"throttled_count": 123,
"total_duration_ms": 123
}
],
"total": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}{
"code": "<string>",
"error": "<string>",
"limit": 123,
"retry_after": 123
}
