Repository: huggingface/text-embeddings-inference (Rust)

Issue:
Support env `HF_ENDPOINT`?
### Feature request

Is it possible to support HuggingFace mirror website? Such as env `HF_ENDPOINT` . Like `huggingface_hub` library, it has a environment variable `HF_ENDPOINT` which can use huggingface mirror website to download models.

```bash
export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download --resume-download gpt2 --local-dir gpt2
```
https://hf-mirror.com/

### Motivation

It's difficult to download model in China. Use HF mirror to accelerate model download.

### Your contribution

Moral support


Discussion: You can download the model locally and then use TEI to load the local model.


```sh

model=/path/to/model/weights
volume=/path/to/model

docker run --gpus all  -p 8080:80 -v $volume:/data --pull always ghcr.io/huggingface/text-embeddings-inference:1.5 --model-id /data/weights
```
Hi @nbroad1881 could you give example for `BAAI--bge-reranker-large` I could not make it work. Also it still tries to download `model.safetensors` which is still blocked. I work for crop and all those things are blocked, so it would be greatly appreciated🙏.
@r0kk ,

If it is blocked, then there is nothing that can be done until it gets unblocked.

If you have a local copy, copy the code I have above.

> You can download the model locally and then use TEI to load the local model.
> 
> model=/path/to/model/weights
> volume=/path/to/model
> 
> docker run --gpus all  -p 8080:80 -v $volume:/data --pull always ghcr.io/huggingface/text-embeddings-inference:1.6 --model-id /data/weights





Fix (patch):
diff --git a/Cargo.lock b/Cargo.lock
index c669a692..ab1e39fd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -387,7 +387,7 @@ dependencies = [
  "bitflags 2.9.0",
  "cexpr",
  "clang-sys",
- "itertools 0.12.1",
+ "itertools 0.11.0",
  "lazy_static",
  "lazycell",
  "log",
@@ -1607,11 +1607,9 @@ checksum = "cc03dcb0b0a83ae3f3363ec811014ae669f083e4e499c66602f447c4828737a1"
 dependencies = [
  "dirs",
  "futures",
- "http 1.3.1",
  "indicatif",
  "libc",
  "log",
- "native-tls",
  "num_cpus",
  "rand 0.8.5",
  "reqwest",
@@ -1619,7 +1617,6 @@ dependencies = [
  "serde_json",
  "thiserror 2.0.12",
  "tokio",
- "ureq",
  "windows-sys 0.59.0",
 ]
 
@@ -2104,15 +2101,6 @@ dependencies = [
  "either",
 ]
 
-[[package]]
-name = "itertools"
-version = "0.12.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
-dependencies = [
- "either",
-]
-
 [[package]]
 name = "itertools"
 version = "0.13.0"
@@ -3220,8 +3208,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4"
 dependencies = [
  "bytes",
- "heck 0.5.0",
- "itertools 0.12.1",
+ "heck 0.4.1",
+ "itertools 0.11.0",
  "log",
  "multimap 0.10.0",
  "once_cell",
@@ -3254,7 +3242,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1"
 dependencies = [
  "anyhow",
- "itertools 0.12.1",
+ "itertools 0.11.0",
  "proc-macro2",
  "quote",
  "syn 2.0.100",
@@ -5024,7 +5012,6 @@ dependencies = [
  "base64 0.22.1",
  "flate2",
  "log",
- "native-tls",
  "once_cell",
  "rustls",
  "rustls-pki-types",
diff --git a/backends/candle/Cargo.toml b/backends/candle/Cargo.toml
index ca6dd198..5ee0c730 100644
--- a/backends/candle/Cargo.toml
+++ b/backends/candle/Cargo.toml
@@ -29,7 +29,7 @@ memmap2 = "^0.9"
 [dev-dependencies]
 insta = { git = "https://github.com/OlivierDehaene/insta", rev = "f4f98c0410b91fb5a28b10df98e4422955be9c2c", features = ["yaml"] }
 is_close = "0.1.3"
-hf-hub = "0.4.2"
+hf-hub = { workspace = true }
 anyhow = { workspace = true }
 tokenizers = { workspace = true }
 serial_test = { workspace = true }
diff --git a/router/src/lib.rs b/router/src/lib.rs
index 7c8968ec..ee9b0e41 100644
--- a/router/src/lib.rs
+++ b/router/src/lib.rs
@@ -70,7 +70,9 @@ pub async fn run(
         // Using a local model
         (model_id_path.to_path_buf(), None)
     } else {
-        let mut builder = ApiBuilder::new().with_progress(false).with_token(hf_token);
+        let mut builder = ApiBuilder::from_env()
+            .with_progress(false)
+            .with_token(hf_api_token);
 
         if let Some(cache_dir) = huggingface_hub_cache {
             builder = builder.with_cache_dir(cache_dir.into());