Skip to content

Commit bca4f71

Browse files
authored
[Fix Replicate] Send Prefer:wait header (huggingface#1249)
Fixing a bug introduced in huggingface#1208 and more precisely [here](https://github.com/huggingface/huggingface.js/pull/1208/files#diff-ba5cb4afef57c85afde67b883b333c80972fc4ac5d3083d929447105ebfbe55fL107). For Replicate provider, we must send `Prefer: wait` header as this is the only path we support for now. --- Tested locally and it fixes the textToVideo issue we have on https://huggingface.co/Wan-AI/Wan2.1-T2V-14B ```ts import { HfInference } from "@huggingface/inference"; import fs from "fs/promises"; async function generateTextToVideo() { const hf = new HfInference("xxx"); const res = await hf.textToVideo({ inputs: "a cat swimming in an ocean of bananas", provider: "replicate", model: "Wan-AI/Wan2.1-T2V-14B", }); const arrayBuffer = await res.arrayBuffer(); const buffer = Buffer.from(arrayBuffer); await fs.writeFile("output.mp4", buffer); } generateTextToVideo(); ``` https://github.com/user-attachments/assets/4234c65e-ab11-45e0-9e29-825f88b2be49 cc @SBrandeis @kefranabg @zeke
1 parent 8b8c685 commit bca4f71

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/inference/src/providers/replicate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const makeBody = (params: BodyParams): Record<string, unknown> => {
2626
};
2727

2828
const makeHeaders = (params: HeaderParams): Record<string, string> => {
29-
return { Authorization: `Bearer ${params.accessToken}` };
29+
return { Authorization: `Bearer ${params.accessToken}`, Prefer: "wait" };
3030
};
3131

3232
const makeUrl = (params: UrlParams): string => {

0 commit comments

Comments
 (0)