列出模型
curl --request GET \
--url https://api.leapx-hub.com/v1/models \
--header 'Authorization: <authorization>'import requests
url = "https://api.leapx-hub.com/v1/models"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.leapx-hub.com/v1/models', 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.leapx-hub.com/v1/models",
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.leapx-hub.com/v1/models"
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.leapx-hub.com/v1/models")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leapx-hub.com/v1/models")
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{
"object": "list",
"data": [
{
"id": "gpt-4o",
"object": "model",
"created": 1715232000,
"owned_by": "openai"
},
{
"id": "claude-sonnet-4-20250514",
"object": "model",
"created": 1743465600,
"owned_by": "anthropic"
},
{
"id": "gemini-2.5-pro",
"object": "model",
"created": 1746057600,
"owned_by": "google"
}
]
}
API 文档
列出模型
GET
/
v1
/
models
列出模型
curl --request GET \
--url https://api.leapx-hub.com/v1/models \
--header 'Authorization: <authorization>'import requests
url = "https://api.leapx-hub.com/v1/models"
headers = {"Authorization": "<authorization>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: '<authorization>'}};
fetch('https://api.leapx-hub.com/v1/models', 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.leapx-hub.com/v1/models",
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.leapx-hub.com/v1/models"
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.leapx-hub.com/v1/models")
.header("Authorization", "<authorization>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.leapx-hub.com/v1/models")
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{
"object": "list",
"data": [
{
"id": "gpt-4o",
"object": "model",
"created": 1715232000,
"owned_by": "openai"
},
{
"id": "claude-sonnet-4-20250514",
"object": "model",
"created": 1743465600,
"owned_by": "anthropic"
},
{
"id": "gemini-2.5-pro",
"object": "model",
"created": 1746057600,
"owned_by": "google"
}
]
}
简介
获取当前可用的模型列表。本接口支持自动识别返回格式,无需手动指定。自动格式识别
根据请求头自动返回对应格式:Anthropic、Gemini 或 OpenAI 格式
认证
string
必填
Bearer Token,如
Bearer sk-xxxxxxxxxx请求头说明
根据请求头自动识别返回格式:string
返回 Anthropic 格式响应
string
返回 Gemini 格式响应
string
返回 OpenAI 格式响应(默认)
代码示例
cURL 示例
curl https://api.leapx-hub.com/v1/models \
-H "Authorization: Bearer sk-XyLy**************************mIqSt"
Python 示例
from openai import OpenAI
client = OpenAI(
api_key="sk-XyLy**************************mIqSt",
base_url="https://api.leapx-hub.com/v1"
)
models = client.models.list()
for model in models.data:
print(f"Model ID: {model.id}, Provider: {model.owned_by}")
Node.js 示例
const axios = require('axios');
const response = await axios.get('https://api.leapx-hub.com/v1/models', {
headers: {
'Authorization': 'Bearer sk-XyLy**************************mIqSt'
}
});
console.log(response.data.data);
响应字段说明
| 字段 | 类型 | 说明 |
|---|---|---|
| object | string | 固定为 list |
| data | array | 模型列表 |
| data[].id | string | 模型唯一标识 |
| data[].object | string | 固定为 model |
| data[].created | integer | 模型创建时间戳(Unix 时间戳) |
| data[].owned_by | string | 模型提供商(如:openai、anthropic、google) |
响应示例
{
"object": "list",
"data": [
{
"id": "gpt-4o",
"object": "model",
"created": 1715232000,
"owned_by": "openai"
},
{
"id": "claude-sonnet-4-20250514",
"object": "model",
"created": 1743465600,
"owned_by": "anthropic"
},
{
"id": "gemini-2.5-pro",
"object": "model",
"created": 1746057600,
"owned_by": "google"
}
]
}
HTTP 状态码
| 状态码 | 说明 |
|---|---|
| 200 | 请求成功 |
| 401 | API Key 无效或已过期 |
| 429 | 请求频率过高 |
| 500 | 服务器内部错误 |
错误响应示例
{
"error": {
"message": "Invalid API key",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}
注意事项
- 返回的模型列表会根据您的 API Key 权限动态变化
- 建议缓存模型列表,避免频繁请求(推荐缓存 1 小时)
- 可在应用启动时调用此接口进行可用性检查
- 不同模型的
created时间戳可能差异较大,仅代表模型发布时间 - Python 示例依赖
openai库:pip install openai - Node.js 示例依赖
axios库:npm install axios
⌘I
