Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/inference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Currently, we support the following providers:
- [Groq](https://groq.com)
- [Wavespeed.ai](https://wavespeed.ai/)
- [Z.ai](https://z.ai/)
- [ZenMux](https://zenmux.ai)

To send requests to a third-party provider, you have to pass the `provider` parameter to the inference function. The default value of the `provider` parameter is "auto", which will select the first of the providers available for the model, sorted by your preferred order in https://hf.co/settings/inference-providers.

Expand Down Expand Up @@ -112,6 +113,7 @@ Only a subset of models are supported when requesting third-party providers. You
- [Novita AI supported models](https://huggingface.co/api/partners/novita/models)
- [Wavespeed.ai supported models](https://huggingface.co/api/partners/wavespeed/models)
- [Z.ai supported models](https://huggingface.co/api/partners/zai-org/models)
- [ZenMux supported models](https://huggingface.co/api/partners/zenmux/models)

❗**Important note:** To be compatible, the third-party API must adhere to the "standard" shape API we expect on HF model pages for each pipeline task type.
This is not an issue for LLMs as everyone converged on the OpenAI API anyways, but can be more tricky for other tasks like "text-to-image" or "automatic-speech-recognition" where there exists no standard API. Let us know if any help is needed or if we can make things easier for you!
Expand Down
4 changes: 4 additions & 0 deletions packages/inference/src/lib/getProviderHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import * as Scaleway from "../providers/scaleway.js";
import * as Together from "../providers/together.js";
import * as Wavespeed from "../providers/wavespeed.js";
import * as Zai from "../providers/zai-org.js";
import * as Zenmux from "../providers/zenmux.js";
import type { InferenceProvider, InferenceProviderOrPolicy, InferenceTask } from "../types.js";
import { InferenceClientInputError } from "../errors.js";

Expand Down Expand Up @@ -200,6 +201,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
"text-to-image": new Zai.ZaiTextToImageTask(),
"image-to-text": new Zai.ZaiImageToTextTask(),
},
zenmux: {
conversational: new Zenmux.ZenmuxConversationalTask(),
},
};

/**
Expand Down
1 change: 1 addition & 0 deletions packages/inference/src/providers/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
together: {},
wavespeed: {},
"zai-org": {},
zenmux: {},
};
30 changes: 30 additions & 0 deletions packages/inference/src/providers/zenmux.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* See the registered mapping of HF model ID => ZenMux model ID here:
*
* https://huggingface.co/api/partners/zenmux/models
*
* This is a publicly available mapping.
*
* If you want to try to run inference for a new model locally before it's registered on huggingface.co,
* you can add it to the dictionary "HARDCODED_MODEL_ID_MAPPING" in consts.ts, for dev purposes.
*
* - If you work at ZenMux and want to update this mapping, please use the model mapping API we provide on huggingface.co
* - If you're a community member and want to add a new supported HF model to ZenMux, please open an issue on the present repo
* and we will tag ZenMux team members.
*
* Thanks!
*/
import { HeaderParams } from "../types.js";
import { BaseConversationalTask } from "./providerHelper.js";

export class ZenmuxConversationalTask extends BaseConversationalTask {
constructor() {
super("zenmux", "https://zenmux.ai/api/v1");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Duplicated v1 path segment in API URL

High Severity

The base URL "https://zenmux.ai/api/v1" already includes a /v1 segment, but the inherited BaseConversationalTask.makeRoute() returns "v1/chat/completions". When makeUrl combines them, the resulting URL becomes https://zenmux.ai/api/v1/v1/chat/completions with a duplicated v1. All direct API calls (with provider-key auth) will hit the wrong endpoint and fail.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 27f1632. Configure here.

}
override prepareHeaders(params: HeaderParams, binary: boolean): Record<string, string> {
const headers = super.prepareHeaders(params, binary);
headers["x-source-channel"] = "hugging_face";
headers["accept-language"] = "en-US,en";
return headers;
}
}
2 changes: 2 additions & 0 deletions packages/inference/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export const INFERENCE_PROVIDERS = [
"together",
"wavespeed",
"zai-org",
"zenmux",
] as const;

export const PROVIDERS_OR_POLICIES = [...INFERENCE_PROVIDERS, "auto"] as const;
Expand Down Expand Up @@ -109,6 +110,7 @@ export const PROVIDERS_HUB_ORGS: Record<InferenceProvider, string> = {
together: "togethercomputer",
wavespeed: "wavespeed",
"zai-org": "zai-org",
zenmux: "zenmux",
};

export interface InferenceProviderMappingEntry {
Expand Down