Skip to content
Closed
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
30 changes: 16 additions & 14 deletions packages/inference/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@ Your access token should be kept private. If you need to protect it in front-end
You can send inference requests to third-party providers with the inference client.

Currently, we support the following providers:
- [Baseten](https://baseten.co)
- [Blackforestlabs](https://blackforestlabs.ai)
- [Cerebras](https://cerebras.ai/)
- [Clarifai](http://clarifai.com)
- [Cohere](https://cohere.com)
- [DeepInfra](https://deepinfra.com)
- [Fal.ai](https://fal.ai)
- [Featherless AI](https://featherless.ai)
- [Fireworks AI](https://fireworks.ai)
- [Groq](https://groq.com)
- [HF Inference](https://huggingface.co/docs/inference-providers/providers/hf-inference)
- [Hyperbolic](https://hyperbolic.xyz)
- [Nebius](https://studio.nebius.ai)
Expand All @@ -61,14 +68,8 @@ Currently, we support the following providers:
- [Replicate](https://replicate.com)
- [Sambanova](https://sambanova.ai)
- [Scaleway](https://www.scaleway.com/en/generative-apis/)
- [Clarifai](http://clarifai.com)
- [Telnyx](https://telnyx.com/)
- [Together](https://together.xyz)
- [Baseten](https://baseten.co)
- [Blackforestlabs](https://blackforestlabs.ai)
- [Cohere](https://cohere.com)
- [Cerebras](https://cerebras.ai/)
- [DeepInfra](https://deepinfra.com)
- [Groq](https://groq.com)
- [Wavespeed.ai](https://wavespeed.ai/)
- [Z.ai](https://z.ai/)

Expand All @@ -90,26 +91,27 @@ When authenticated with a Hugging Face access token, the request is routed throu
When authenticated with a third-party provider key, the request is made directly against that provider's inference API.

Only a subset of models are supported when requesting third-party providers. You can check the list of supported models per pipeline tasks here:
- [Baseten supported models](https://huggingface.co/api/partners/baseten/models)
- [Cerebras supported models](https://huggingface.co/api/partners/cerebras/models)
- [Clarifai supported models](https://huggingface.co/api/partners/clarifai/models)
- [Cohere supported models](https://huggingface.co/api/partners/cohere/models)
- [DeepInfra supported models](https://huggingface.co/api/partners/deepinfra/models)
- [Fal.ai supported models](https://huggingface.co/api/partners/fal-ai/models)
- [Featherless AI supported models](https://huggingface.co/api/partners/featherless-ai/models)
- [Fireworks AI supported models](https://huggingface.co/api/partners/fireworks-ai/models)
- [Groq supported models](https://console.groq.com/docs/models)
- [HF Inference supported models](https://huggingface.co/api/partners/hf-inference/models)
- [Hyperbolic supported models](https://huggingface.co/api/partners/hyperbolic/models)
- [Nebius supported models](https://huggingface.co/api/partners/nebius/models)
- [Novita AI supported models](https://huggingface.co/api/partners/novita/models)
- [Nscale supported models](https://huggingface.co/api/partners/nscale/models)
- [NVIDIA supported models](https://huggingface.co/api/partners/nvidia/models)
- [OVHcloud supported models](https://huggingface.co/api/partners/ovhcloud/models)
- [Replicate supported models](https://huggingface.co/api/partners/replicate/models)
- [Sambanova supported models](https://huggingface.co/api/partners/sambanova/models)
- [Scaleway supported models](https://huggingface.co/api/partners/scaleway/models)
- [Telnyx supported models](https://huggingface.co/api/partners/telnyx/models)
- [Together supported models](https://huggingface.co/api/partners/together/models)
- [Baseten supported models](https://huggingface.co/api/partners/baseten/models)
- [Clarifai supported models](https://huggingface.co/api/partners/clarifai/models)
- [Cohere supported models](https://huggingface.co/api/partners/cohere/models)
- [Cerebras supported models](https://huggingface.co/api/partners/cerebras/models)
- [DeepInfra supported models](https://huggingface.co/api/partners/deepinfra/models)
- [Groq supported models](https://console.groq.com/docs/models)
- [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)

Expand Down
6 changes: 5 additions & 1 deletion packages/inference/src/lib/getProviderHelper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as Baseten from "../providers/baseten.js";
import * as Clarifai from "../providers/clarifai.js";
import * as BlackForestLabs from "../providers/black-forest-labs.js";
import * as Cerebras from "../providers/cerebras.js";
import * as Clarifai from "../providers/clarifai.js";
import * as Cohere from "../providers/cohere.js";
import * as DeepInfra from "../providers/deepinfra.js";
import * as FalAI from "../providers/fal-ai.js";
Expand Down Expand Up @@ -55,6 +55,7 @@ import type {
import * as Replicate from "../providers/replicate.js";
import * as Sambanova from "../providers/sambanova.js";
import * as Scaleway from "../providers/scaleway.js";
import * as Telnyx from "../providers/telnyx.js";
import * as Together from "../providers/together.js";
import * as Wavespeed from "../providers/wavespeed.js";
import * as Zai from "../providers/zai-org.js";
Expand Down Expand Up @@ -182,6 +183,9 @@ export const PROVIDERS: Record<InferenceProvider, Partial<Record<InferenceTask,
"text-generation": new Scaleway.ScalewayTextGenerationTask(),
"feature-extraction": new Scaleway.ScalewayFeatureExtractionTask(),
},
telnyx: {
conversational: new Telnyx.TelnyxConversationalTask(),
},
together: {
"text-to-image": new Together.TogetherTextToImageTask(),
"image-to-image": new Together.TogetherImageToImageTask(),
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 @@ -40,6 +40,7 @@ export const HARDCODED_MODEL_INFERENCE_MAPPING: Record<
replicate: {},
sambanova: {},
scaleway: {},
telnyx: {},
together: {},
wavespeed: {},
"zai-org": {},
Expand Down
28 changes: 28 additions & 0 deletions packages/inference/src/providers/telnyx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* See the registered mapping of HF model ID => Telnyx model ID here:
*
* https://huggingface.co/api/partners/telnyx/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 Telnyx 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 Telnyx, please open an issue on the present repo
* and we will tag Telnyx team members.
*
* Thanks!
*/

import { BaseConversationalTask } from "./providerHelper.js";

export class TelnyxConversationalTask extends BaseConversationalTask {
constructor() {
super("telnyx", "https://api.telnyx.com/v2/ai/openai");
}

override makeRoute(): string {
return "chat/completions";
}
}
2 changes: 2 additions & 0 deletions packages/inference/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export const INFERENCE_PROVIDERS = [
"replicate",
"sambanova",
"scaleway",
"telnyx",
"together",
"wavespeed",
"zai-org",
Expand Down Expand Up @@ -106,6 +107,7 @@ export const PROVIDERS_HUB_ORGS: Record<InferenceProvider, string> = {
replicate: "replicate",
sambanova: "sambanovasystems",
scaleway: "scaleway",
telnyx: "telnyx",
together: "togethercomputer",
wavespeed: "wavespeed",
"zai-org": "zai-org",
Expand Down
15 changes: 15 additions & 0 deletions packages/inference/test/provider-helper.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { describe, expect, it } from "vitest";

import { getProviderHelper } from "../src/lib/getProviderHelper.js";

describe("provider helpers", () => {
it("resolves Telnyx conversational helper with direct provider route", () => {
const helper = getProviderHelper("telnyx", "conversational");
const urlParams = { authMethod: "provider-key" as const, model: "telnyx/test-model" };

expect(helper.provider).toBe("telnyx");
expect(helper.makeBaseUrl(urlParams)).toBe("https://api.telnyx.com/v2/ai/openai");
expect(helper.makeRoute(urlParams)).toBe("chat/completions");
expect(helper.makeUrl(urlParams)).toBe("https://api.telnyx.com/v2/ai/openai/chat/completions");
});
});