fix(api-proxy): offer a model hf-inference still serves - #82
Open
rickstaa wants to merge 1 commit into
Open
Conversation
hf-inference dropped FLUX.1 schnell (410, "deprecated and no longer
supported by provider"), and it now serves exactly one text-to-image
model, so the second capability cannot be another painter. ViT keeps it
in the same domain by reading an image instead of making one: same
pinned URL, same {"inputs": ...} body, a tenth of the price, and it
classifies what SD3 just painted.
A bare JSON array is neither a JSON object nor opaque bytes, so the
route relabels the response as text for the client to parse.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
livepeer-example/flux-1-schnellis dead. Calling it returnsHTTP 410 {"error":"The requested model is deprecated and no longer supported by provider hf-inference"}, so half of what the example advertises fails for anyone who runs it.There is no same-modality replacement. Hugging Face's model index now lists exactly one text-to-image model on
hf-inference(stabilityai/stable-diffusion-3-medium-diffusers, the one this example already uses). FLUX.1 schnell is still live on nscale, together, fal-ai and wavespeed, but each of those either puts the model in the request body (/v1/images/generations, so nginx can no longer pin it and the operator's token stops being spendable on exactly one model) or answers with a URL rather than the image, and they bill inference-provider credits rather than running on the free provider. Video is worse:hf-inferenceserves no text-to-video model at all, and every provider that does runs it as an async job, which a stock nginx cannot poll without becoming app code.So the second capability stays in the image domain by reversing direction:
google/vit-base-patch16-224reads an image instead of making one. It keeps every property the example teaches — the model pinned in the URL, the caller's{"inputs": ...}body forwarded verbatim,hf-inferenceas the provider — and the price gap is real rather than decorative: one forward pass against a diffusion run, priced at 0.00001 against 0.0001. It also demonstrates itself, since the image SD3 paints is the image ViT reads back.One wrinkle worth reviewing
call_runneraccepts a JSON object or opaque bytes, and raisesLive runner call expected JSON object, got liston anything else. Every Hugging Face inference task other than text-to-image answers with a bare JSON array, so this is not specific to ViT — it is what any config-only proxy hits in front of that API. A runner that is pure config can pin, inject, and relabel but cannot rewrite a body, so the route relabels the responseContent-Typeas text and the client parses it. The README says so in as many words, and the constraint is arguably worth teaching. If we would rather the SDK accepted a top-level array, that is a separate change and this route would drop the relabel.Testing
Both paths, both capabilities:
llamaat0.9937on that same file.fee=52781032608for SD3 andfee=5278103260for ViT, the 10x the config asks for.MAX_PRICE_PER_UNITis unchanged and still clears the highest price.Also updated: the root README transport column, the app README throughout, and the
.env.examplenote that named flux as the cheaper capability.