Spaces:
Running
Running
Deploy LiteLLM proxy
Browse files- README.md +16 -1
- config.yaml +12 -2
README.md
CHANGED
|
@@ -12,13 +12,15 @@ This Space runs the LiteLLM proxy, providing an OpenAI-compatible API that can r
|
|
| 12 |
## Secrets to Set (Space Settings -> Secrets)
|
| 13 |
|
| 14 |
- `LITELLM_MASTER_KEY`: master key required in `Authorization: Bearer ...`
|
| 15 |
-
- `
|
|
|
|
| 16 |
- `ANTHROPIC_API_KEY`: for Anthropic routing
|
| 17 |
|
| 18 |
## Useful Endpoints
|
| 19 |
|
| 20 |
- `GET /health/liveliness` (no auth) - good for keep-alive pings
|
| 21 |
- `POST /chat/completions` (auth) - OpenAI-compatible chat completions
|
|
|
|
| 22 |
|
| 23 |
## Example Curl
|
| 24 |
|
|
@@ -36,6 +38,19 @@ curl -sS https://YOUR-SPACE.hf.space/chat/completions \
|
|
| 36 |
}'
|
| 37 |
```
|
| 38 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
Anthropic via alias:
|
| 40 |
|
| 41 |
```bash
|
|
|
|
| 12 |
## Secrets to Set (Space Settings -> Secrets)
|
| 13 |
|
| 14 |
- `LITELLM_MASTER_KEY`: master key required in `Authorization: Bearer ...`
|
| 15 |
+
- `GMN_API_KEY`: for the third-party OpenAI-compatible gateway
|
| 16 |
+
- `GMN_API_BASE`: set to `https://gmn.chuangzuoli.com/v1`
|
| 17 |
- `ANTHROPIC_API_KEY`: for Anthropic routing
|
| 18 |
|
| 19 |
## Useful Endpoints
|
| 20 |
|
| 21 |
- `GET /health/liveliness` (no auth) - good for keep-alive pings
|
| 22 |
- `POST /chat/completions` (auth) - OpenAI-compatible chat completions
|
| 23 |
+
- `POST /v1/responses` (auth) - OpenAI-compatible Responses API (recommended)
|
| 24 |
|
| 25 |
## Example Curl
|
| 26 |
|
|
|
|
| 38 |
}'
|
| 39 |
```
|
| 40 |
|
| 41 |
+
Responses API (some gateways require this exact path + OpenAI-Beta header):
|
| 42 |
+
|
| 43 |
+
```bash
|
| 44 |
+
curl -sS https://YOUR-SPACE.hf.space/v1/responses \
|
| 45 |
+
-H "Authorization: Bearer $LITELLM_MASTER_KEY" \
|
| 46 |
+
-H "Content-Type: application/json" \
|
| 47 |
+
-H "OpenAI-Beta: responses=v1" \
|
| 48 |
+
-d '{
|
| 49 |
+
"model": "gpt-4o-mini",
|
| 50 |
+
"input": "Say hi"
|
| 51 |
+
}'
|
| 52 |
+
```
|
| 53 |
+
|
| 54 |
Anthropic via alias:
|
| 55 |
|
| 56 |
```bash
|
config.yaml
CHANGED
|
@@ -3,7 +3,13 @@ model_list:
|
|
| 3 |
- model_name: gpt-4o-mini
|
| 4 |
litellm_params:
|
| 5 |
model: openai/gpt-4o-mini
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
# Pick a modern, fast Claude Sonnet variant as the default alias.
|
| 9 |
# You can still call any Anthropic model via `anthropic/<model>` because of the wildcard route.
|
|
@@ -16,7 +22,11 @@ model_list:
|
|
| 16 |
- model_name: openai/*
|
| 17 |
litellm_params:
|
| 18 |
model: openai/*
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
model_info:
|
| 21 |
health_check_model: openai/gpt-4o-mini
|
| 22 |
|
|
|
|
| 3 |
- model_name: gpt-4o-mini
|
| 4 |
litellm_params:
|
| 5 |
model: openai/gpt-4o-mini
|
| 6 |
+
# Third-party OpenAI-compatible endpoint
|
| 7 |
+
api_base: "os.environ/GMN_API_BASE"
|
| 8 |
+
api_key: "os.environ/GMN_API_KEY"
|
| 9 |
+
# Some gateways/WAFs require specific headers to allow /v1/responses
|
| 10 |
+
extra_headers:
|
| 11 |
+
OpenAI-Beta: "responses=v1"
|
| 12 |
+
User-Agent: "curl/8.0"
|
| 13 |
|
| 14 |
# Pick a modern, fast Claude Sonnet variant as the default alias.
|
| 15 |
# You can still call any Anthropic model via `anthropic/<model>` because of the wildcard route.
|
|
|
|
| 22 |
- model_name: openai/*
|
| 23 |
litellm_params:
|
| 24 |
model: openai/*
|
| 25 |
+
api_base: "os.environ/GMN_API_BASE"
|
| 26 |
+
api_key: "os.environ/GMN_API_KEY"
|
| 27 |
+
extra_headers:
|
| 28 |
+
OpenAI-Beta: "responses=v1"
|
| 29 |
+
User-Agent: "curl/8.0"
|
| 30 |
model_info:
|
| 31 |
health_check_model: openai/gpt-4o-mini
|
| 32 |
|