mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
* test(ci): fix four CircleCI regressions on main Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(ci): stop reloading auth_checks in unit tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(constants): cover CLI JWT expiry env parsing Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * test(gateway): restore proxy lifespan after importing gateway.main in launch tests Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> --------- Co-authored-by: mateo <mateo@berri.ai> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
import os
|
|
from typing import Final
|
|
|
|
import uvicorn
|
|
from dotenv import load_dotenv
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
|
|
def build_app() -> FastAPI:
|
|
load_dotenv()
|
|
os.environ["SERVER_ROOT_PATH"] = "/my-custom-path"
|
|
|
|
from litellm.proxy.proxy_server import app as litellm_app
|
|
from litellm.proxy.proxy_server import proxy_startup_event
|
|
|
|
app: Final = FastAPI(title="Custom LiteLLM Server", lifespan=proxy_startup_event)
|
|
custom_path: Final = "/my-custom-path"
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.mount(custom_path, litellm_app)
|
|
|
|
@app.get("/")
|
|
async def root() -> dict[str, str]:
|
|
return {
|
|
"message": "Welcome to the API Gateway",
|
|
"litellm_endpoint": custom_path,
|
|
}
|
|
|
|
@app.get("/health")
|
|
async def health_check() -> dict[str, str]:
|
|
return {"status": "healthy"}
|
|
|
|
return app
|
|
|
|
|
|
if __name__ == "__main__":
|
|
uvicorn.run(build_app(), host="0.0.0.0", port=4000, log_level="info")
|