API anahtarları
Bir API anahtarını alın
Kimliği doğrulanmış hesap için ID ile tek bir API anahtarı kaydını almak üzere CometAPI GET /api/token/ uç noktasını kullanın.
GET
/
api
/
token
/
{id}
cURL
curl https://api.cometapi.com/api/token/1234 \
-H "Authorization: your-access-token"import requests
url = "https://api.cometapi.com/api/token/{id}"
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/{id}', 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/{id}",
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/{id}"
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/{id}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/token/{id}")
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": {
"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
}
}Bu uç noktayı, ID ile tek bir API anahtarı kaydını almak için kullanın.
Console → Personal Settings bölümünde bir personal access token oluşturun, ardından bunu ham
Authorization header değeri olarak gönderin. Başına Bearer eklemeyin.id path parametresi, API anahtarlarını listele tarafından döndürülen sayısal anahtar ID’sidir.
API anahtarı durumu
| Status | Meaning |
|---|---|
1 | Etkin |
2 | Devre dışı |
3 | Süresi dolmuş |
4 | Tükenmiş |
Döndürülen alanlar
| Field | Type | Description |
|---|---|---|
id | integer | Sayısal API anahtarı ID’si. Bu değeri Bir API anahtarını güncelle ve Bir API anahtarını sil ile kullanın. |
key | string | Yönetim API’si tarafından döndürülen API anahtarı değeri. Bunu bir sır olarak değerlendirin ve model istekleri için Authorization: Bearer $COMETAPI_KEY şeklinde kullanın. |
status | integer | İşletim durumu. Yalnızca 1, anahtarın model istekleri için etkin olduğu anlamına gelir. |
name | string | Anahtar için kullanıcı tarafından okunabilir görünen ad. |
created_time | integer | Anahtarın oluşturulduğu zamanı gösteren saniye cinsinden Unix zaman damgası. |
accessed_time | integer | Anahtarın en son kullanıldığı zamanı gösteren saniye cinsinden Unix zaman damgası. |
expired_time | integer | Anahtarın süresinin dolduğu zamanı gösteren saniye cinsinden Unix zaman damgası. -1 süresiz anlamına gelir. |
remain_quota | integer | CometAPI iç kota birimlerinde kalan kota. |
used_quota | integer | Bu anahtar tarafından CometAPI iç kota birimlerinde zaten tüketilmiş kota. |
unlimited_quota | boolean | Anahtarın kalan-kota kontrollerini atlayıp atlamadığı. |
model_limits_enabled | boolean | Bu anahtar için model kısıtlamalarının etkin olup olmadığı. |
model_limits | string | model_limits_enabled true olduğunda bu anahtarın izin verdiği, virgülle ayrılmış model ID’leri. Boş olması, yapılandırılmış bir model listesi olmadığı anlamına gelir. |
allow_ips | string or null | Tek bir satır sonu ile ayrılmış string olarak IP izin listesi. Her giriş tek bir IPv4 adresi, tek bir IPv6 adresi, IPv4 CIDR veya IPv6 CIDR olabilir. null veya "", IP kısıtlaması olmadığı anlamına gelir. |
group | string | Hesap grubu kısıtlaması. Boş olması, açıkça tanımlanmış bir grup kısıtlaması olmadığı anlamına gelir. |
cross_group_retry | boolean | Otomatik grup yönlendirmesi için gruplar arası yeniden denemenin etkin olup olmadığı. |
Yetkilendirmeler
Personal access token copied from CometAPI Console > Personal Settings. Send the raw token value; do not prefix it with Bearer.
Yol Parametreleri
Numeric API key ID returned by the list endpoint.
⌘I
cURL
curl https://api.cometapi.com/api/token/1234 \
-H "Authorization: your-access-token"import requests
url = "https://api.cometapi.com/api/token/{id}"
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/{id}', 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/{id}",
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/{id}"
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/{id}")
.header("Authorization", "<api-key>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/api/token/{id}")
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": {
"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
}
}