OpenAI格式
获取指定模型的基础信息。
Try It
GET
/v1/models/{model}https://api-platform.ope.ai认证
使用 Bearer Token 认证。
- Header:
Authorization: Bearer <api-key> - 示例:
Authorization: Bearer sk-xxxxxx
Path 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型 ID |
请求示例
- cURL
- JavaScript
- Python
curl -X GET "https://api-platform.ope.ai/v1/models/{model}" \
-H "Authorization: Bearer $OPEAI_API_KEY"
const model = "gpt-4";
const res = await fetch(`https://api-platform.ope.ai/v1/models/${encodeURIComponent(model)}`, {
headers: {Authorization: `Bearer ${process.env.OPEAI_API_KEY}`},
});
console.log(await res.json());
import os
import requests
resp = requests.get(
"https://api-platform.ope.ai/v1/models/gpt-4",
headers={"Authorization": f"Bearer {os.environ['OPEAI_API_KEY']}"},
timeout=60,
)
print(resp.json())
响应示例
- 成功
- 模型不存在
{
"id": "gpt-4",
"object": "model",
"created": 1687882411,
"owned_by": "openai"
}
模型不存在时,后端返回 HTTP 200,并在响应体中返回 error 对象。
{
"error": {
"message": "The model 'unknown-model' does not exist",
"type": "invalid_request_error",
"param": "model",
"code": "model_not_found"
}
}