docs(health.md): add /health/readiness and /health/liveliness to docs

This commit is contained in:
Krrish Dholakia 2024-01-19 08:45:23 -08:00
parent 9aaa2c417d
commit c5e144af23
5 changed files with 79 additions and 15 deletions

View file

@ -1,4 +1,4 @@
# Modify Incoming Data # Modify / Reject Incoming Requests
Modify data just before making litellm completion calls call on proxy Modify data just before making litellm completion calls call on proxy

View file

@ -5,8 +5,10 @@ Use this to health check all LLMs defined in your config.yaml
The proxy exposes: The proxy exposes:
* a /health endpoint which returns the health of the LLM APIs * a /health endpoint which returns the health of the LLM APIs
* a /test endpoint which makes a ping to the litellm server * a /health/readiness endpoint for returning if the proxy is ready to accept requests
* a /health/liveliness endpoint for returning if the proxy is alive
## `/health`
#### Request #### Request
Make a GET Request to `/health` on the proxy Make a GET Request to `/health` on the proxy
```shell ```shell
@ -39,7 +41,7 @@ litellm --health
} }
``` ```
## Background Health Checks ### Background Health Checks
You can enable model health checks being run in the background, to prevent each model from being queried too frequently via `/health`. You can enable model health checks being run in the background, to prevent each model from being queried too frequently via `/health`.
@ -61,7 +63,7 @@ $ litellm /path/to/config.yaml
curl --location 'http://0.0.0.0:8000/health' curl --location 'http://0.0.0.0:8000/health'
``` ```
## Embedding Models ### Embedding Models
We need some way to know if the model is an embedding model when running checks, if you have this in your config, specifying mode it makes an embedding health check We need some way to know if the model is an embedding model when running checks, if you have this in your config, specifying mode it makes an embedding health check
@ -77,7 +79,7 @@ model_list:
mode: embedding # 👈 ADD THIS mode: embedding # 👈 ADD THIS
``` ```
## Text Completion Models ### Text Completion Models
We need some way to know if the model is a text completion model when running checks, if you have this in your config, specifying mode it makes an embedding health check We need some way to know if the model is a text completion model when running checks, if you have this in your config, specifying mode it makes an embedding health check
@ -92,3 +94,52 @@ model_list:
model_info: model_info:
mode: completion # 👈 ADD THIS mode: completion # 👈 ADD THIS
``` ```
## `/health/readiness`
Unprotected endpoint for checking if proxy is ready to accept requests
Example Request:
```bash
curl --location 'http://0.0.0.0:8000/health/readiness'
```
Example Response:
*If proxy connected to a database*
```json
{
"status": "healthy",
"db": "connected"
}
```
*If proxy not connected to a database*
```json
{
"status": "healthy",
"db": "Not connected"
}
```
`/health/liveliness`
Unprotected endpoint for checking if proxy is alive
Example Request:
```
curl -X 'GET' \
'http://0.0.0.0:8000/health/liveliness' \
-H 'accept: application/json'
```
Example Response:
```json
"I'm alive!"
```

View file

@ -1,5 +1,4 @@
# Multiple Instances of 1 model
# Load Balancing - Multiple Instances of 1 model
Load balance multiple instances of the same model Load balance multiple instances of the same model
The proxy will handle routing requests (using LiteLLM's Router). **Set `rpm` in the config if you want maximize throughput** The proxy will handle routing requests (using LiteLLM's Router). **Set `rpm` in the config if you want maximize throughput**

View file

@ -106,29 +106,41 @@ const sidebars = {
"proxy/configs", "proxy/configs",
{ {
type: 'link', type: 'link',
label: 'All Endpoints', label: '📖 All Endpoints',
href: 'https://litellm-api.up.railway.app/', href: 'https://litellm-api.up.railway.app/',
}, },
"proxy/user_keys", "proxy/user_keys",
"proxy/load_balancing",
"proxy/virtual_keys", "proxy/virtual_keys",
"proxy/users", "proxy/users",
"proxy/ui", "proxy/ui",
"proxy/model_management", "proxy/model_management",
"proxy/reliability", "proxy/health",
"proxy/caching",
{ {
"type": "category", "type": "category",
"label": "Logging, Alerting", "label": "🔥 Load Balancing",
"items": [
"proxy/load_balancing",
"proxy/reliability",
]
},
{
"type": "category",
"label": "Logging, Alerting, Caching",
"items": [ "items": [
"proxy/logging", "proxy/logging",
"proxy/alerting", "proxy/alerting",
"proxy/streaming_logging", "proxy/streaming_logging",
"proxy/caching",
] ]
}, },
"proxy/health", {
"type": "category",
"label": "Admin Controls",
"items": [
"proxy/call_hooks", "proxy/call_hooks",
"proxy/rules", "proxy/rules",
]
},
"proxy/deploy", "proxy/deploy",
"proxy/cli", "proxy/cli",
] ]

View file

@ -2734,6 +2734,8 @@ async def config_yaml_endpoint(config_info: ConfigYAML):
@router.get("/test", tags=["health"]) @router.get("/test", tags=["health"])
async def test_endpoint(request: Request): async def test_endpoint(request: Request):
""" """
[DEPRECATED] use `/health/liveliness` instead.
A test endpoint that pings the proxy server to check if it's healthy. A test endpoint that pings the proxy server to check if it's healthy.
Parameters: Parameters: