获取模型
GET
/v1beta/models/{model}使用 Google Gemini API 格式获取模型元数据
以 Google Gemini API 格式返回特定模型的元数据。
路径参数
参数 model
模型名称(例如:gemini-2.5-pro,gemini-2.5-flash)。也支持别名。
认证
必填。支持与其他 Gemini 端点相同的认证方式:
?key=YOUR_API_KEY查询参数x-goog-api-key: YOUR_API_KEY请求头Authorization: Bearer YOUR_API_KEY请求头
响应
响应字段 name
models/{model} 格式的模型资源名称。
响应字段 displayName
人类可读的模型名称。
响应字段 inputTokenLimit
最大输入 token 数(上下文窗口)。
响应字段 outputTokenLimit
最大输出 token 数。
响应字段 supportedGenerationMethods
支持的生成方法列表(例如:generateContent、countTokens、streamGenerateContent)。
请求示例
curl "https://api.anypath.dev/v1beta/models/gemini-2.5-pro"
import google.generativeai as genai
genai.configure(
api_key="sk-your-api-key",
transport="rest",
client_options={"api_endpoint": "api.anypath.dev"}
)
model = genai.get_model("models/gemini-2.5-pro")
print(f"Name: {model.name}")
print(f"Input limit: {model.input_token_limit}")
print(f"Output limit: {model.output_token_limit}")
响应示例
{
"name": "models/gemini-2.5-pro",
"version": "1.0",
"displayName": "gemini-2.5-pro",
"description": "AnyPath routeable Gemini-compatible model.",
"inputTokenLimit": 1048576,
"outputTokenLimit": 65536,
"supportedGenerationMethods": ["generateContent", "countTokens", "streamGenerateContent"]
}