模型列表 API
模型列表 API
Section titled “模型列表 API”GET /v1/models 是 OpenAI 兼容的模型列表端点,返回当前 API Key 可见的模型。
| Header | 值 |
|---|---|
Authorization | Bearer <api-key> |
无请求体,无 Query 参数。
200 OK
Section titled “200 OK”{ "object": "list", "data": [ { "id": "gpt-4o", "object": "model", "created": 1700000000, "ownedBy": "system" }, { "id": "claude-sonnet-4-20250514", "object": "model", "created": 1700000000, "ownedBy": "system" } ]}返回的模型列表基于 API Key 关联的 applicationId,仅包含该应用授权渠道下的可见模型。若预期模型未出现,请检查应用渠道授权(应用管理)。
HTTP 状态码
Section titled “HTTP 状态码”| 状态码 | 说明 |
|---|---|
| 200 | 成功 |
| 401 | API Key 无效 |
curl https://{gateway-host}/v1/models -H "Authorization: Bearer sk-xxx"from openai import OpenAI
client = OpenAI(base_url="https://{gateway-host}/v1", api_key="sk-xxx")models = client.models.list()for m in models.data: print(m.id)import OpenAI from 'openai';
const client = new OpenAI({ baseURL: 'https://{gateway-host}/v1', apiKey: 'sk-xxx' });const models = await client.models.list();models.data.forEach((m) => console.log(m.id));