Chiavi API
Elencare le chiavi API
Usa CometAPI GET /api/token/ per elencare le chiavi API dell’account autenticato con paginazione.
GET
/
api
/
token
/
cURL
curl "https://api.cometapi.com/api/token/?p=1&page_size=20" \
-H "Authorization: your-access-token"import requests
url = "https://api.cometapi.com/api/token/"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.cometapi.com/api/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/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: <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://api.cometapi.com/api/token/"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<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://api.cometapi.com/api/token/")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "",
"data": {
"page": 1,
"page_size": 20,
"total": 1,
"items": [
{
"id": 1234,
"user_id": 5678,
"key": "$COMETAPI_KEY",
"status": 1,
"name": "production",
"created_time": 1766102400,
"accessed_time": 1766102400,
"expired_time": -1,
"remain_quota": 100000,
"unlimited_quota": false,
"model_limits_enabled": false,
"model_limits": "",
"allow_ips": null,
"used_quota": 0,
"group": "",
"cross_group_retry": false
}
]
}
}Usa questo endpoint per elencare le chiavi API che appartengono all’account CometAPI autenticato. Le chiavi più recenti vengono restituite per prime.
Genera un personal access token in Console → Personal Settings, quindi invialo come valore raw dell’header
Authorization. Non anteporre Bearer.Paginazione
| Query parameter | Description |
|---|---|
p | Numero di pagina. Il valore predefinito è 1. |
page_size | Elementi per pagina. I valori superiori a 100 vengono limitati a 100. |
Stato della chiave API
| Status | Meaning |
|---|---|
1 | Abilitata |
2 | Disabilitata |
3 | Scaduta |
4 | Esaurita |
Campi restituiti
| Field | Type | Description |
|---|---|---|
id | integer | ID numerico della chiave API. Usa questo valore con Ottenere una singola chiave API, Aggiornare una chiave API e Eliminare una chiave API. |
key | string | Valore della chiave API restituito dalla management API. Trattalo come un segreto e usalo come Authorization: Bearer $COMETAPI_KEY per le richieste ai model. |
status | integer | Stato operativo. Solo 1 indica che la chiave è abilitata per le richieste ai model. |
name | string | Nome visualizzato della chiave leggibile dall’utente. |
created_time | integer | Timestamp Unix in secondi che indica quando è stata creata la chiave. |
accessed_time | integer | Timestamp Unix in secondi che indica quando la chiave è stata usata l’ultima volta. |
expired_time | integer | Timestamp Unix in secondi che indica quando la chiave scade. -1 significa nessuna scadenza. |
remain_quota | integer | Quota rimanente nelle unità di quota interne di CometAPI. |
used_quota | integer | Quota già consumata da questa chiave nelle unità di quota interne di CometAPI. |
unlimited_quota | boolean | Indica se la chiave ignora i controlli sulla quota residua. |
model_limits_enabled | boolean | Indica se le restrizioni sui model sono attive per questa chiave. |
model_limits | string | model ID separati da virgole consentiti da questa chiave quando model_limits_enabled è true. Vuoto significa che non è configurato alcun elenco di model. |
allow_ips | string or null | Allowlist di IP come singola stringa separata da newline. Ogni voce può essere un singolo indirizzo IPv4, un singolo indirizzo IPv6, un CIDR IPv4 o un CIDR IPv6. null o "" significa nessuna restrizione IP. |
group | string | Restrizione del gruppo dell’account. Vuoto significa nessuna restrizione esplicita del gruppo. |
cross_group_retry | boolean | Indica se il tentativo tra gruppi è abilitato per il routing automatico del gruppo. |
Autorizzazioni
Personal access token copied from CometAPI Console > Personal Settings. Send the raw token value; do not prefix it with Bearer.
Parametri della query
Page number to return. Defaults to 1.
Intervallo richiesto:
x >= 1Number of keys per page. Values above 100 are capped at 100 by the backend.
Intervallo richiesto:
1 <= x <= 100⌘I
cURL
curl "https://api.cometapi.com/api/token/?p=1&page_size=20" \
-H "Authorization: your-access-token"import requests
url = "https://api.cometapi.com/api/token/"
headers = {"Authorization": "<api-key>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<api-key>'}};
fetch('https://api.cometapi.com/api/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/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: <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://api.cometapi.com/api/token/"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<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://api.cometapi.com/api/token/")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<api-key>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "",
"data": {
"page": 1,
"page_size": 20,
"total": 1,
"items": [
{
"id": 1234,
"user_id": 5678,
"key": "$COMETAPI_KEY",
"status": 1,
"name": "production",
"created_time": 1766102400,
"accessed_time": 1766102400,
"expired_time": -1,
"remain_quota": 100000,
"unlimited_quota": false,
"model_limits_enabled": false,
"model_limits": "",
"allow_ips": null,
"used_quota": 0,
"group": "",
"cross_group_retry": false
}
]
}
}