创建新的 API KEY
curl --request POST \
--url https://geekai.co/api/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "geekai",
"group": "balance",
"credit_limit": 10000,
"expired_at": "2025-12-31"
}
'import requests
url = "https://geekai.co/api/api_keys"
payload = {
"name": "geekai",
"group": "balance",
"credit_limit": 10000,
"expired_at": "2025-12-31"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'geekai',
group: 'balance',
credit_limit: 10000,
expired_at: '2025-12-31'
})
};
fetch('https://geekai.co/api/api_keys', 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://geekai.co/api/api_keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'geekai',
'group' => 'balance',
'credit_limit' => 10000,
'expired_at' => '2025-12-31'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://geekai.co/api/api_keys"
payload := strings.NewReader("{\n \"name\": \"geekai\",\n \"group\": \"balance\",\n \"credit_limit\": 10000,\n \"expired_at\": \"2025-12-31\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://geekai.co/api/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"geekai\",\n \"group\": \"balance\",\n \"credit_limit\": 10000,\n \"expired_at\": \"2025-12-31\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/api_keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"geekai\",\n \"group\": \"balance\",\n \"credit_limit\": 10000,\n \"expired_at\": \"2025-12-31\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"uuid": "<string>",
"name": "<string>",
"value": "<string>",
"raw_value": "<string>",
"group": {
"name": "<string>",
"alias": "<string>",
"desc": "<string>"
},
"credit_limit": 123,
"credit_used": 123,
"expired_at": "2023-12-25",
"expired": true,
"status": true,
"last_used_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
},
"message": "<string>"
}{
"code": "validation_error",
"message": "参数验证失败",
"details": {
"field": "错误描述"
}
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}令牌管理
创建新的 API KEY
POST
/
api_keys
创建新的 API KEY
curl --request POST \
--url https://geekai.co/api/api_keys \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "geekai",
"group": "balance",
"credit_limit": 10000,
"expired_at": "2025-12-31"
}
'import requests
url = "https://geekai.co/api/api_keys"
payload = {
"name": "geekai",
"group": "balance",
"credit_limit": 10000,
"expired_at": "2025-12-31"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'geekai',
group: 'balance',
credit_limit: 10000,
expired_at: '2025-12-31'
})
};
fetch('https://geekai.co/api/api_keys', 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://geekai.co/api/api_keys",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'geekai',
'group' => 'balance',
'credit_limit' => 10000,
'expired_at' => '2025-12-31'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://geekai.co/api/api_keys"
payload := strings.NewReader("{\n \"name\": \"geekai\",\n \"group\": \"balance\",\n \"credit_limit\": 10000,\n \"expired_at\": \"2025-12-31\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://geekai.co/api/api_keys")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"geekai\",\n \"group\": \"balance\",\n \"credit_limit\": 10000,\n \"expired_at\": \"2025-12-31\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://geekai.co/api/api_keys")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"geekai\",\n \"group\": \"balance\",\n \"credit_limit\": 10000,\n \"expired_at\": \"2025-12-31\"\n}"
response = http.request(request)
puts response.read_body{
"data": {
"uuid": "<string>",
"name": "<string>",
"value": "<string>",
"raw_value": "<string>",
"group": {
"name": "<string>",
"alias": "<string>",
"desc": "<string>"
},
"credit_limit": 123,
"credit_used": 123,
"expired_at": "2023-12-25",
"expired": true,
"status": true,
"last_used_at": "2023-11-07T05:31:56Z",
"created_at": "2023-11-07T05:31:56Z"
},
"message": "<string>"
}{
"code": "validation_error",
"message": "参数验证失败",
"details": {
"field": "错误描述"
}
}{
"code": "unauthorized",
"message": "Invalid API key or token"
}{
"code": "invalid_request",
"message": "请求参数不合法"
}创建一个新的 API KEY。
注意:调用此接口需要通过系统 KEY 进行认证,需要创建后复制进行使用。
授权
系统KEY
请求体
application/json
名称,可用于标识 API KEY 的使用场景/用途,便于后续管理/统计费用
示例:
"geekai"
代理策略分组,用于区分不同的代理策略,目前支持四个策略:lowcost(低价优先), balance(均衡), ha(高可用), none(不使用代理)
可用选项:
lowcost, balance, ha, none 示例:
"balance"
信用额度,单位:金币(1金币=0.01元),用于限时 API KEY 的消费上限,超出额度后将无法继续使用,默认为 0,表示不限制信用额度
示例:
10000
过期时间,过期后将无法继续使用,默认为空,表示没有过期时间
示例:
"2025-12-31"
此页面对您有帮助吗?
⌘I
