Skip to content

[Inference Providers] Add Replicate image-to-video support#2144

Open
lucataco wants to merge 1 commit into
huggingface:mainfrom
lucataco:replicate-image-to-video
Open

[Inference Providers] Add Replicate image-to-video support#2144
lucataco wants to merge 1 commit into
huggingface:mainfrom
lucataco:replicate-image-to-video

Conversation

@lucataco

@lucataco lucataco commented May 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add Replicate image-to-video support in the inference provider helper registry.
  • Convert image inputs to data URLs and pass them using the Replicate-compatible image keys (image, images, input_image, input_images).
  • Add a Replicate imageToVideo integration case for Wan-AI/Wan2.1-I2V-14B-720P with a local hardcoded mapping until the public provider mapping includes the model.

Tests

  • pnpm --filter @huggingface/inference check
  • pnpm --filter @huggingface/inference format:check
  • pnpm --filter @huggingface/inference test

cc @hanouticelina


Note

Medium Risk
Adds a new Replicate image-to-video provider helper that changes request payload construction (base64 data URLs and multiple image key variants), which could affect compatibility with different Replicate models and payload size/performance.

Overview
Adds Replicate support for the image-to-video task by registering a new ReplicateImageToVideoTask in the provider helper registry.

The new helper base64-encodes Blob image inputs into data URLs and sends them under several Replicate-expected keys (image, images, input_image, input_images), then normalizes responses that return either a single URL or a list of URLs into a downloaded video Blob.

Extends integration tests with an imageToVideo case using a temporary HARDCODED_MODEL_INFERENCE_MAPPING entry for Wan-AI/Wan2.1-I2V-14B-720P.

Reviewed by Cursor Bugbot for commit 9228cd0. Bugbot is set up for automated code reviews on this repo. Configure here.

@lucataco

lucataco commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

cc @SBrandeis @hanouticelina, could you take a look when you have a chance? This follows the recent Replicate provider support pattern

Comment on lines +223 to +249
override async getResponse(response: ReplicateOutput): Promise<Blob> {
if (
typeof response === "object" &&
!!response &&
"output" in response &&
Array.isArray(response.output) &&
response.output.length > 0 &&
typeof response.output[0] === "string" &&
isUrl(response.output[0])
) {
const urlResponse = await fetch(response.output[0]);
return await urlResponse.blob();
}

if (
typeof response === "object" &&
!!response &&
"output" in response &&
typeof response.output === "string" &&
isUrl(response.output)
) {
const urlResponse = await fetch(response.output);
return await urlResponse.blob();
}

throw new InferenceClientProviderOutputError("Received malformed response from Replicate image-to-video API");
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my understanding, the new task "blocks" (waits for the HTTP response) until the model has generated the video, is that correct?

In other words: there is no polling for the generated video

If so, it might be an issue because video models can have generation times larger than 60s which has been proven to be an issue for our proxy layer, due to timeouts

cc @hanouticelina for validation

Comment on lines +200 to +204
lora_weights:
params.mapping?.adapter === "lora" && params.mapping.adapterWeightsPath
? `https://huggingface.co/${params.mapping.hfModelId}`
: undefined,
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants