获取用量配置
curl --request POST \
--url https://server.codeium.com/api/v1/GetUsageConfig \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"service_key": "<string>",
"team_level": true,
"group_id": "<string>",
"user_email": "<string>"
}
'import requests
url = "https://server.codeium.com/api/v1/GetUsageConfig"
payload = {
"service_key": "<string>",
"team_level": True,
"group_id": "<string>",
"user_email": "<string>"
}
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({
service_key: '<string>',
team_level: true,
group_id: '<string>',
user_email: '<string>'
})
};
fetch('https://server.codeium.com/api/v1/GetUsageConfig', 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://server.codeium.com/api/v1/GetUsageConfig",
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([
'service_key' => '<string>',
'team_level' => true,
'group_id' => '<string>',
'user_email' => '<string>'
]),
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://server.codeium.com/api/v1/GetUsageConfig"
payload := strings.NewReader("{\n \"service_key\": \"<string>\",\n \"team_level\": true,\n \"group_id\": \"<string>\",\n \"user_email\": \"<string>\"\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://server.codeium.com/api/v1/GetUsageConfig")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"service_key\": \"<string>\",\n \"team_level\": true,\n \"group_id\": \"<string>\",\n \"user_email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://server.codeium.com/api/v1/GetUsageConfig")
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 \"service_key\": \"<string>\",\n \"team_level\": true,\n \"group_id\": \"<string>\",\n \"user_email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"addOnCreditCap": 123
}用量 API
获取用量配置
获取用于企业计费管理的每用户附加额度上限配置,可按团队、组或单个用户作用域查询。
POST
/
api
/
v1
/
GetUsageConfig
获取用量配置
curl --request POST \
--url https://server.codeium.com/api/v1/GetUsageConfig \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"service_key": "<string>",
"team_level": true,
"group_id": "<string>",
"user_email": "<string>"
}
'import requests
url = "https://server.codeium.com/api/v1/GetUsageConfig"
payload = {
"service_key": "<string>",
"team_level": True,
"group_id": "<string>",
"user_email": "<string>"
}
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({
service_key: '<string>',
team_level: true,
group_id: '<string>',
user_email: '<string>'
})
};
fetch('https://server.codeium.com/api/v1/GetUsageConfig', 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://server.codeium.com/api/v1/GetUsageConfig",
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([
'service_key' => '<string>',
'team_level' => true,
'group_id' => '<string>',
'user_email' => '<string>'
]),
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://server.codeium.com/api/v1/GetUsageConfig"
payload := strings.NewReader("{\n \"service_key\": \"<string>\",\n \"team_level\": true,\n \"group_id\": \"<string>\",\n \"user_email\": \"<string>\"\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://server.codeium.com/api/v1/GetUsageConfig")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"service_key\": \"<string>\",\n \"team_level\": true,\n \"group_id\": \"<string>\",\n \"user_email\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://server.codeium.com/api/v1/GetUsageConfig")
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 \"service_key\": \"<string>\",\n \"team_level\": true,\n \"group_id\": \"<string>\",\n \"user_email\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"addOnCreditCap": 123
}概述
请求
你的服务密钥,需具有“Billing Read”权限
作用域配置 (任选一项)
设为
true 以获取适用于团队内所有用户的每用户上限提供组 ID,以获取适用于特定组内所有用户的每用户上限
提供电子邮件地址,以获取特定用户的配置
你必须提供
team_level、group_id 或 user_email 其中之一来定义作用域。示例请求 - 获取团队中所有用户的每用户上限
curl -X POST --header "Content-Type: application/json" \
--data '{
"service_key": "your_service_key_here",
"team_level": true
}' \
https://server.codeium.com/api/v1/GetUsageConfig
示例请求 - 获取组内所有用户的每位用户上限
curl -X POST --header "Content-Type: application/json" \
--data '{
"service_key": "your_service_key_here",
"group_id": "engineering_team"
}' \
https://server.codeium.com/api/v1/GetUsageConfig
示例请求 - 获取用户配置
curl -X POST --header "Content-Type: application/json" \
--data '{
"service_key": "your_service_key_here",
"user_email": "user@example.com"
}' \
https://server.codeium.com/api/v1/GetUsageConfig
响应
已配置的附加额度上限值。如果响应中未返回此字段,则表示在所请求的作用域级别未配置上限。
示例响应 - 已设置上限
{
"addOnCreditCap": 10000
}
响应示例 - 未设置上限
{}
错误响应
- 服务密钥无效或权限不足
- 提供了多个作用域参数
- 未提供作用域参数
- 组 ID 或用户邮箱无效
- 超出速率限制
⌘I

