Shyamnath commited on
Commit
ef7bcea
·
1 Parent(s): a1bc0ef

Update api.py with proper Swagger UI and CORS configuration

Browse files
Files changed (1) hide show
  1. api.py +30 -0
api.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI
2
+ from fastapi.middleware.cors import CORSMiddleware
3
+ from litellm.proxy.proxy_server import app as proxy_app
4
+
5
+ # Create FastAPI app
6
+ app = FastAPI(
7
+ title="LiteLLM API",
8
+ version="1.0.0",
9
+ docs_url="/", # Serve Swagger UI at root
10
+ )
11
+
12
+ # Add CORS middleware
13
+ app.add_middleware(
14
+ CORSMiddleware,
15
+ allow_origins=["*"],
16
+ allow_credentials=True,
17
+ allow_methods=["*"],
18
+ allow_headers=["*"],
19
+ )
20
+
21
+ # Mount the LiteLLM Proxy server
22
+ app.mount("/proxy", proxy_app)
23
+
24
+ @app.get("/health")
25
+ def health_check():
26
+ return {"status": "healthy"}
27
+
28
+ if __name__ == "__main__":
29
+ import uvicorn
30
+ uvicorn.run(app, host="0.0.0.0", port=7860)