跳转到主要内容
POST
/
api
/
v1
/
UsageConfig
设置用量配置
curl --request POST \
  --url https://server.codeium.com/api/v1/UsageConfig \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "service_key": "<string>",
  "clear_add_on_credit_cap": true,
  "set_add_on_credit_cap": 123,
  "team_level": true,
  "group_id": "<string>",
  "user_email": "<string>"
}
'
import requests

url = "https://server.codeium.com/api/v1/UsageConfig"

payload = {
"service_key": "<string>",
"clear_add_on_credit_cap": True,
"set_add_on_credit_cap": 123,
"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>',
clear_add_on_credit_cap: true,
set_add_on_credit_cap: 123,
team_level: true,
group_id: '<string>',
user_email: '<string>'
})
};

fetch('https://server.codeium.com/api/v1/UsageConfig', 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/UsageConfig",
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>',
'clear_add_on_credit_cap' => true,
'set_add_on_credit_cap' => 123,
'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/UsageConfig"

payload := strings.NewReader("{\n \"service_key\": \"<string>\",\n \"clear_add_on_credit_cap\": true,\n \"set_add_on_credit_cap\": 123,\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/UsageConfig")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"service_key\": \"<string>\",\n \"clear_add_on_credit_cap\": true,\n \"set_add_on_credit_cap\": 123,\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/UsageConfig")

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 \"clear_add_on_credit_cap\": true,\n \"set_add_on_credit_cap\": 123,\n \"team_level\": true,\n \"group_id\": \"<string>\",\n \"user_email\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body

概述

为你的组织设置或清除附加额度的每用户用量上限。上限始终按用户单独生效。当你指定团队或组作用域时,上限会单独应用于该团队或组中的每位用户——而不是为整个团队或组设置一个共享上限。

请求

service_key
string
必填
你的服务密钥,且具有“Billing Write”权限

额度上限配置 (任选其一)

clear_add_on_credit_cap
boolean
设为 true 以清除当前的附加额度上限
set_add_on_credit_cap
integer
设置新的附加额度上限 (整数值)
必须提供 clear_add_on_credit_capset_add_on_credit_cap 其中之一,但不能同时提供两者。

作用域配置 (任选其一)

team_level
boolean
设为 true,将对团队中的每位用户应用单用户上限
group_id
string
提供组 ID,将对特定组中的每位用户应用单用户上限
user_email
string
提供电子邮件地址,将该配置应用于特定用户
你必须提供 team_levelgroup_iduser_email 其中之一来定义作用域。

示例请求 - 为团队中的所有用户设置单用户信用额度上限

curl -X POST --header "Content-Type: application/json" \
--data '{
  "service_key": "your_service_key_here",
  "set_add_on_credit_cap": 10000,
  "team_level": true
}' \
https://server.codeium.com/api/v1/UsageConfig

示例请求 - 为组中的所有用户设置每位用户的信用额度上限

curl -X POST --header "Content-Type: application/json" \
--data '{
  "service_key": "your_service_key_here",
  "set_add_on_credit_cap": 5000,
  "group_id": "engineering_team"
}' \
https://server.codeium.com/api/v1/UsageConfig

示例请求 - 为用户设置额度上限

curl -X POST --header "Content-Type: application/json" \
--data '{
  "service_key": "your_service_key_here",
  "set_add_on_credit_cap": 1000,
  "user_email": "user@example.com"
}' \
https://server.codeium.com/api/v1/UsageConfig

示例请求 - 取消信用额度上限

curl -X POST --header "Content-Type: application/json" \
--data '{
  "service_key": "your_service_key_here",
  "clear_add_on_credit_cap": true,
  "team_level": true
}' \
https://server.codeium.com/api/v1/UsageConfig

响应

响应体为空。200 状态码表示操作成功。

错误响应

常见错误场景:
  • 服务密钥无效或权限不足
  • 同时提供了 clear_add_on_credit_capset_add_on_credit_cap
  • 既未提供 clear_add_on_credit_cap,也未提供 set_add_on_credit_cap
  • 提供了多个作用域参数
  • 未提供作用域参数
  • 组 ID 或用户邮箱无效
  • 已超出速率限制