feat: add authorization header to llama model endpoint fetch

This commit is contained in:
Alpha Nerd 2026-05-28 09:32:20 +02:00
parent 4b5a70e787
commit 13d796817f
Signed by: alpha-nerd
SSH key fingerprint: SHA256:QkkAgVoYi9TQ0UKPkiKSfnerZy2h4qhi3SVPXJmBN+M

View file

@ -192,12 +192,19 @@ class fetch:
For llama-server endpoints: queries /v1/models and filters for status.value == "loaded"
"""
client: aiohttp.ClientSession = get_session(endpoint)
cfg = get_config()
# Check if this is a llama-server endpoint
if endpoint in get_config().llama_server_endpoints:
# Query /v1/models for llama-server
if endpoint in cfg.llama_server_endpoints:
# Query /v1/models for llama-server. Send the configured key as a
# Bearer token — current llama.cpp leaves /models public, but a
# build/config that protects it would otherwise 401 this probe.
headers = {"Referer": default_headers.get("HTTP-Referer", "https://nomyo.ai")}
api_key = cfg.api_keys.get(endpoint)
if api_key is not None:
headers["Authorization"] = "Bearer " + api_key
try:
async with client.get(f"{endpoint}/models") as resp:
async with client.get(f"{endpoint}/models", headers=headers) as resp:
await _ensure_success(resp)
data = await resp.json()