MCPcopy Create free account
hub / github.com/ZyphrZero/z.ai2api_python / list_models

Function list_models

app/core/openai.py:88–102  ·  view source on GitHub ↗

返回当前服务支持的模型列表。

()

Source from the content-addressed store, hash-verified

86
87@router.get("/v1/models")
88async def list_models():
89 """返回当前服务支持的模型列表。"""
90 try:
91 client = get_upstream_client()
92 current_time = int(time.time())
93 response = ModelsResponse(
94 data=[
95 Model(id=model_id, created=current_time, owned_by=settings.SERVICE_NAME)
96 for model_id in client.get_supported_models()
97 ]
98 )
99 return JSONResponse(content=response.model_dump(exclude_none=True))
100 except Exception as exc:
101 logger.error(f"❌ 获取模型列表失败: {exc}")
102 raise HTTPException(status_code=500, detail=f"Failed to list models: {exc}")
103
104
105@router.post("/v1/chat/completions")

Callers

nothing calls this directly

Calls 4

ModelsResponseClass · 0.90
ModelClass · 0.90
get_upstream_clientFunction · 0.85
get_supported_modelsMethod · 0.80

Tested by

no test coverage detected