Add POST /openai/v1/embeddings route in openai_gateway router, new config fields for embedding upstream URL/model/key/enabled toggle with defaults pointing to OpenRouter Qwen3 8B, INTERNAL_EMBED_MODEL constant in config.py, documentation in docs_api.py and README.md describing the molodetz~embed model mapping, and embed-call tracking in gateway metrics alongside existing chat/vision counters.
31 lines
868 B
Python
31 lines
868 B
Python
# retoor <retoor@molodetz.nl>
|
|
|
|
import logging
|
|
from fastapi import APIRouter, Request, HTTPException
|
|
from devplacepy.services.manager import service_manager
|
|
|
|
logger = logging.getLogger(__name__)
|
|
router = APIRouter()
|
|
|
|
|
|
def _service():
|
|
svc = service_manager.get_service("openai")
|
|
if svc is None:
|
|
raise HTTPException(status_code=503, detail="Gateway is not available")
|
|
return svc
|
|
|
|
|
|
@router.post("/v1/chat/completions")
|
|
async def chat_completions(request: Request):
|
|
return await _service().handle(request, "chat/completions")
|
|
|
|
|
|
@router.post("/v1/embeddings")
|
|
async def embeddings(request: Request):
|
|
return await _service().handle(request, "embeddings")
|
|
|
|
|
|
@router.api_route("/v1/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "PATCH"])
|
|
async def passthrough(request: Request, path: str):
|
|
return await _service().handle(request, path)
|