获取所有令牌
curl --request GET \
--url 'https://api.example.com/{{llmApiOrigin}}/api/token/' \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/{{llmApiOrigin}}/api/token/"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/{{llmApiOrigin}}/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.example.com/{{llmApiOrigin}}/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: <authorization>"
],
]);
$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.example.com/{{llmApiOrigin}}/api/token/"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.example.com/{{llmApiOrigin}}/api/token/")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "",
"data": {
"data": [
{
"id": 1,
"name": "my-token",
"key": "sk-xxxxxxxxxxxxxxxx",
"status": 1,
"remain_quota": 1000000,
"expired_time": 1767225600,
"unlimited_quota": false
}
],
"total": 1
}
}
令牌管理
获取所有令牌
GET
{llmApiOrigin}
/
api
/
token
/
获取所有令牌
curl --request GET \
--url 'https://api.example.com/{{llmApiOrigin}}/api/token/' \
--header 'Authorization: <authorization>'import requests
url = "https://api.example.com/{{llmApiOrigin}}/api/token/"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.example.com/{{llmApiOrigin}}/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.example.com/{{llmApiOrigin}}/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: <authorization>"
],
]);
$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.example.com/{{llmApiOrigin}}/api/token/"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "<authorization>")
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.example.com/{{llmApiOrigin}}/api/token/")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/{{llmApiOrigin}}/api/token/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = '<authorization>'
response = http.request(request)
puts response.read_body{
"success": true,
"message": "",
"data": {
"data": [
{
"id": 1,
"name": "my-token",
"key": "sk-xxxxxxxxxxxxxxxx",
"status": 1,
"remain_quota": 1000000,
"expired_time": 1767225600,
"unlimited_quota": false
}
],
"total": 1
}
}
简介
获取所有令牌列表,支持分页。此接口需要登录(User 权限)后调用。认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxx查询参数
integer
默认值:"0"
页码,从
0 开始。integer
默认值:"10"
每页数量。
代码示例
- cURL
- Python
- Node.js
curl -X GET "https://api-test.shengmoai.com/api/token/?p=0&page_size=20" \
-H "Authorization: Bearer sk-xxxxxxxxxx"
import requests
url = "https://api-test.shengmoai.com/api/token/"
headers = {"Authorization": "Bearer sk-xxxxxxxxxx"}
params = {"p": 0, "page_size": 20}
response = requests.get(url, headers=headers, params=params)
print(response.json())
const axios = require('axios');
const response = await axios.get('https://api-test.shengmoai.com/api/token/', {
params: { p: 0, page_size: 20 },
headers: { 'Authorization': 'Bearer sk-xxxxxxxxxx' }
});
console.log(response.data);
响应示例
{
"success": true,
"message": "",
"data": {
"data": [
{
"id": 1,
"name": "my-token",
"key": "sk-xxxxxxxxxxxxxxxx",
"status": 1,
"remain_quota": 1000000,
"expired_time": 1767225600,
"unlimited_quota": false
}
],
"total": 1
}
}
HTTP 状态码
| 状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 401 | 未登录或令牌无效 |
注意事项
- 返回的令牌列表会根据当前登录用户的权限动态变化
- 建议使用
page_size控制单页数量,避免响应过大
