feat: implement AI model API proxy service

This commit is contained in:
2026-03-11 18:22:16 +08:00
commit 26738973bd
33 changed files with 4607 additions and 0 deletions

46
backend/app/main.py Normal file
View File

@@ -0,0 +1,46 @@
"""FastAPI application entry point."""
from contextlib import asynccontextmanager
from fastapi import FastAPI
from .database import init_db, seed_default_providers
from .services.logger import async_logger
from .routes import health_router, chat_router, openai_router, anthropic_router
@asynccontextmanager
async def lifespan(app: FastAPI):
"""Application lifespan handler."""
# Startup
await init_db()
await seed_default_providers()
await async_logger.start()
yield
# Shutdown
await async_logger.stop()
app = FastAPI(
title="zzrouter",
description="AI Model API Proxy Service",
version="0.1.0",
lifespan=lifespan
)
# Register routers
app.include_router(health_router)
app.include_router(chat_router)
app.include_router(openai_router)
app.include_router(anthropic_router)
def run_server():
"""Run the server (entry point for script)."""
import uvicorn
from .config import HOST, PORT
uvicorn.run(app, host=HOST, port=PORT)
if __name__ == "__main__":
run_server()