Skip to content

🐛 inference: honor DeepInfra image output types - #2886

Open
KuroGeo wants to merge 1 commit into
huggingface:mainfrom
KuroGeo:fix/deepinfra-image-output-types
Open

KuroGeo wants to merge 1 commit into
huggingface:mainfrom
KuroGeo:fix/deepinfra-image-output-types

Conversation

@KuroGeo

@KuroGeo KuroGeo commented Nov 18, 2026 •

Copy link
Copy Markdown

When DeepInfra returns data[0].url, textToImage() currently returns that URL string even for the default/blob or dataUrl output type. This contradicts the requested output contract and breaks callers expecting a Blob.

Download URL responses for Blob/data-URL output, preserving the downloaded bytes and MIME type and forwarding the abort signal. Reject failed downloads. Explicit url and json output still return without downloading; the base64 response path is unchanged.

Fixes #2884.

Validation (Node 22.19.0):

  • Full inference package tests: 35 passed, 123 existing skipped; all 9 new cases passed. Five regression cases fail against unmodified production code.
  • Full inference package tests in headless Chrome: 33 passed, 125 existing skipped; all 9 new cases passed. No skips or timeouts were added.
  • pnpm --filter @huggingface/inference... build passed, including workspace dependencies.
  • Inference package check, lint:check, and format:check, plus git diff --check, passed.

The tests exercise the real provider helper with synthetic provider responses and mocked image downloads; no live DeepInfra inference was called. URL downloads use the existing global fetch path; this patch does not add custom-fetch plumbing. Prepared with AI assistance and independently reviewed by an AI reviewer.


Note

Low Risk
Scoped to DeepInfra image response shaping and an outbound fetch of provider-supplied URLs; no auth or core API contract changes beyond fixing incorrect return types.

Overview
DeepInfra textToImage no longer returns a bare provider URL when callers ask for the default/blob or dataUrl output. For URL-shaped API responses it now downloads the image (with abort signal forwarding), returns a Blob or dataUrl via dataUrlFromBlob, and throws InferenceClientProviderOutputError on failed downloads.

Explicit url and json output still skip the download; the existing b64_json conversion path is unchanged.

Adds deepinfra-image-output.spec.ts with mocked fetch coverage for blob/dataUrl/url/json, failed downloads, cancellation, and base64 responses.

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

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.

DeepInfra text-to-image returns a URL string when a Blob or data URL is requested

1 participant