raheem786 commited on
Commit
8059fde
·
verified ·
1 Parent(s): 88195aa

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +16 -10
  2. README.md +21 -2
  3. docker-compose.yaml +1 -0
  4. litellm-config-auto.yaml +9 -0
Dockerfile CHANGED
@@ -1,15 +1,21 @@
1
- # Use the official stable LiteLLM image as the base
2
- FROM ghcr.io/berriai/litellm:main-stable
3
 
4
- # Set the working directory
5
- WORKDIR /app
 
 
 
 
6
 
7
- # Copy your local config into the image
8
- COPY litellm-config-auto.yaml /app/config.yaml
9
 
10
- # Expose the port (Render uses PORT env; default 4000 for local)
11
- EXPOSE 4000
12
 
13
- # PORT from environment (Render sets it); config reads LITELLM_MASTER_KEY, OPENROUTER_API_KEY from env
 
 
 
14
  ENTRYPOINT ["/bin/sh", "-c"]
15
- CMD ["exec litellm --config /app/config.yaml --port ${PORT:-4000}"]
 
1
+ FROM python:3.11-slim
 
2
 
3
+ # Create a non-root user (UID 1000 is required by Hugging Face)
4
+ RUN useradd -m -u 1000 user
5
+ USER user
6
+ ENV HOME=/home/user \
7
+ PATH=/home/user/.local/bin:$PATH
8
+ WORKDIR $HOME/app
9
 
10
+ # Install LiteLLM
11
+ RUN pip install --no-cache-dir 'litellm[proxy]'
12
 
13
+ # Copy your config with correct ownership (source: litellm-config-auto.yaml config.yaml)
14
+ COPY --chown=user litellm-config-auto.yaml config.yaml
15
 
16
+ # MUST use port 7860 for Hugging Face; Render sets PORT at runtime
17
+ EXPOSE 7860
18
+
19
+ # PORT from env (Render); default 7860 for Hugging Face Spaces
20
  ENTRYPOINT ["/bin/sh", "-c"]
21
+ CMD ["exec litellm --config config.yaml --port ${PORT:-7860} --host 0.0.0.0 --no-semantic-tool-filter"]
README.md CHANGED
@@ -1,6 +1,16 @@
1
- # LiteLLM Proxy (Render)
 
 
 
 
 
 
 
 
2
 
3
- LiteLLM proxy for OpenRouter and other providers, deployable to Render and runnable locally with Docker.
 
 
4
 
5
  ## Fix: "Authentication Error, No api key passed in" (401)
6
 
@@ -21,6 +31,7 @@ The config reads **from environment variables** (`os.environ/LITELLM_MASTER_KEY`
21
  |-----|-------|--------|
22
  | `LITELLM_MASTER_KEY` | e.g. `sk-your-secret-key` | Mark as **Secret**. This is the key clients send. |
23
  | `OPENROUTER_API_KEY` | Your OpenRouter API key | Mark as **Secret**. |
 
24
  | `PORT` | (optional) | Render sets this automatically; no need to add. |
25
 
26
  4. Save and redeploy.
@@ -60,3 +71,11 @@ Port is controlled by `PORT` in `.env` (default 4000).
60
  2. Render will use the **Dockerfile**; no build/start command needed.
61
  3. Add **Environment Variables** (see above): `LITELLM_MASTER_KEY` and `OPENROUTER_API_KEY` (mark as Secret).
62
  4. Deploy. Use the service URL and the same master key in `Authorization: Bearer ...` from your app or Cursor.
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: LiteLLM Proxy
3
+ emoji: 🔀
4
+ colorFrom: indigo
5
+ colorTo: blue
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
 
11
+ # LiteLLM Proxy (Render & Hugging Face Space)
12
+
13
+ LiteLLM proxy for OpenRouter, Hugging Face, and other providers, deployable to Render, Hugging Face Spaces (Docker), and runnable locally with Docker.
14
 
15
  ## Fix: "Authentication Error, No api key passed in" (401)
16
 
 
31
  |-----|-------|--------|
32
  | `LITELLM_MASTER_KEY` | e.g. `sk-your-secret-key` | Mark as **Secret**. This is the key clients send. |
33
  | `OPENROUTER_API_KEY` | Your OpenRouter API key | Mark as **Secret**. |
34
+ | `HF_TOKEN` | Your Hugging Face token (`hf_...`) | Optional. Mark as **Secret**. Required only for Hugging Face models (`my-hf-models`). Create at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens). |
35
  | `PORT` | (optional) | Render sets this automatically; no need to add. |
36
 
37
  4. Save and redeploy.
 
71
  2. Render will use the **Dockerfile**; no build/start command needed.
72
  3. Add **Environment Variables** (see above): `LITELLM_MASTER_KEY` and `OPENROUTER_API_KEY` (mark as Secret).
73
  4. Deploy. Use the service URL and the same master key in `Authorization: Bearer ...` from your app or Cursor.
74
+
75
+ ## Deploy to Hugging Face Spaces (Docker)
76
+
77
+ The README includes Spaces frontmatter (`sdk: docker`, `app_port: 7860`). To run this repo as a Space:
78
+
79
+ 1. Create a new Space at [huggingface.co/new-space](https://huggingface.co/new-space), choose **Docker**, and use this repo (or push this repo to the Space).
80
+ 2. In the Space **Settings** → **Variables and secrets**, add **Secrets**: `LITELLM_MASTER_KEY`, `OPENROUTER_API_KEY` (and optionally `HF_TOKEN` for Hugging Face models). Add a **Variable** `PORT` = `7860` so the proxy listens on the Space’s expected port.
81
+ 3. The Space will build from the **Dockerfile** and run the proxy. Use the Space URL (e.g. `https://your-username-litellm-proxy.hf.space`) with `Authorization: Bearer <LITELLM_MASTER_KEY>`.
docker-compose.yaml CHANGED
@@ -9,5 +9,6 @@ services:
9
  environment:
10
  - OPENROUTER_API_KEY=${OPENROUTER_API_KEY}
11
  - LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY:-sk-1234}
 
12
  - PORT=${PORT:-4000}
13
  restart: always
 
9
  environment:
10
  - OPENROUTER_API_KEY=${OPENROUTER_API_KEY}
11
  - LITELLM_MASTER_KEY=${LITELLM_MASTER_KEY:-sk-1234}
12
+ - HF_TOKEN=${HF_TOKEN}
13
  - PORT=${PORT:-4000}
14
  restart: always
litellm-config-auto.yaml CHANGED
@@ -103,6 +103,15 @@ model_list:
103
  litellm_params:
104
  model: openrouter/meta-llama/llama-3-8b-instruct
105
  api_key: "os.environ/OPENROUTER_API_KEY"
 
 
 
 
 
 
 
 
 
106
 
107
  router_settings:
108
  routing_strategy: latency-based-routing
 
103
  litellm_params:
104
  model: openrouter/meta-llama/llama-3-8b-instruct
105
  api_key: "os.environ/OPENROUTER_API_KEY"
106
+ # Hugging Face (set HF_TOKEN in env); format: huggingface/<provider>/<org>/<model>
107
+ - model_name: my-hf-models
108
+ litellm_params:
109
+ model: huggingface/meta-llama/Llama-3.3-70B-Instruct
110
+ api_key: "os.environ/HF_TOKEN"
111
+ - model_name: my-hf-models
112
+ litellm_params:
113
+ model: huggingface/together/deepseek-ai/DeepSeek-R1
114
+ api_key: "os.environ/HF_TOKEN"
115
 
116
  router_settings:
117
  routing_strategy: latency-based-routing