模型與路由
provider/model 命名與各前綴的上游路由規則
Hakila 的 model 欄位使用 OpenRouter 風格的 provider/model 命名。Gateway 依前綴決定上游供應商。
路由表
| 前綴 | 供應商 | 說明 |
|---|---|---|
hakila/auto | 自動選擇 | 依可用金鑰依序嘗試 OpenAI → Gemini → Claude → Grok → OpenRouter |
openai/* | OpenAI | 直連 OpenAI;轉發前會剝除 openai/ 前綴 |
google/* | Gemini | Google OpenAI 相容端點 |
anthropic/* | Claude | Anthropic OpenAI 相容端點 |
x-ai/* | Grok | xAI |
其他(含 openrouter/*) | OpenRouter | model id 原樣轉發 |
hakila/auto 目前依序嘗試的預設上游模型為:gpt-5.6-luna → gemini-flash-latest → claude-haiku-4-5-20251001 → grok-4.3 → openrouter/auto。
查詢可用模型
curl https://api.hakila.ai/api/v1/models \
-H "Authorization: Bearer $HAKILA_API_KEY"回應格式(目錄由後端 ModelCatalog 維護,會隨平台更新):
{
"data": [
{
"id": "hakila/auto",
"name": "Hakila: Auto",
"context_length": 2000000,
"owned_by": "hakila"
},
{
"id": "openai/gpt-5.6-luna",
"name": "OpenAI: GPT-5.6 Luna",
"context_length": 1050000,
"owned_by": "openai"
}
]
}完整清單請以 GET /api/v1/models 為準;目前目錄涵蓋 OpenAI(含 GPT-5.6 / 4.1 / 4o)、Gemini 3.x、Claude 5 / Haiku 4.5、Grok 4.x 與 openrouter/auto。
範例
# 指定 OpenAI
curl https://api.hakila.ai/api/v1/chat/completions \
-H "Authorization: Bearer $HAKILA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"openai/gpt-5.6-luna","messages":[{"role":"user","content":"hi"}]}'
# 自動選路
curl https://api.hakila.ai/api/v1/chat/completions \
-H "Authorization: Bearer $HAKILA_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"hakila/auto","messages":[{"role":"user","content":"hi"}]}'hakila/auto 需要至少一組可用的上游 Provider Key;否則回傳 502。