lucataco commited on
Commit
9109265
·
verified ·
1 Parent(s): fae2a8e

Add JavaScript quickstart, link to all Replicate models, and billing section

Browse files
Files changed (1) hide show
  1. README.md +45 -5
README.md CHANGED
@@ -9,13 +9,15 @@ pinned: false
9
 
10
  # Run AI with an API
11
 
12
- Replicate lets developers run, fine-tune, and deploy open models with a production-ready API. On Hugging Face, you can use Replicate as an Inference Provider for popular models across image generation, video generation, speech, and audio.
13
 
14
- **Browse Replicate-powered models:** [Run with Replicate](https://huggingface.co/collections/replicate/run-with-replicate-6a04d0792d027edbf66c7155)
 
 
15
 
16
  **Read the integration docs:** [Replicate on Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers/providers/replicate)
17
 
18
- **Reference examples:** [Replicate Inference Provider Examples](https://huggingface.co/spaces/replicate/inference-provider-examples)
19
 
20
  ## Why use Replicate on Hugging Face?
21
 
@@ -23,7 +25,9 @@ Use Replicate infrastructure through Hugging Face's standard Inference Providers
23
 
24
  ## Get started in 30 seconds
25
 
26
- Install the Hub client, set your token, generate an image, and save it locally:
 
 
27
 
28
  ```bash
29
  pip install huggingface_hub pillow
@@ -47,4 +51,40 @@ image = client.text_to_image(
47
  image.save("replicate-astronaut.png")
48
  ```
49
 
50
- For JavaScript, cURL, and task-specific examples, see the [Replicate provider docs](https://huggingface.co/docs/inference-providers/providers/replicate).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
  # Run AI with an API
11
 
12
+ Replicate lets developers run, fine-tune, and deploy open models with a production-ready API. On Hugging Face, you can use Replicate as an Inference Provider for popular models across image generation, image editing, video generation, speech recognition, and text-to-speech.
13
 
14
+ **Featured models:** [Run with Replicate](https://huggingface.co/collections/replicate/run-with-replicate-6a04d0792d027edbf66c7155)
15
+
16
+ **All Replicate-powered models:** [Browse the full list](https://huggingface.co/models?inference_provider=replicate&sort=trending)
17
 
18
  **Read the integration docs:** [Replicate on Hugging Face Inference Providers](https://huggingface.co/docs/inference-providers/providers/replicate)
19
 
20
+ **Examples for every task:** [Replicate Inference Provider Examples](https://huggingface.co/spaces/replicate/inference-provider-examples)
21
 
22
  ## Why use Replicate on Hugging Face?
23
 
 
25
 
26
  ## Get started in 30 seconds
27
 
28
+ Create a token at [huggingface.co/settings/tokens](https://huggingface.co/settings/tokens) with the "Make calls to Inference Providers" permission, then generate an image:
29
+
30
+ **Python**
31
 
32
  ```bash
33
  pip install huggingface_hub pillow
 
51
  image.save("replicate-astronaut.png")
52
  ```
53
 
54
+ **JavaScript**
55
+
56
+ ```bash
57
+ npm install @huggingface/inference
58
+ export HF_TOKEN=hf_...
59
+ ```
60
+
61
+ ```js
62
+ import { InferenceClient } from "@huggingface/inference";
63
+ import { writeFile } from "node:fs/promises";
64
+
65
+ const client = new InferenceClient(process.env.HF_TOKEN);
66
+
67
+ const image = await client.textToImage({
68
+ provider: "replicate",
69
+ model: "Tongyi-MAI/Z-Image-Turbo",
70
+ inputs: "A cinematic photo of an astronaut riding a horse",
71
+ });
72
+
73
+ const ext = image.type.split("/")[1];
74
+ await writeFile(`replicate-astronaut.${ext}`, Buffer.from(await image.arrayBuffer()));
75
+ ```
76
+
77
+ For cURL and task-specific examples, see the [Replicate provider docs](https://huggingface.co/docs/inference-providers/providers/replicate).
78
+
79
+ ## Billing
80
+
81
+ You have two options:
82
+
83
+ - **Bill through Hugging Face (default):** requests are charged to your Hugging Face account at Replicate's rates with no markup, and your monthly HF credits apply. No Replicate account needed.
84
+ - **Use your own Replicate key:** add your Replicate API token in your [Inference Providers settings](https://huggingface.co/settings/inference-providers). Your code stays the same, and usage is billed directly by Replicate.
85
+
86
+ Team and Enterprise orgs can bill usage to the organization with `bill_to="your-org"` (Python) or `{ billTo: "your-org" }` (JavaScript). See [Pricing and Billing](https://huggingface.co/docs/inference-providers/pricing) for details.
87
+
88
+ ## Go further on Replicate
89
+
90
+ Need fine-tuning, deployments, or thousands more models? Visit [replicate.com](https://replicate.com) and the [Replicate docs](https://replicate.com/docs).