feat: transparent anthropic api incl. native anthropic api backend

This commit is contained in:
Alpha Nerd 2026-07-06 10:46:18 +02:00
parent c9e495876b
commit 1d012a92ef
Signed by: alpha-nerd
SSH key fingerprint: SHA256:QkkAgVoYi9TQ0UKPkiKSfnerZy2h4qhi3SVPXJmBN+M
11 changed files with 1431 additions and 20 deletions

View file

@ -665,10 +665,16 @@ async def openai_models_proxy(request: Request):
fetch.endpoint_details(ep, "/models", "data", config.api_keys.get(ep), skip_error_cache=True, timeout=8)
for ep in all_llama_endpoints
]
# 4. Query native Anthropic endpoints via /v1/models (auth headers picked by endpoint type)
anthropic_tasks = [
fetch.endpoint_details(ep, "/v1/models", "data", config.api_keys.get(ep), skip_error_cache=True, timeout=8)
for ep in config.anthropic_endpoints
]
ollama_models = await asyncio.gather(*ollama_tasks) if ollama_tasks else []
ext_openai_models = await asyncio.gather(*ext_openai_tasks) if ext_openai_tasks else []
llama_models = await asyncio.gather(*llama_tasks) if llama_tasks else []
anthropic_models = await asyncio.gather(*anthropic_tasks) if anthropic_tasks else []
models = {'data': []}
@ -702,6 +708,16 @@ async def openai_models_proxy(request: Request):
model['name'] = model['id']
models['data'].append(model)
# Add native Anthropic models (if any)
if anthropic_models:
for modellist in anthropic_models:
for model in modellist:
if not "id" in model.keys():
model['id'] = model.get('name', model.get('id', ''))
else:
model['name'] = model['id']
models['data'].append(model)
# 2. Return a JSONResponse with a deduplicated list of unique models for inference
return JSONResponse(
content={"data": dedupe_on_keys(models['data'], ['name'])},