APIキー
現在のAPIキーを取得
CometAPI の GET /api/usage/token を使用して、Bearer API キーのクォータ、使用量、有効期限、モデル制限の詳細を取得します。
GET
/
api
/
usage
/
token
cURL
curl https://api.cometapi.com/api/usage/token \
-H "Authorization: Bearer $COMETAPI_KEY"import requests
url = "https://api.cometapi.com/api/usage/token"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cometapi.com/api/usage/token', 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.cometapi.com/api/usage/token",
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.cometapi.com/api/usage/token"
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.cometapi.com/api/usage/token")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/usage/token")
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{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "production",
"total_granted": 150000,
"total_used": 50000,
"total_available": 100000,
"unlimited_quota": false,
"model_limits": {
"gpt-4.1": true
},
"model_limits_enabled": true,
"expires_at": 0
}
}このエンドポイントを使用すると、リクエストで使用された CometAPI API キーを確認できます。返されるのは Bearer キーの使用量とクォータに関するフィールドであり、アカウントレベルですべてのキーを一覧表示するものではありません。
このエンドポイントは CometAPI API キーを使用します:
Authorization: Bearer $COMETAPI_KEY。API キー管理エンドポイントでは、別の personal access token を使用します。返されるフィールド
| Field | Type | Description |
|---|---|---|
name | string | API キーの表示名。 |
total_granted | integer | このキーに割り当てられた合計クォータ(CometAPI の内部クォータ単位)。 |
total_used | integer | このキーによって消費されたクォータ(CometAPI の内部クォータ単位)。 |
total_available | integer | このキーで利用可能な残りクォータ(CometAPI の内部クォータ単位)。 |
unlimited_quota | boolean | このキーが残りクォータのチェックをバイパスするかどうか。 |
model_limits | object | このキーのモデル制限。model ID ごとにキー付けされています。モデル制限が設定されていない場合は空です。 |
model_limits_enabled | boolean | このキーでモデル制限が有効かどうか。 |
expires_at | integer | キーの有効期限を示す秒単位の Unix タイムスタンプ。0 は、この使用状況レスポンスでは有効期限がないことを意味します。 |
⌘I
cURL
curl https://api.cometapi.com/api/usage/token \
-H "Authorization: Bearer $COMETAPI_KEY"import requests
url = "https://api.cometapi.com/api/usage/token"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.cometapi.com/api/usage/token', 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.cometapi.com/api/usage/token",
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.cometapi.com/api/usage/token"
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.cometapi.com/api/usage/token")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/usage/token")
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{
"code": true,
"message": "ok",
"data": {
"object": "token_usage",
"name": "production",
"total_granted": 150000,
"total_used": 50000,
"total_available": 100000,
"unlimited_quota": false,
"model_limits": {
"gpt-4.1": true
},
"model_limits_enabled": true,
"expires_at": 0
}
}