File size: 2,127 Bytes
4aed899 08c684a 4aed899 08c684a 4aed899 08c684a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | ---
title: Replicate Inference Provider Examples
emoji: 🚀
colorFrom: blue
colorTo: green
sdk: static
pinned: true
---
# Replicate Inference Provider Examples
Use Replicate through Hugging Face's standard `InferenceClient` by setting `provider="replicate"`. These examples use your `HF_TOKEN` and models available through Hugging Face Inference Providers.
## Image generation
```python
import os
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="replicate",
api_key=os.environ["HF_TOKEN"],
)
image = client.text_to_image(
"A cinematic photo of an astronaut riding a horse",
model="Tongyi-MAI/Z-Image-Turbo",
)
image.save("replicate-astronaut.png")
```
## Image editing
```python
import os
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="replicate",
api_key=os.environ["HF_TOKEN"],
)
with open("cat.png", "rb") as image_file:
input_image = image_file.read()
image = client.image_to_image(
input_image,
prompt="Turn the cat into a tiger.",
model="black-forest-labs/FLUX.2-dev",
)
image.save("replicate-tiger.png")
```
## Video generation
```python
import os
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="replicate",
api_key=os.environ["HF_TOKEN"],
)
video = client.text_to_video(
"A young man walking on the street",
model="Wan-AI/Wan2.2-T2V-A14B",
)
```
## Speech recognition
```python
import os
from huggingface_hub import InferenceClient
client = InferenceClient(
provider="replicate",
api_key=os.environ["HF_TOKEN"],
)
output = client.automatic_speech_recognition(
"sample1.flac",
model="openai/whisper-large-v3",
)
```
## More resources
- [Replicate org on Hugging Face](https://huggingface.co/replicate)
- [Run with Replicate collection](https://huggingface.co/collections/replicate/run-with-replicate-6a04d0792d027edbf66c7155)
- [Replicate provider docs](https://huggingface.co/docs/inference-providers/providers/replicate)
- [Supported Replicate models](https://huggingface.co/models?inference_provider=replicate&sort=trending)
|