Skip to content

Conversation

inf3rnus
Copy link

@inf3rnus inf3rnus commented Oct 6, 2025

Hey there all,

We're Bytez, and we're the largest inference provider on the internet! (We offer inference for 170k+ models.)

We're stuck on step 3 of the integration guide presumably because we need to be added as a provider. (We are unable to use the model mapping api because we don't exist as a provider on your backend.)

This PR allows for Bytez to be used as an inference provider (bytez-ai).

For the most part, changes are isolated to just the Bytez code with the exception of 5 places:

  1. packages/inference/src/tasks/audio/audioClassification.ts
  2. packages/inference/src/tasks/cv/imageClassification.ts
  3. packages/inference/src/tasks/cv/objectDetection.ts
  4. packages/inference/src/tasks/cv/imageToText.ts
  5. packages/inference/src/providers/hf-inference.ts

The first three have this simple addition to allow for the flexibility to prepare a payload async, which better aligns with how the other tasks are setup.

	const payload = providerHelper.preparePayloadAsync
		? await providerHelper.preparePayloadAsync(args)
		: preparePayload(args);

I'd have dug deeper to bring greater consistency for all of the tasks, but opted for these simple adjustments to see what you guys have to say before making any major changes.

The final task change, packages/inference/src/tasks/cv/imageToText.ts follows the same pattern, but also changes the passing of the response to this:

return providerHelper.getResponse(res);

It used to be:

return providerHelper.getResponse(res[0]);

There isn't a hook higher up in the call stack (AFAIK) for us to adapt our response to look like an array, so I've opted for this.

To ensure that the existing hf-inference provider code still works, I've modified the HFInferenceImageToTextTask to destructure the array internally, which to me seems more consistent with the general pattern, where the raw response is untouched until it is passed to the getResponse() handler.

export class HFInferenceImageToTextTask extends HFInferenceTask implements ImageToTextTaskHelper {
	override async getResponse(response: ImageToTextOutput[]): Promise<ImageToTextOutput> {
		const [first] = response
		if (typeof first?.generated_text !== "string") {
			throw new InferenceClientProviderOutputError(
				"Received malformed response from HF-Inference image-to-text API: expected {generated_text: string}"
			);
		}
		return first;
	}
}

Please let us know if we need to do anything else! 🙏

Also, as a question, is it normal for us to not be able to hit https://huggingface.co/api/partners/bytez-ai/models until this PR is accepted and we are on a Team/Enterprise plan? FWIW we are on a Team/Enterprise plan.

If so, we'd like to help you update your docs to make this more explicit!

We look forward to integrating!

Long live huggingface! 🤗

@inf3rnus inf3rnus changed the title 09 0 25 bytez integration Bytez Model Provider Integration Oct 6, 2025
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.

1 participant