You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+18-2Lines changed: 18 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ await uploadFile({
27
27
}
28
28
});
29
29
30
-
// Use Inference API
30
+
// Use HF Inference API
31
31
32
32
awaitinference.chatCompletion({
33
33
model: "meta-llama/Llama-3.1-8B-Instruct",
@@ -53,7 +53,7 @@ await inference.textToImage({
53
53
54
54
This is a collection of JS libraries to interact with the Hugging Face API, with TS types included.
55
55
56
-
-[@huggingface/inference](packages/inference/README.md): Use Inference API (serverless) and Inference Endpoints (dedicated) to make calls to 100,000+ Machine Learning models
56
+
-[@huggingface/inference](packages/inference/README.md): Use Inference API (serverless), Inference Endpoints (dedicated) and third-party Inference providers to make calls to 100,000+ Machine Learning models
57
57
-[@huggingface/hub](packages/hub/README.md): Interact with huggingface.co to create or delete repos and commit / download files
58
58
-[@huggingface/agents](packages/agents/README.md): Interact with HF models through a natural language interface
59
59
-[@huggingface/gguf](packages/gguf/README.md): A GGUF parser that works on remotely hosted files.
@@ -144,6 +144,22 @@ for await (const chunk of inference.chatCompletionStream({
Your access token should be kept private. If you need to protect it in front-end applications, we suggest setting up a proxy server that stores the access token.
44
44
45
+
### Requesting third-party inference providers
46
+
47
+
You can request inference from third-party providers with the inference client.
48
+
49
+
Currently, we support the following providers: [Fal.ai](https://fal.ai), [Replicate](https://replicate.com), [Together](https://together.xyz) and [Sambanova](https://sambanova.ai).
50
+
51
+
To make request to a third-party provider, you have to pass the `provider` parameter to the inference function. Make sure your request is authenticated with an access token.
52
+
```ts
53
+
const accessToken ="hf_..."; // Either a HF access token, or an API key from the 3rd party provider (Replicate in this example)
54
+
55
+
const client =newHfInference(accessToken);
56
+
awaitclient.textToImage({
57
+
provider: "replicate",
58
+
model:"black-forest-labs/Flux.1-dev",
59
+
inputs: "A black forest cake"
60
+
})
61
+
```
62
+
63
+
When authenticated with a Hugging Face access token, the request is routed through https://huggingface.co.
64
+
When authenticated with a third-party provider key, the request is made directly against that provider's inference API.
65
+
66
+
Only a subset of models are supported when requesting 3rd party providers. You can check the list of supported models per pipeline tasks here:
0 commit comments